Exemplo n.º 1
0
def update():
    languages = database.get_languages()
    for language in languages:
        print(f"Updating {language}")
        tweets = database.load_tweets(language=language)
        topics = load_topics(language)
        for tweet in tweets:
            tweet["topics"] = analyze(tweet["tokens"], topics)
        print(f"Finished updating {language}")
        update_topics(tweets)
Exemplo n.º 2
0
def test_load_tweets():
    tweets = database.load_tweets()
    assert len(tweets) > 1000
    assert type(tweets) == list
    assert type(tweets[0]) == dict
Exemplo n.º 3
0
def test_load_tweets_language():
    tweets = database.load_tweets(language="french")
    assert len(tweets) > 1000
    assert all([tweet["language"] == "french" for tweet in tweets])
Exemplo n.º 4
0
def test_load_tweets_language_publisher():
    tweets = database.load_tweets(language="french", publisher="le_figaro")
    assert len(tweets) > 1000
    assert all([tweet["language"] == "french" for tweet in tweets])
    assert all([tweet["publisher"] == "le_figaro" for tweet in tweets])
Exemplo n.º 5
0
def test_load_tweets_publisher():
    tweets = database.load_tweets(publisher="nytimes")
    assert len(tweets) > 1000
    assert all([tweet["publisher"] == "nytimes" for tweet in tweets])