Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -31,10 +31,11 @@ def summarize_text(text):
|
|
31 |
resp = summarizer(text)
|
32 |
return resp[0]['summary_text']
|
33 |
|
34 |
-
def text_to_sentiment(text, all_score=False):
|
35 |
-
|
36 |
-
|
37 |
-
|
|
|
38 |
def fin_ext(text):
|
39 |
results = fin_model(split_in_sentences(text))
|
40 |
return make_spans(text, results)
|
@@ -80,7 +81,7 @@ def process_paragraph_1_sent(paragraph):
|
|
80 |
try:
|
81 |
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
82 |
selected_paragraph = stored_paragraphs_1[paragraph_index]
|
83 |
-
results = text_to_sentiment(selected_paragraph, True)
|
84 |
if isinstance(results, list) and isinstance(results[0], list):
|
85 |
# We unpack the list of dictionaries to get all labels
|
86 |
output = {result['label']: result['score'] for result in results[0]}
|
@@ -117,7 +118,7 @@ def process_paragraph_2_sent(paragraph):
|
|
117 |
try:
|
118 |
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
119 |
selected_paragraph = stored_paragraphs_2[paragraph_index]
|
120 |
-
results = text_to_sentiment(selected_paragraph, True)
|
121 |
if isinstance(results, list) and isinstance(results[0], list):
|
122 |
# We unpack the list of dictionaries to get all labels
|
123 |
output = {result['label']: result['score'] for result in results[0]}
|
|
|
31 |
resp = summarizer(text)
|
32 |
return resp[0]['summary_text']
|
33 |
|
34 |
+
def text_to_sentiment(text, all_score=False, label == True):
|
35 |
+
if label:
|
36 |
+
return fin_model(text, return_all_scores=all_score)[0]["label"]
|
37 |
+
else:
|
38 |
+
return fin_model(text, return_all_scores=all_score)[0]
|
39 |
def fin_ext(text):
|
40 |
results = fin_model(split_in_sentences(text))
|
41 |
return make_spans(text, results)
|
|
|
81 |
try:
|
82 |
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
83 |
selected_paragraph = stored_paragraphs_1[paragraph_index]
|
84 |
+
results = text_to_sentiment(selected_paragraph, True, False)
|
85 |
if isinstance(results, list) and isinstance(results[0], list):
|
86 |
# We unpack the list of dictionaries to get all labels
|
87 |
output = {result['label']: result['score'] for result in results[0]}
|
|
|
118 |
try:
|
119 |
paragraph_index = int(paragraph.split(':')[0].replace('Paragraph ', '')) - 1
|
120 |
selected_paragraph = stored_paragraphs_2[paragraph_index]
|
121 |
+
results = text_to_sentiment(selected_paragraph, True, False)
|
122 |
if isinstance(results, list) and isinstance(results[0], list):
|
123 |
# We unpack the list of dictionaries to get all labels
|
124 |
output = {result['label']: result['score'] for result in results[0]}
|