Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -41,20 +41,22 @@ def prediction(text):
|
|
| 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 |
-
|
| 45 |
-
|
|
|
|
|
|
|
| 46 |
|
| 47 |
-
|
| 48 |
-
|
| 49 |
-
|
| 50 |
-
|
| 51 |
-
|
| 52 |
-
|
| 53 |
-
|
| 54 |
-
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
|
| 58 |
#predicted_label, score = occ_predict("img1.jpg")
|
| 59 |
#inputs = gr.inputs.text(label)
|
| 60 |
#label = gr.outputs.Label(num_top_classes=2)
|
|
@@ -67,13 +69,14 @@ outputs = [
|
|
| 67 |
gr.Number(label="Word Count of given Text"),
|
| 68 |
gr.Number(label="Word Count of Summarized Text")
|
| 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 |
-
|
| 77 |
#cache_example = True,
|
| 78 |
#live = True,
|
| 79 |
theme = 'huggingface'
|
|
|
|
| 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 |
+
org_len = len(text.split(' '))
|
| 45 |
+
summary = (str(summary[0]))
|
| 46 |
+
sum_len = len(summary.split(' '))
|
| 47 |
+
return summary,org_len,sum_len
|
| 48 |
|
| 49 |
+
text = """
|
| 50 |
+
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.
|
| 51 |
+
I think everyone knows this is my job here. When I'm on the courts or when I'm on the court playing, I'm a competitor and I want to beat every single person whether they're in the locker room or across the net.
|
| 52 |
+
So I'm not the one to strike up a conversation about the weather and know that in the next few minutes I have to go and try to win a tennis match.
|
| 53 |
+
I'm a pretty competitive girl. I say my hellos, but I'm not sending any players flowers as well. Uhm, I'm not really friendly or close to many players.
|
| 54 |
+
I have not a lot of friends away from the courts.' When she said she is not really close to a lot of players, is that something strategic that she is doing? Is it different on the men's tour than the women's tour? 'No, not at all.
|
| 55 |
+
I think just because you're in the same sport doesn't mean that you have to be friends with everyone just because you're categorized, you're a tennis player, so you're going to get along with tennis players.
|
| 56 |
+
I think every person has different interests. I have friends that have completely different jobs and interests, and I've met them in very different parts of my life.
|
| 57 |
+
I think everyone just thinks because we're tennis players we should be the greatest of friends. But ultimately tennis is just a very small part of what we do.
|
| 58 |
+
There are so many other things that we're interested in, that we do.'
|
| 59 |
+
"""
|
| 60 |
#predicted_label, score = occ_predict("img1.jpg")
|
| 61 |
#inputs = gr.inputs.text(label)
|
| 62 |
#label = gr.outputs.Label(num_top_classes=2)
|
|
|
|
| 69 |
gr.Number(label="Word Count of given Text"),
|
| 70 |
gr.Number(label="Word Count of Summarized Text")
|
| 71 |
]
|
| 72 |
+
example = text
|
| 73 |
demo_app = gr.Interface(
|
| 74 |
fn=prediction,
|
| 75 |
inputs=gr.Textbox(lines =10,label = " Enter the Text", max_lines = 20),
|
| 76 |
outputs= outputs,
|
| 77 |
title = "Text Summarization",
|
| 78 |
#description = DESCRIPTION,
|
| 79 |
+
examples = example,
|
| 80 |
#cache_example = True,
|
| 81 |
#live = True,
|
| 82 |
theme = 'huggingface'
|