当前位置: 首页>>代码示例>>Python>>正文


Python AlchemyAPI.imageTagging方法代码示例

本文整理汇总了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'])
开发者ID:zhewang,项目名称:salesprediction,代码行数:15,代码来源:pipeline.py

示例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
开发者ID:Taiiwo,项目名称:IRCLinkBot,代码行数:53,代码来源:link.py

示例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')
开发者ID:hjorthjort,项目名称:Presens,代码行数:32,代码来源:tests.py

示例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



开发者ID:habdulkafi,项目名称:TwittMapHP,代码行数:27,代码来源:firsttest.py

示例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('')
开发者ID:metador,项目名称:alchemy,代码行数:33,代码来源:trying_api.py

示例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("")
开发者ID:jaybird23,项目名称:market_sentimentalism2,代码行数:33,代码来源:example.py


注:本文中的alchemyapi.AlchemyAPI.imageTagging方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。