Exemplo n.º 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')
Exemplo n.º 2
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')
Exemplo n.º 3
0
class TestClientImageApi(unittest.TestCase):
    
    def setUp(self):
        self.api = ImageApi(testConfiguration.client)


    def testImage(self):
        imageData = self.api.getImageForExpression(testConfiguration.RETINA_NAME, inputJSON)
        self.assertNotEqual(imageData, None)

    def testCompare(self):
        imageData = self.api.getOverlayImage(testConfiguration.RETINA_NAME, inputJSONarray)
        self.assertNotEqual(imageData, None)

    def testBulk(self):
        images = self.api.getImageForBulkExpressions(testConfiguration.RETINA_NAME, inputJSONarray3, get_fingerprint=True)
        self.assertEqual(len(images), 3)
        for image in images:
            self.assertNotEqual(image, None)
            self.assertNotEqual(image.image_data, None)
            self.assertNotEqual(len(image.fingerprint.positions), 0)
Exemplo n.º 4
0
 def setUp(self):
     self.api = ImageApi(testConfiguration.client)
Exemplo n.º 5
0
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 ####################
#####################################################