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


Python Algorithmia.client方法代码示例

本文整理汇总了Python中Algorithmia.client方法的典型用法代码示例。如果您正苦于以下问题:Python Algorithmia.client方法的具体用法?Python Algorithmia.client怎么用?Python Algorithmia.client使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Algorithmia的用法示例。


在下文中一共展示了Algorithmia.client方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: abstractToKeyword

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
def abstractToKeyword(title):
	process = subprocess.Popen('python scholar.py -c %(count)d -A %(text)s --csv' \
			% {"count": 1, "text": title}, shell=True, stdout=subprocess.PIPE)
	output=process.communicate()[0]
	elements = output.rsplit('|')
	lastIndex = len(elements) - 1
	LDAinput = [[elements[0], elements[lastIndex]],1]
	client = Algorithmia.client('simfAKlzXJA516uRJm37b8tT9b31')
	algo = client.algo('kenny/LDA/0.1.3')
	results = algo.pipe(LDAinput)
	return list(results[0].keys())
开发者ID:bryantwong,项目名称:dubhacks,代码行数:13,代码来源:abstractToKeyword.py

示例2: test_create_acl

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
    def test_create_acl(self):
        c = Algorithmia.client(os.environ['ALGORITHMIA_API_KEY'])
        dd = DataDirectory(c, 'data://.my/privatePermissions')
        if dd.exists():
            dd.delete(True)
        dd.create(ReadAcl.private)

        dd_perms = DataDirectory(c, 'data://.my/privatePermissions').get_permissions()
        self.assertEquals(dd_perms.read_acl, AclType.private)

        dd.update_permissions(ReadAcl.public)
        dd_perms = DataDirectory(c, 'data://.my/privatePermissions').get_permissions()
        self.assertEquals(dd_perms.read_acl, AclType.public)
开发者ID:algorithmiaio,项目名称:algorithmia-python,代码行数:15,代码来源:acl_test.py

示例3: generate_sentence

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
def generate_sentence(filepath):
	'''
    Generates a sentence given a trained trigram model
    PARAMETERS:
    	<str> filepath: location that trained model is located
    					 in Algorithmia API
    RETURNS:
    	<str> output: a randomly generated sentence
	'''
	client = Algorithmia.client(api_key.key)
	input = [filepath, "xxBeGiN142xx", "xxEnD142xx"]
	algo = client.algo('ngram/RandomTextFromTrigram/0.1.1')
	print algo.pipe(input)
开发者ID:lizrush,项目名称:shorties,代码行数:15,代码来源:generate_sentences.py

示例4: random

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
def random():
        try:
                query = wikipedia.random(pages=1)
                input = wikipedia.WikipediaPage(title=query).summary
                title = wikipedia.WikipediaPage(title=query).title
                image = wikipedia.WikipediaPage(title=query).images[0]
                client = Algorithmia.client('Simple simR+{}'.format(api_key))
                algo = client.algo('nlp/Summarizer/0.1.2')
                contents ={
                        'image': image,
                        'title': title,
                        'summary': algo.pipe(input),
                        'link': 'https://en.wikipedia.org/wiki/{}'.format(wikipedia.random(pages=1))
                }
        except:
                return json.dumps({
                        'msg': "Sorry, we couldn't find a Wikipedia article matching your search."
                        })
        return json.dumps(contents)
开发者ID:cherylafitz,项目名称:react_flask,代码行数:21,代码来源:app.py

示例5: summarise_img

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
def summarise_img(src, options=False):
    '''
    Retrieve meta-data for an image web resource.
    Use algorithmia, openshift or similar cloud service. 
    '''
    import Algorithmia
    client = Algorithmia.client(config.ALGORITHMIA['api_key'])
    algo = client.algo('deeplearning/IllustrationTagger/0.2.3')

    input = {"image":src}
    if options:
        # tags (optional) required probs
        for opt, value in options.items():
            input[opt] = value

        # e.g. threshold  0.3 etc
        
    result = algo.pipe(input)

    return result
开发者ID:battez,项目名称:analysis,代码行数:22,代码来源:summarise.py

示例6: pull_tweets

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
def pull_tweets():
    """Pull tweets from Twitter API via Algorithmia."""
    input = {
        "query": q_input,
        "numTweets": "700",
        "auth": {
            "app_key": 'your_consumer_key',
            "app_secret": 'your_consumer_secret_key',
            "oauth_token": 'your_access_token',
            "oauth_token_secret": 'your_access_token_secret'
        }
    }
    client = Algorithmia.client('your_algorithmia_api_key')
    algo = client.algo('twitter/RetrieveTweetsWithKeyword/0.1.3')

    tweet_list = [{'user_id': record['user']['id'],
                   'retweet_count': record['retweet_count'],
                   'text': record['text']}
                  for record in algo.pipe(input).result]
    return tweet_list
开发者ID:algorithmiaio,项目名称:sample-apps,代码行数:22,代码来源:twitter_pull_data.py

示例7: main

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
def main(filepath, outpath, length):
	story = ''
	client = Algorithmia.client(api_key.key)
	alg_path = "data://.algo/ngram/GenerateTrigramFrequencies/temp/trigrams.txt"
	generate_trigrams(filepath, alg_path)
	while len(re.findall(r'\w+', story)) < length:
		print "Generating new paragraph..."
		input = ["data://.algo/ngram/GenerateTrigramFrequencies/temp/trigrams.txt", "xxBeGiN142xx", "xxEnD142xx", (randint(1,9))]
		new_par = client.algo('/lizmrush/GenerateParagraphFromTrigram/0.1.2').pipe(input)
		if len(re.findall(r'\w+', story)) + len(re.findall(r'\w+', new_par)) > length:
			break
		story += new_par.strip()
		story += '\n\n'
		print "Word count:"
		print len(re.findall(r'\w+', story))

	with open(outpath, 'w') as f:
		f.write(story.encode('utf8'))

	f.close()

	print "Complete! Story written to " + outpath
开发者ID:lizrush,项目名称:shorties,代码行数:24,代码来源:generate_sentences.py

示例8: generate_trigrams

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
def generate_trigrams(corpus, filepath):
	'''
	Generates a trained trigram model
	PARAMETERS:
		str[] corpus: array of strings generated from splitting
		              the original corpus. Needs beginning and
		              end tags in data
		<str> filepath: location that data is stored in Algorithmia
		                data API
	RETURNS:
        filepath: location that data is stored in Algorithmia data API
                  (as confirmation)
	'''
	with open(corpus, 'r') as myfile:
		data = myfile.read().replace('\n', '')
	data = data.replace("xxEnD142xx", "xxEnD142xx qq")
	data = data.split(" qq ")
	input = [data, "xxBeGiN142xx", "xxEnD142xx", filepath]
	client = Algorithmia.client(api_key.key)
	algo = client.algo('ngram/GenerateTrigramFrequencies/0.1.1')
	print "Trigram Frequency txt in data api, filepath is:"
	print algo.pipe(input)
开发者ID:lizrush,项目名称:shorties,代码行数:24,代码来源:generate_sentences.py

示例9: main

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
def main():
    parser = argparse.ArgumentParser()
    parser.add_argument('--api-key', required=True, help='algorithmia api key')
    parser.add_argument('--connector-path', required=True, help='s3 or dropbox path for the directory to scan')
    parser.add_argument('--recursive', action='store_true', help='continue scanning all sub-directories of the connector path')
    args = parser.parse_args()

    # Initialize Algorithmia Python client
    client = Algorithmia.client(args.api_key)

    # Get the algorithm we plan to use on each picture
    algo = client.algo('deeplearning/ColorfulImageColorization/1.0.1')
    algo.set_options(timeout=600) # This is a slow algorithm, so let's bump up the timeout to 10 minutes

    # The root level directory that we will traverse
    top_level_dir = client.dir(args.connector_path)

    # Colorize the files
    if args.recursive:
        recursivelyColorize(algo, args.connector_path, top_level_dir)
    else:
        colorizeFilesInDirectory(algo, args.connector_path, top_level_dir)

    print 'Done processing!'
开发者ID:algorithmiaio,项目名称:sample-apps,代码行数:26,代码来源:colorize.py

示例10:

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
import Algorithmia

input = "https://pbs.twimg.com/profile_images/714630467409018884/2ywNrMx2.jpg"
client = Algorithmia.client('simmp0NmxBIAkbVwazmgI8QQvMg1')
algo = client.algo('sfw/NudityDetection/1.1.4')
print algo.pipe(input)
开发者ID:kirai,项目名称:tensorflowplay,代码行数:8,代码来源:detectnudity.py

示例11: send_simple_message

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
import Algorithmia
import requests

# Algorithmia API key here
client = Algorithmia.client("ALGORITHMIA_API_KEY")

example_input = {
  "url": "http://algorithmia.com/",
  "depth": 3
}

res = client.algo("web/ErrorScanner").set_options(timeout=2000).pipe(example_input)

broken_links = res.result["brokenLinks"]

email_str = ""

# Iterate through our list of broken links
# to create a string we can add to the body of our email
for linkPair in broken_links:
    email_str += "broken link: " + linkPair["brokenLink"] + " (referring page: " + linkPair["refPage"] + ")" + "\n\n"

# Print the result from the API call
print email_str

# Send the email
def send_simple_message():
	return requests.post(
		# Mailgun Documentation: https://documentation.mailgun.com/quickstart-sending.html#send-via-api
		"https://api.mailgun.net/v3/YOUR_DOMAIN_NAME/messages",
		auth=("api", "YOUR_API_KEY"),
开发者ID:algorithmiaio,项目名称:sample-apps,代码行数:33,代码来源:404.py

示例12: pull_tweets

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
import re
from collections import defaultdict, Counter

import Algorithmia
client = Algorithmia.client("your_algorithmia_api_key")

def pull_tweets():
    input = {
        "query": "Thanksgiving",
        "numTweets": "700",
        "auth": {
            "app_key": 'your_consumer_key',
            "app_secret": 'your_consumer_secret_key',
            "oauth_token": 'your_access_token',
            "oauth_token_secret": 'your_access_token_secret'
        }
    }
    
    twitter_algo = client.algo("twitter/RetrieveTweetsWithKeyword/0.1.3")
    result = twitter_algo.pipe(input).result
    tweet_list = [tweets['text'] for tweets in result]
    return tweet_list


def process_text():
    """Remove emoticons, numbers etc. and returns list of cleaned tweets."""
    data = pull_tweets()
    regex_remove = "(@[A-Za-z0-9]+)|([^0-9A-Za-z \t])|(\w+:\/\/\S+)|^RT|http.+?"
    stripped_text = [
        re.sub(regex_remove, '',
               tweets).strip() for tweets in data
开发者ID:algorithmiaio,项目名称:sample-apps,代码行数:33,代码来源:twitter_named_entity_recognition.py

示例13: print

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
#Get the user name first

x =raw_input('Enter your name:')
print('Hello ' + x)
y =raw_input('How are you doing today,' +x)

import Algorithmia

input = y
client = Algorithmia.client('simsmuMGjwhXqpi7hcakzab+RoG1')
algo = client.algo('nlp/SentimentAnalysis/0.1.2')
print algo.pipe(input)

开发者ID:spurtipreetham,项目名称:Python,代码行数:14,代码来源:hellomaster.py

示例14: search

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
 def search(self, tweet_content, algo_path):
     client = Algorithmia.client(settings.ALGORITHMIA_API_KEY)
     algo = client.algo(algo_path)
     return (algo.pipe(tweet_content))
开发者ID:chrishintz,项目名称:city-scape-app,代码行数:6,代码来源:algorithm.py

示例15: somefunction

# 需要导入模块: import Algorithmia [as 别名]
# 或者: from Algorithmia import client [as 别名]
def somefunction(input):
    client = Algorithmia.client('simL4K0sq9xovn9rSUqxzGy19R/1')
    algo = client.algo('mtman/SentimentAnalysis/0.1.1')
    ans = algo.pipe(input).result
    return ans
开发者ID:ak795,项目名称:Academic-Project,代码行数:7,代码来源:wordpolarity.py


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