コード例 #1
0
ファイル: region.py プロジェクト: juicyJ/citybeat_online
def checkTweetInRegion():
    region = {}
    region['min_lat'] = InstagramConfig.photo_min_lat
    region['max_lat'] = InstagramConfig.photo_max_lat
    region['min_lng'] = InstagramConfig.photo_min_lng
    region['max_lng'] = InstagramConfig.photo_max_lng

    r = Region(region)

    ti = TweetInterface()
    ti.setDB('citybeat_production')
    ti.setCollection('tweets')
    cur = ti.getAllDocuments()
    tot = 0
    tweet_in_region = 0
    for tweet in cur:
        cor = [0, 0]
        cor[0] = tweet['location']['latitude']
        cor[1] = tweet['location']['longitude']
        tot += 1
        if r.insideRegion(cor):
            tweet_in_region += 1

    print tweet_in_region
    print tot
コード例 #2
0
ファイル: test4.py プロジェクト: juicyJ/citybeat_online
def main():
    ti = TweetInterface()
    ti.setDB('citybeat_production')
    ti.setCollection('tweets')
    tc = ti.getAllDocuments({'created_time' : {'$gte' : '1378711668'}})
    print tc.count()
    cnt = 0
    for tweet in tc:
        tweet = Tweet(tweet)
        text = tweet.getText().lower()
        if 'quinn' in text:
            print text
            cnt += 1
    print cnt
コード例 #3
0
def testWithTweet():
    from corpus import buildAllCorpus

    corpus_all = buildAllCorpus(element_type="tweets", debug=True)
    for key, corpus in corpus_all.items():
        break

    ei = EventInterface()
    ei.setDB("citybeat")
    ei.setCollection("candidate_event_25by25_merged")
    event = ei.getDocument()
    print event
    ti = TweetInterface()
    cur = ti.getAllDocuments(limit=30)
    tweets = []
    for tweet in cur:
        tweets.append(tweet)
    del event["photos"]
    event["tweets"] = tweets
    event = BaseFeature(event, corpus=corpus)
    print event.printFeatures()