Commit
·
6536c32
1
Parent(s):
99b1579
final updates
Browse files
app.py
CHANGED
@@ -4,8 +4,9 @@ def data_summarizer(input_eng):
|
|
4 |
from bs4 import BeautifulSoup
|
5 |
from googletrans import Translator
|
6 |
import warnings
|
|
|
7 |
from transformers import pipeline
|
8 |
-
|
9 |
from transformers import PegasusForConditionalGeneration, AutoTokenizer
|
10 |
tokenizer = AutoTokenizer.from_pretrained("google/pegasus-xsum")
|
11 |
warnings.filterwarnings("ignore")
|
@@ -47,11 +48,14 @@ def data_summarizer(input_eng):
|
|
47 |
# return {"Output_summary :":out.text,"Keywords":keys.text.replace("\n",","),"Sentiment":f"{'Positive' if analysis.polarity > 0 else 'Negative' if analysis.polarity < 0 else 'Neutral' }"}
|
48 |
# print(translation.text)
|
49 |
# print(translation.extra_data)
|
50 |
-
return
|
51 |
|
52 |
except Exception as e:
|
53 |
raise e
|
54 |
|
|
|
|
|
|
|
55 |
# input_eng = input()
|
56 |
# data_summarizer(input_eng)
|
57 |
import gradio as gr
|
|
|
4 |
from bs4 import BeautifulSoup
|
5 |
from googletrans import Translator
|
6 |
import warnings
|
7 |
+
warnings.filterwarnings("ignore")
|
8 |
from transformers import pipeline
|
9 |
+
sentiment = pipeline("sentiment-analysis")
|
10 |
from transformers import PegasusForConditionalGeneration, AutoTokenizer
|
11 |
tokenizer = AutoTokenizer.from_pretrained("google/pegasus-xsum")
|
12 |
warnings.filterwarnings("ignore")
|
|
|
48 |
# return {"Output_summary :":out.text,"Keywords":keys.text.replace("\n",","),"Sentiment":f"{'Positive' if analysis.polarity > 0 else 'Negative' if analysis.polarity < 0 else 'Neutral' }"}
|
49 |
# print(translation.text)
|
50 |
# print(translation.extra_data)
|
51 |
+
return sentiment(out.text.strip())[0]['label'], keys.text.replace("\n",","), out.text.strip()
|
52 |
|
53 |
except Exception as e:
|
54 |
raise e
|
55 |
|
56 |
+
|
57 |
+
|
58 |
+
|
59 |
# input_eng = input()
|
60 |
# data_summarizer(input_eng)
|
61 |
import gradio as gr
|