-
Notifications
You must be signed in to change notification settings - Fork 1
/
app.py
45 lines (37 loc) · 1.25 KB
/
app.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
from random import random
from core import (
create_total_selection,
colors,
tokenize_sentences,
summarize
)
class App:
text = ''
selection = []
sentences = []
priorities = []
@staticmethod
def set_text(text: str):
App.text = text
@staticmethod
def reduce():
App.sentences = tokenize_sentences(App.text)
App.selection = create_total_selection(App.sentences, {"ratio": 0.6})
@staticmethod
def get_colors():
# We can use random!
App.priorities = colors.get_priorities(random())
@staticmethod
def colorize():
for i, sentence in enumerate(App.sentences):
weight = App.selection[i]
priority = App.priorities[weight]
print(f'{i} [{weight}] {priority}{sentence}{colors.end}')
print(App.selection, len(App.selection), sum(App.selection))
@staticmethod
def summarize(threshold: int):
summarized_sentences = summarize(App.sentences, App.selection, threshold)
for i, (sentence, weight) in enumerate(summarized_sentences):
priority = App.priorities[weight]
print(f'{i} [{weight}] {priority}{sentence}{colors.end}')
print(App.selection, len(App.selection), sum(App.selection))