dream

Форк
0
/
funfact.py 
77 строк · 3.5 Кб
1
import re
2

3
FUNFACT_COMPILED_PATTERN = re.compile(
4
    r"(funfact|fun fact|tell me something fun|tell something interesting|"
5
    "tell me something interesting|^interesting fact.*)",
6
    re.IGNORECASE,
7
)
8

9
STORY_COMPILED_PATTERN = re.compile(r"(tell a story|tell me a story|interesting story|funny story)\.?$")
10

11

12
def story_requested(annotated_user_utt):
13
    return bool(STORY_COMPILED_PATTERN.search(annotated_user_utt["text"]))
14

15

16
def funfact_requested(annotated_user_utt, annotated_bot_utt):
17
    story_request = story_requested(annotated_user_utt)
18
    turn_on_funfact = FUNFACT_COMPILED_PATTERN.search(annotated_user_utt["text"])
19
    previous_was_funfact = annotated_bot_utt.get("active_skill", "") == "dff_funfact_skill"
20
    agree_next = "other" in annotated_user_utt["text"] or "fact" in annotated_user_utt["text"]
21
    flag = turn_on_funfact or (previous_was_funfact and agree_next) or story_request
22
    return bool(flag)
23

24

25
FUNFACT_LIST = [
26
    ("Pineapple works as a natural meat tenderizer.", "food"),
27
    ("Only two mammals like spicy food: humans and the tree shrew.", "food"),
28
    ("The M in M&Ms stand for Mars and Murrie.", "food"),
29
    ("Pringles are not actually potato chips.", "food"),
30
    ("Cotton candy was invented by a dentist.", "food"),
31
    ("Water makes different pouring sounds depending on its temperature.", "food"),
32
    ("Some sea snakes can breathe through their skin.", "animals"),
33
    ('The budget for the Movie "Titanic" was higher than the budget of Titanic itself.', "movies"),
34
    ("The original London Bridge is now in Arizona.", "travelling"),
35
    ("The healthiest place in the world is in Panama.", "travelling"),
36
    ("Pigeons can tell the difference between a painting by Monet and Picasso.", "travelling"),
37
    ("Dinosaurs lived on every continent.", "travelling"),
38
    ("Napoleon was once attacked by thousands of rabbits.", "travelling"),
39
    (
40
        "For 100 years, maps have shown an island that does not exist. Sandy Island about size of Manhattan"
41
        " in the Pacific Ocean was discovered in 1774, but in 2012 it turned out to not exist",
42
        "travelling",
43
    ),
44
    ("A 2007 study found that music, classical in particular, can help make plants grow faster.", "music"),
45
    (
46
        "The world’s largest book made of paper is located in Dubai, United Arab Emirates. "
47
        "It is five meters wide, 8.06 meters long, contains 429 pages and weighs over 3,000 pounds.",
48
        "books",
49
    ),
50
    (
51
        "Australian rower Bobby Pearce won the 1928 Olympic Games against eight other competitors, "
52
        "even though he stopped during the race to let ducks pass in front of him.",
53
        "sport",
54
    ),
55
    ("The sunniest place on earth is Arizona.", "weather"),
56
    ("The hottest spot on the planet is in Libya.", "weather"),
57
    (
58
        "The oldest continuously published daily newspaper in the United States is the New York Post, "
59
        "which was founded in 1801 by Alexander Hamilton.",
60
        "news",
61
    ),
62
    ("Marie Curie is the only person to earn a Nobel prize in two different sciences.", "science"),
63
    ("Showers really do spark creativity.", "science"),
64
    ("Dogs actually understand some English.", "science"),
65
    (
66
        "South Korea has a rule called ‘Cinderella law’ which disallows under-16 gamers "
67
        "to play online video games after midnight.",
68
        "games",
69
    ),
70
]
71

72

73
def make_question(topic=""):
74
    if topic:
75
        return f"Would you like to talk about {topic}? Or would you like to hear another fun fact?"
76
    else:
77
        return "Would you like to hear another fun fact?"
78

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.