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


Python maps.wait函数代码示例

本文整理汇总了Python中maps.wait函数的典型用法代码示例。如果您正苦于以下问题:Python wait函数的具体用法?Python wait怎么用?Python wait使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
	"""Draw the n states closest to center_state."""
	center = us_centers[center_state.upper()]
	dist_from_center = lambda name: geo_distance(center, us_centers[name])
	for name in sorted(us_states.keys(), key=dist_from_center)[:int(n)]:
		draw_state(us_states[name])
		draw_name(name, us_centers[name])
	draw_dot(center, 1, 10)  # Mark the center state with a red dot
	wait()
开发者ID:kevinchau321,项目名称:cs61a,代码行数:9,代码来源:trends.py

示例2: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
    """Draw the n states closest to center_state."""
    centers = {name: find_state_center(us_states[name]) for name in us_states}
    center = centers[center_state.upper()]
    distance = lambda name: geo_distance(center, centers[name])
    for name in sorted(centers, key=distance)[:int(n)]:
        draw_state(us_states[name])
        draw_name(name, centers[name])
    draw_dot(center, 1, 10)  # Mark the center state with a red dot
    wait()
开发者ID:chenkc805,项目名称:CS61AProjects,代码行数:10,代码来源:trends.py

示例3: draw_centered_map

def draw_centered_map(center_state='TX', n=10, canvas=None):
    """Draw the n states closest to center_state."""
    us_centers = {n: find_center(s) for n, s in us_states.items()}
    center = us_centers[center_state.upper()]
    dist_from_center = lambda name: geo_distance(center, us_centers[name])
    for name in sorted(us_states.keys(), key=dist_from_center)[:int(n)]:
        draw_state(us_states[name], canvas=canvas)
        draw_name(name, us_centers[name], canvas=canvas)
    draw_dot(center, 1, 10, canvas=canvas)  # Mark the center state with a red dot
    wait(canvas=canvas)
开发者ID:aviadlevy,项目名称:Intro2cs-huji-2014,代码行数:10,代码来源:trends.py

示例4: draw_map_by_hour

def draw_map_by_hour(term='my job', pause=0.5):
    """Draw the sentiment map for tweets that match term, for each hour."""
    tweets = load_tweets(make_tweet, term)
    tweets_by_hour = group_tweets_by_hour(tweets)

    for hour in range(24):
        current_tweets = tweets_by_hour.get(hour, [])
        tweets_by_state = group_tweets_by_state(current_tweets)
        state_sentiments = average_sentiments(tweets_by_state)
        draw_state_sentiments(state_sentiments)
        message("{0:02}:00-{0:02}:59".format(hour))
        wait(pause)
开发者ID:jesseyli,项目名称:OldProjects,代码行数:12,代码来源:trends.py

示例5: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
    """Draw the n states closest to center_state."""
    us_centers = make_database()
    for state, s in get_items(us_states):
        us_centers = add_value(us_centers, state, find_state_center(s))
    center = get_value_from_key(us_centers, center_state.upper()) 
    dist_from_center = lambda name: geo_distance(center, get_value_from_key(us_centers, name))
    for name in sorted(get_keys(us_centers), key=dist_from_center)[:int(n)]:
        draw_state(get_value_from_key(us_states, name))
        draw_name(name, get_value_from_key(us_centers, name))
    draw_dot(center, 1, 10)  # Mark the center state with a red dot
    wait()
开发者ID:wrahman1251,项目名称:Twitter-Trends,代码行数:12,代码来源:trends.py

示例6: draw_map_for_term

def draw_map_for_term(term='my job'):
    """Draw the sentiment map corresponding to the tweets that contain term.

    Some term suggestions:
    New York, Texas, sandwich, my life, justinbieber
    """
    tweets = load_tweets(make_tweet, term)
    tweets_by_state = group_tweets_by_state(tweets)
    state_sentiments = average_sentiments(tweets_by_state)
    draw_state_sentiments(state_sentiments)
    for tweet in tweets:
        draw_dot(tweet_location(tweet), analyze_tweet_sentiment(tweet))
    wait()
开发者ID:szmark001,项目名称:CS-188,代码行数:13,代码来源:trends.py

示例7: draw_map_for_query

def draw_map_for_query(term='my job', file_name='tweets2014.txt'):
    """Draw the sentiment map corresponding to the tweets that contain term.

    Some term suggestions:
    New York, Texas, sandwich, my life, justinbieber
    """
    tweets = load_tweets(make_tweet, term, file_name)
    tweets_by_state = group_tweets_by_state(tweets)
    state_sentiments = average_sentiments(tweets_by_state)
    draw_state_sentiments(state_sentiments)
    for tweet in tweets:
        s = analyze_tweet_sentiment(tweet)
        if has_sentiment(s):
            draw_dot(tweet_location(tweet), sentiment_value(s))
    wait()
开发者ID:chenkc805,项目名称:CS61AProjects,代码行数:15,代码来源:trends.py

示例8: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
    """Draw the n states closest to center_state.
    
    For example, to draw the 20 states closest to California (including California):

    # python3 trends.py CA 20
    """
    us_centers = {n: find_center(s) for n, s in us_states.items()}
    center = us_centers[center_state.upper()]
    dist_from_center = lambda name: geo_distance(center, us_centers[name])
    for name in sorted(us_states.keys(), key=dist_from_center)[:int(n)]:
        draw_state(us_states[name])
        draw_name(name, us_centers[name])
    draw_dot(center, 1, 10)  # Mark the center state with a red dot
    wait()
开发者ID:PMX10,项目名称:projects,代码行数:15,代码来源:trends.py

示例9: draw_map_by_hour

def draw_map_by_hour(find_state, term='my job', pause=0.5, canvas=None, imglist=None):
    """Draw the sentiment map for tweets that match term, for each hour."""

    word_sentiments = load_sentiments()
    tweets = load_tweets(term)
    tweets_by_hour = group_tweets_by_hour(tweets)
    
    for hour in range(24):
        current_tweets = tweets_by_hour[hour]
        tweets_by_state = group_tweets_by_state(current_tweets, find_state)
        state_sentiments = average_sentiments(tweets_by_state,word_sentiments)
        draw_state_sentiments(state_sentiments, canvas=canvas)
        message("{0:02}:00-{0:02}:59".format(hour), canvas=canvas)
        wait(pause, canvas=canvas)
        if imglist is not None:
            imglist.append(get_img_copy(canvas))
开发者ID:aviadlevy,项目名称:Intro2cs-huji-2014,代码行数:16,代码来源:trends.py

示例10: draw_map_for_term

def draw_map_for_term(find_state, term='my job', canvas=None):
    """Draw the sentiment map corresponding to the tweets that contain term.

    Some term suggestions:
    New York, Texas, sandwich, my life, justinbieber
    """

    word_sentiments = load_sentiments()
    tweets = load_tweets(term)
    tweets_by_state = group_tweets_by_state(tweets, find_state)
    state_sentiments = average_sentiments(tweets_by_state,word_sentiments)
    draw_state_sentiments(state_sentiments, canvas=canvas)
    for tweet in tweets:
        s = tweet.get_sentiment(word_sentiments)
        if s != None:
            draw_dot(tweet.get_location(), s, canvas=canvas)
    wait(canvas=canvas)
开发者ID:aviadlevy,项目名称:Intro2cs-huji-2014,代码行数:17,代码来源:trends.py

示例11: run

def run(*args):
    """Read command-line arguments and calls corresponding functions."""
    import argparse
    parser = argparse.ArgumentParser(description="Run Trends")
    parser.add_argument('--print_sentiment', '-p', action='store_true')
    parser.add_argument('--run_doctests', '-t', action='store_true')
    parser.add_argument('--draw_centered_map', '-d', action='store_true')
    parser.add_argument('--draw_state_sentiments', '-s', action='store_true')
    parser.add_argument('--draw_map_for_term', '-m', action='store_true')
    parser.add_argument('--draw_map_by_hour', '-b', action='store_true')
    parser.add_argument('--containing_state', '-c', action='store_true')
    parser.add_argument('--file', '-f', type=str, default=None)
    parser.add_argument('text', metavar='T', type=str, nargs='*',
                        help='Text to process')
    args = parser.parse_args()

    if (args.__dict__['containing_state']):
            find_state = find_containing_state(us_states)
    else:
        us_centers = {n: find_center(s) for n, s in us_states.items()}
        find_state = find_closest_state(us_centers)
    
    if args.__dict__['file']:
        canvas = MapImage(960,500)
    else:
        canvas = None
    for name, execute in args.__dict__.items():
        if name != 'text' and name != 'containing_state' and name != 'file' and execute:
            if name == 'draw_map_for_term':
                draw_map_for_term(find_state, ' '.join(args.text), canvas=canvas)
                if canvas: canvas._img.save(args.file+'.png', "PNG")
            elif name == 'draw_map_by_hour':
                imglist = [] if canvas else None
                draw_map_by_hour(find_state, ' '.join(args.text), canvas=canvas, imglist=imglist)
                if canvas:
                    for i in range(24):
                        imglist[i].save(args.file+'_'+str(i).zfill(2)+'.png', "PNG")
            elif name == 'draw_centered_map':
                draw_centered_map(' '.join(args.text), canvas=canvas)
                if canvas: canvas._img.save(args.file+'.png', "PNG")
            elif name == 'draw_state_sentiments': 
                draw_state_sentiments(average_sentiments(group_tweets_by_state(load_tweets(' '.join(args.text)), find_state),load_sentiments()), canvas=canvas) 
                wait(canvas=canvas)
                if canvas: canvas._img.save(args.file+'.png', "PNG")
            else:
                globals()[name](' '.join(args.text))
开发者ID:aviadlevy,项目名称:Intro2cs-huji-2014,代码行数:46,代码来源:trends.py

示例12: draw_centered_map

def draw_centered_map(center_state='TX', n=10):
    """Draw the n states closest to center_state.
    
    For example, to draw the 20 states closest to California (including California),
    enter in the terminal: 

    # python3 trends.py CA 20
    """
    us_centers = make_idict()
    for i, s in idict_items(us_states):
        us_centers = idict_insert(us_centers, i, find_center(s))
    center = idict_select(us_centers, center_state.upper())
    dist_from_center = lambda name: geo_distance(center, idict_select(us_centers, name)) 
    for name in sorted(idict_keys(us_states), key=dist_from_center)[:int(n)]:
        draw_state(idict_select(us_states, name))
        draw_name(name, idict_select(us_centers, name))
    draw_dot(center, 1, 10)  # Mark the center state with a red dot
    wait()
开发者ID:anjishnu,项目名称:GeoProject,代码行数:18,代码来源:trends.py

示例13: draw_map_for_term

def draw_map_for_term(term='my job'):
    """Draw the sentiment map corresponding to the tweets that contain term.

    Some term suggestions:
    New York, Texas, sandwich, my life, justinbieber
    """
    tweets = load_tweets(make_tweet, term)
    tweets_by_state = group_tweets_by_state(tweets)
    state_sentiments = average_sentiments(tweets_by_state)
    draw_state_sentiments(state_sentiments)
    for tweet in tweets:
        s = analyze_tweet_sentiment(tweet)
        if has_sentiment(s):
            draw_dot(tweet_location(tweet), sentiment_value(s))
    if len(tweets) != 0:
        draw_top_states(most_talkative_states(term))
    else:
        draw_top_states(None)

    wait()
开发者ID:jesseyli,项目名称:OldProjects,代码行数:20,代码来源:trends.py

示例14: draw_map_for_term

def draw_map_for_term(term='Berkeley'):
    """
    Draw the sentiment map corresponding to the tweets that match term.
    
    term -- a word or phrase to filter the tweets by.  
    
    To visualize tweets containing the word "obama":
    
    # python3 trends.py obama
    
    Some term suggestions:
    New York, Texas, sandwich, my life, justinbieber
    """
    tweets = load_tweets(make_tweet, term)
    tweets_by_state = group_tweets_by_state(tweets)
    state_sentiments = calculate_average_sentiments(tweets_by_state)
    draw_state_sentiments(state_sentiments)
    for tweet in tweets:
        draw_dot(tweet_location(tweet), analyze_tweet_sentiment(tweet))
    wait()
开发者ID:PMX10,项目名称:projects,代码行数:20,代码来源:trends.py


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