Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -17,6 +17,7 @@ from string import punctuation
|
|
| 17 |
# Prediction
|
| 18 |
def prediction(text):
|
| 19 |
doc = nlp(text)
|
|
|
|
| 20 |
tokens = [token.text for token in doc]
|
| 21 |
word_frequencies = {}
|
| 22 |
for word in doc:
|
|
@@ -40,7 +41,8 @@ def prediction(text):
|
|
| 40 |
sentence_scores[sent] += word_frequencies[word.text.lower()]
|
| 41 |
select_length = int(len(sentence_tokens)*0.3)
|
| 42 |
summary = nlargest(select_length, sentence_scores, key = sentence_scores.get)
|
| 43 |
-
|
|
|
|
| 44 |
|
| 45 |
#text = """
|
| 46 |
# Maria Sharapova has basically no friends as tennis players on the WTA Tour. The Russian player has no problems in openly speaking about it and in a recent interview she said: 'I don't really hide any feelings too much.
|
|
@@ -60,11 +62,15 @@ def prediction(text):
|
|
| 60 |
#DESCRIPTION = "Occlusion means the act of closing, blocking or shutting something or the state of being closed or blocked"
|
| 61 |
#summary = prediction(text)
|
| 62 |
#print(summary)
|
| 63 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 64 |
demo_app = gr.Interface(
|
| 65 |
fn=prediction,
|
| 66 |
-
inputs=gr.Textbox(label = " Enter the Text", max_lines = 20),
|
| 67 |
-
outputs=
|
| 68 |
title = "Text Summarization",
|
| 69 |
#description = DESCRIPTION,
|
| 70 |
#examples = EXAMPLES,
|
|
|
|
| 17 |
# Prediction
|
| 18 |
def prediction(text):
|
| 19 |
doc = nlp(text)
|
| 20 |
+
len1 = len(text.split())
|
| 21 |
tokens = [token.text for token in doc]
|
| 22 |
word_frequencies = {}
|
| 23 |
for word in doc:
|
|
|
|
| 41 |
sentence_scores[sent] += word_frequencies[word.text.lower()]
|
| 42 |
select_length = int(len(sentence_tokens)*0.3)
|
| 43 |
summary = nlargest(select_length, sentence_scores, key = sentence_scores.get)
|
| 44 |
+
len2 = len(summary.split())
|
| 45 |
+
return summary,len1,len2
|
| 46 |
|
| 47 |
#text = """
|
| 48 |
# Maria Sharapova has basically no friends as tennis players on the WTA Tour. The Russian player has no problems in openly speaking about it and in a recent interview she said: 'I don't really hide any feelings too much.
|
|
|
|
| 62 |
#DESCRIPTION = "Occlusion means the act of closing, blocking or shutting something or the state of being closed or blocked"
|
| 63 |
#summary = prediction(text)
|
| 64 |
#print(summary)
|
| 65 |
+
outputs = [
|
| 66 |
+
gr.Textbox(lines =5,label = "Summarization of text"),
|
| 67 |
+
gr.Number(label="count1")
|
| 68 |
+
gr.Number(label="count2")
|
| 69 |
+
]
|
| 70 |
demo_app = gr.Interface(
|
| 71 |
fn=prediction,
|
| 72 |
+
inputs=gr.Textbox(lines =10,label = " Enter the Text", max_lines = 20),
|
| 73 |
+
outputs= outputs,
|
| 74 |
title = "Text Summarization",
|
| 75 |
#description = DESCRIPTION,
|
| 76 |
#examples = EXAMPLES,
|