コード例 #1
0
def encounter_s(mood, dirty):
    """Generate a few sentences about a meeting with another person."""
    # Sentence 1: The meeting
    familiar_people = wordlist.wordlist("familiar_people", dirty)
    strange_people = wordlist.wordlist("strange_people", dirty)
    locations = wordlist.wordlist("locations", dirty)

    person = common.choose_from(familiar_people, strange_people)
    location = common.choose_from(locations)
    preposition = location[0]
    location = location[1]
    s1 = "You may meet %s %s %s." % (person, preposition, location)

    # Sentence 2: The discussion
    discussions = wordlist.wordlist("neutral_discussions", dirty)
    discussions += wordlist.wordlist("_discussions", dirty, prefix=mood)
    feeling_nouns = wordlist.wordlist("_feeling_nouns", dirty, prefix=mood)
    emotive_nouns = wordlist.wordlist("_emotive_nouns", dirty, prefix=mood)
    conversation_topics = wordlist.wordlist("conversation_topics", dirty)

    discussion = common.choose_from(discussions)
    if random.random() <= 0.5:
        feeling = common.choose_from(feeling_nouns)
        feeling = "feelings of %s" % feeling
    else:
        feeling = common.choose_from(emotive_nouns)
    topic = common.choose_from(conversation_topics)

    s2 = "%s about %s may lead to %s." % (common.an(discussion), topic,
                                          feeling)
    s2 = common.sentence_case(s2)
    return "%s %s" % (s1, s2)
コード例 #2
0
def cosmic_implication_s(mood, dirty):
    """Generate a sentence about the influence of a cosmic event."""
    c_event = cosmic_event(dirty)
    prediction_verbs = wordlist.wordlist("prediction_verbs", dirty)
    verb = common.choose_from(prediction_verbs)

    # Bad mood =  End of good, or start of bad
    # Good mood = End of bad, or start of good
    r = random.random()
    beginnings = wordlist.wordlist("beginnings", dirty)
    endings = wordlist.wordlist("endings", dirty)
    if mood == 'bad' and r <= 0.5:
        junction = common.choose_from(beginnings)
        e_event = emotive_event('bad', dirty)
    elif mood == 'bad':
        junction = common.choose_from(endings)
        e_event = emotive_event('good', dirty)
    elif mood == 'good' and r <= 0.5:
        junction = common.choose_from(beginnings)
        e_event = emotive_event('good', dirty)
    else:
        junction = common.choose_from(endings)
        e_event = emotive_event('bad', dirty)

    s = "%s %s the %s of %s" % (c_event, verb, junction, common.an(e_event))
    return common.sentence_case(s)
コード例 #3
0
def warning_s(mood, dirty):
    r = random.random()
    avoid_list = wordlist.wordlist("avoid_list", dirty)
    bad_thing = random.choice(avoid_list)

    if r <= 0.27:
        s = "You would be well advised to avoid %s" % bad_thing
    elif r <= 0.54:
        s = "Avoid %s at all costs" % bad_thing
    elif r <= 0.81:
        s = "Steer clear of %s for a stress-free week" % bad_thing
    else:
        also_bad = common.choose_uniq({bad_thing}, avoid_list)
        s = "For a peaceful week, avoid %s and %s" % (bad_thing, also_bad)

    return common.sentence_case(s)
コード例 #4
0
def feeling_statement_s(mood, dirty):
    """Generate a sentence that asserts a mood-based feeling."""
    adjectives = wordlist.wordlist("_feeling_adjs", dirty, prefix=mood)
    degrees = wordlist.wordlist("neutral_degrees", dirty) + wordlist.wordlist(
        "_degrees", dirty, prefix=mood)

    i = random.randint(0, len(adjectives) - 1)
    adj = adjectives[i]

    adj = common.ing_to_ed(adj)
    degree = common.choose_from(degrees)

    ending = positive_intensifier if mood == "good" else consolation
    exciting = (mood == "good" and random.random() <= 0.5)
    are = random.choice([" are", "'re"])
    s = "You%s feeling %s %s" % (are, degree, adj)
    s += ending(dirty)
    return common.sentence_case(s, exciting)
コード例 #5
0
def date_prediction_s(mood, dirty):
    """Generate a random prediction sentence containing a date."""
    days_in_future = random.randint(2, 8)
    significant_day = date.today() + timedelta(days=days_in_future)
    month = significant_day.strftime("%B")
    day = significant_day.strftime("%d").lstrip('0')

    r = random.random()

    if r <= 0.5:
        s = "%s %s will be an important day for you" % (month, day)
    elif r <= 0.8:
        s = "Interesting things await you on %s %s" % (month, day)
    else:
        s = "The events of %s %s have the potential to change your life." % (
            month, day)

    return common.sentence_case(s)
コード例 #6
0
def relationship_s(mood, dirty):
    """Generate a sentence about a relationship."""
    if mood == "good":
        verb = "strengthened"
        talk = "discussion"
    else:
        verb = "strained"
        talk = "argument"

    # Wordlists
    familiar_people = wordlist.wordlist("familiar_people", dirty)
    conversation_topics = wordlist.wordlist("conversation_topics", dirty)

    person = common.choose_from(familiar_people)
    topic = common.choose_from(conversation_topics)
    s = "Your relationship with %s may be %s " % (person, verb)
    s += "as the result of %s about %s" % (common.an(talk), topic)

    return common.sentence_case(s)