本文整理汇总了Python中alchemyapi.AlchemyAPI.imageTagging方法的典型用法代码示例。如果您正苦于以下问题:Python AlchemyAPI.imageTagging方法的具体用法?Python AlchemyAPI.imageTagging怎么用?Python AlchemyAPI.imageTagging使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类alchemyapi.AlchemyAPI
的用法示例。
在下文中一共展示了AlchemyAPI.imageTagging方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: ExtractImageTag
# 需要导入模块: from alchemyapi import AlchemyAPI [as 别名]
# 或者: from alchemyapi.AlchemyAPI import imageTagging [as 别名]
def ExtractImageTag(image_url):
alchemyapi = AlchemyAPI()
response = alchemyapi.imageTagging('url', image_url)
results = []
if response['status'] == 'OK':
for keyword in response['imageKeywords']:
results.append(keyword['text'])
# print(keyword['text'], ' : ', keyword['score'])
print('')
else:
print('Error in image tagging call: ', response['statusInfo'])
示例2: main
# 需要导入模块: from alchemyapi import AlchemyAPI [as 别名]
# 或者: from alchemyapi.AlchemyAPI import imageTagging [as 别名]
def main(data):
args = argv('@',data['recv'])
# look for URL
link = geturl(data['recv'])
if link and link != "" and not modeCheck('b', data):
link = link[0]
# look for title
badext = ('.cgi','.pdf')
imgext = ('.jpg','.png','.gif','.bmp')
if not link[-4:].lower() in badext:
if not link[-4:].lower() in imgext:
title = gettitle(link)
if title:
title = html_decode(title)
# encode unicode object to byte string
if type(title) == unicode:
title = title.encode('utf-8', "ignore")
title = title.replace('\n',' ')
title = title.replace('\r',' ')
title = title.strip()
if len(title) >= 150:
title = title[:150]
if len(link) > int(data['config']['settings']['maxLinkLen']):
# post title + tiny
data['api'].say(args['channel'], '^ ' + title + ' ' + maketiny(link) + ' ^')
return
else:
# post title only
data['api'].say(args['channel'], '^ ' + title + ' ^')
return
else:
# We've got an image URL.
from alchemyapi import AlchemyAPI
alchemyapi = AlchemyAPI()
response = alchemyapi.imageTagging('url', link)
if response['status'] == 'OK' and response['imageKeywords'][0]['text'] != 'NO_TAGS':
retme = "^ Image of: "
for keyword in response['imageKeywords']:
retme += "%s(%s%%) " % (keyword['text'], int(float(keyword['score']) * 100))
if len(link) > int(data['config']['settings']['maxLinkLen']):
retme += maketiny(link) + " "
retme += "^"
data['api'].say(args['channel'], retme)
return
if len(link) > int(data['config']['settings']['maxLinkLen']):
# post tiny only
data['api'].say(args['channel'], '^ ' + maketiny(link) + ' ^')
return
else:
# nothing
return False
示例3: print
# 需要导入模块: from alchemyapi import AlchemyAPI [as 别名]
# 或者: from alchemyapi.AlchemyAPI import imageTagging [as 别名]
# Microformats
print('Checking microformats . . . ')
response = alchemyapi.microformats('text', test_text)
assert(response['status'] == 'ERROR') # only works for html and url content
response = alchemyapi.microformats('html', test_html, {'url': 'test'})
assert(response['status'] == 'OK')
response = alchemyapi.microformats('url', test_url)
assert(response['status'] == 'OK')
print('Microformat tests complete!')
print('')
print('')
# imagetagging
print('Checking imagetagging . . . ')
response = alchemyapi.imageTagging('text', test_text)
assert(response['status'] == 'ERROR')
response = alchemyapi.imageTagging('html', test_html)
assert(response['status'] == 'ERROR')
response = alchemyapi.imageTagging('url', test_url)
assert(response['status'] == 'OK')
response = alchemyapi.imageTagging('image', test_jpg)
assert(response['status'] == 'OK')
print('Image tagging tests complete!')
print('')
print('')
# combined
print('Checking combined . . . ')
response = alchemyapi.combined('text', test_text)
assert(response['status'] == 'OK')
示例4: AlchemyAPI
# 需要导入模块: from alchemyapi import AlchemyAPI [as 别名]
# 或者: from alchemyapi.AlchemyAPI import imageTagging [as 别名]
#!/usr/bin/env python
# from __future__ import print_function
from alchemyapi import AlchemyAPI
import json
alchemyapi = AlchemyAPI()
two_people = "C:/Users/husam/Downloads/11430249_10206846582226070_4444383423738402524_n.jpg"
samljack = "C:/Users/husam/Downloads/aKq4MXO_700b_v1.jpg"
# Returns a bounding box for the faces in the picture
# response = alchemyapi.faceTagging('image', two_people)
# response = alchemyapi.faceTagging('image', samljack)
# response = alchemyapi.imageTagging('image', two_people)
response = alchemyapi.imageTagging('image', samljack)
print response
示例5: print
# 需要导入模块: from alchemyapi import AlchemyAPI [as 别名]
# 或者: from alchemyapi.AlchemyAPI import imageTagging [as 别名]
print('')
print('')
print('')
print('')
print('############################################')
print('# Image tagging Example #')
print('############################################')
print('')
print('')
print('Processing url: ', image_url)
print('')
response = alchemyapi.imageTagging('url', image_url)
if response['status'] == 'OK':
print('## Response Object ##')
print(json.dumps(response, indent=4))
print('')
print('## Keywords ##')
for keyword in response['imageKeywords']:
print(keyword['text'], ' : ', keyword['score'])
print('')
else:
print('Error in image tagging call: ', response['statusInfo'])
print('')
print('')
示例6: print
# 需要导入模块: from alchemyapi import AlchemyAPI [as 别名]
# 或者: from alchemyapi.AlchemyAPI import imageTagging [as 别名]
print("")
print("")
print("")
print("")
print("############################################")
print("# Image tagging Example #")
print("############################################")
print("")
print("")
print("Processing url: ", image_url)
print("")
response = alchemyapi.imageTagging("url", image_url)
if response["status"] == "OK":
print("## Response Object ##")
print(json.dumps(response, indent=4))
print("")
print("## Keywords ##")
for keyword in response["imageKeywords"]:
print(keyword["text"], " : ", keyword["score"])
print("")
else:
print("Error in image tagging call: ", response["statusInfo"])
print("")
print("")