Exemple #1
0
def fingerplot(siteinput, descr, isVC):
    client = ApiClient(app.config['CORTIPY_API_KEY'],
                       apiServer="http://api.cortical.io/rest")

    if descr == 'n':
        # flash('website!')
        con = mysql.connect()
        cur = con.cursor()

        if isVC == "y":
            sql = """SELECT text FROM vctest4 WHERE siteurl = %s"""
        else:
            sql = """SELECT text FROM crunchbase_startups WHERE siteurl = %s"""
        cur.execute(sql, (siteinput, ))

        con.commit()

        body = cur.fetchall()[0]
        body = re.sub(r'\"', '', str(body))
        body = '{"text":"%s"}' % body

    elif descr == 'y':
        # flash('description!')
        body = siteinput
        body = '{"text":"%s"}' % body

    terms = ImageApi(client).getImageForExpression("en_synonymous", body, 2,
                                                   "square", "base64/png",
                                                   '1.0')
    terms = terms.decode('base64')

    return send_file(io.BytesIO(terms), mimetype='image/png')
Exemple #2
0
 def setUp(self):
     self.api = ImageApi(testConfiguration.client)
print text[0].positions

####################################################
############# Code for keywords list ###############
####################################################

# Chose either en_synonymous or en_associative retina
terms = TextApi(client).getKeywordsForText("en_synonymous", body)
print terms

#####################################################
########## Code for fingerprint (image) #############
#####################################################

body = '{"text":"%s"}' % body

# Chose either en_synonymous or en_associative (default) retina, image scalar (default: 2), square or circle (default) image, encoding type, and sparsity
terms = ImageApi(client).getImageForExpression("en_synonymous", body, 2,
                                               "square", "base64/png", '1.0')

# Chose image name
image_name = file_name.replace(".txt", "")
fh = open(image_name + "_fpImage.png", "wb")
fh.write(terms.decode('base64'))
fh.close()
#print(image_name + ' fingerprint image saved to %s') % os.path.dirname(os.path.realpath(__file__))

#####################################################
################## End of Script ####################
#####################################################