-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.py
46 lines (32 loc) · 1.29 KB
/
main.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
from fire import Fire
from src.gen_question import gen_question
from src.gen_answers import gen_answers
from src.rank_poll import rank_poll
def generate_question(topic: str):
'''Generates and returns a question that might be in a poll about a given topic'''
return gen_question(topic)
def generate_answers(question: str):
'''Generates and returns a list of answers provided a question'''
return gen_answers(question)
def generate_poll(topic: str):
'''Generates a poll based on a topic'''
question = generate_question(topic)
answers = generate_answers(question)
return {
'question': question,
'answers': answers
}
def generate_and_rank_poll(topic: str, target_audience: str):
'''generates a poll based on a topic and ranks how good it is in accordance with how_to_make_good_polls.md'''
poll = generate_poll(topic)
print('Question:', poll['question'])
print('Answers:', poll['answers'])
print('Ranking poll....')
final_rank = rank_poll(poll['question'], target_audience, poll['answers'])
print('Final rank:', final_rank)
# this is the main function that will be called by other code later
def task(topic: str):
'''Generates a poll based on a topic'''
return generate_poll(topic)
if __name__ == "__main__":
Fire()