数据挖掘与认知计算:Twitter 与 IBM Watson 探索
1. Twitter 数据挖掘
1.1 地理编码与映射
在地理编码过程中,若出现超时情况,代码的第 16 - 18 行将显示超时消息,等待 delay 秒,并增加 delay 值以应对可能的再次超时。其中,第 17 行调用 Python 标准库 time 模块的 sleep 方法暂停代码执行。
当 while 循环结束后,第 20 - 24 行检查是否返回了位置数据。若返回,则将其添加到推文的字典中;否则,第 24 行将 bad_locations 计数器加 1。最后,函数会打印完成地理编码的消息并返回 bad_locations 的值。
1.2 LocationListener 类
以下是 LocationListener 类的代码:
# locationlistener.py
"""Receives tweets matching a search string and stores a list of
dictionaries containing each tweet's screen_name/text/location."""
import tweepy
from tweetutilities import get_tweet_conte
超级会员免费看
订阅专栏 解锁全文
1208

被折叠的 条评论
为什么被折叠?



