Esempio n. 1
0
def respond(tweet_text, user, tweet_id, t=False):
    tweet = tweet_text.lower()
    tokens = parse_input.tokenize_input(tweet_text)
    question = parse_input.identify_question(tweet)
    # TODO use different rankings based on ppr and return yards
    ppr = parse_input.is_ppr(tweet)
    return_yards = parse_input.is_return_yards(tweet)

    rankings = determine_rankings(ppr)

    print("Tweet: \"%s\"" % tweet)

    if question == "who_start":
        picks = parse_input.identify_total_selections(tweet)

        print("PARSED INFO:")
        print("Question type: %s" % question)
        print("Number of players to return: %s" % picks)
        print("Is it ppr? %s" % ppr)
        print("Is it return yards? %s" % return_yards)

        confirmed_players = parse_input.verify_possible_players(tweet_text,
                                                                configs.nicknames,
                                                                rankings)
        print("\nPlayers confirmed: %s" % confirmed_players)
        players_with_info = parse_input.populate_player_info(confirmed_players,
                                                             rankings)
        selections, player_options = parse_input.return_selection(
            players_with_info, picks)
        if selections != []:
            print("\nSelection(s) are: %s" % selections)
            category = compose_reponse.determine_response_category(
                player_options)
            print("Category is: %s" % category)
            response, response_len = compose_reponse.compose_tweet(selections,
                                                                   category,
                                                                   user)
            print("Response is: %s" % response)

            submit_results(form_id=secrets.FORM_ID,
                           user=user,
                           raw_tweet=tweet_text,
                           tagged_tweet=tokens,
                           question=question,
                           confirmed_players=confirmed_players,
                           selections=selections,
                           category=category,
                           response=response,
                           response_len=response_len,
                           tweet_id=tweet_id)
            return response
        else:
            print("Could not identify any players")
            return None
    elif question == "unknown":
        print("question unknown")
Esempio n. 2
0
def test_identify_total_selections():
    assert parse_input.identify_total_selections(
        "@meanrotobot pick 2: Lacy, Peterson, Murray") == 2
    assert parse_input.identify_total_selections(
        "@meanrotobot pick two: Lacy, Peterson, Murray") == 2
    assert parse_input.identify_total_selections(
        "@meanrotobot pick 3: Lacy, Peterson, Murray") == 3
    assert parse_input.identify_total_selections(
        "@meanrotobot pick three: Lacy, Peterson, Murray") == 3
    assert parse_input.identify_total_selections(
        "@meanrotobot pick 4: Lacy, Peterson, Murray") == 4
    assert parse_input.identify_total_selections(
        "@meanrotobot pick four: Lacy, Peterson, Murray") == 4
    assert parse_input.identify_total_selections(
        "@meanrotobot pick 5: Lacy, Peterson, Murray") == 5
    assert parse_input.identify_total_selections(
        "@meanrotobot pick five: Lacy, Peterson, Murray") == 5
    assert parse_input.identify_total_selections(
        "@meanrotobot who should I start? Lacy, Peterson, Murray") == 1