Spaces:
Runtime error
Runtime error
Commit
·
87c8857
1
Parent(s):
eb83f46
Update app.py
Browse files
app.py
CHANGED
|
@@ -29,42 +29,16 @@ print('Using model {}\n'.format(model_name))
|
|
| 29 |
|
| 30 |
|
| 31 |
def lincoln(content):
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
# print("\nTokens: {}\n".format(len(tokens)))
|
| 43 |
-
# only do sentences with more than 1 words excl. alpha crap
|
| 44 |
-
if len(tokens) <= 1:
|
| 45 |
-
continue
|
| 46 |
-
# Perhaps also ignore paragraphs with no sentence?
|
| 47 |
-
sentences = sent_tokenize(paragraph)
|
| 48 |
-
|
| 49 |
-
# recreate paragraph from the only words tokens list
|
| 50 |
-
paragraph = ' '.join(tokens)
|
| 51 |
-
|
| 52 |
-
print("\nParagraph:")
|
| 53 |
-
print(paragraph+"\n")
|
| 54 |
-
# T5 needs to have 'summarize' in order to work:
|
| 55 |
-
# text = "summarize:" + paragraph
|
| 56 |
-
text = paragraph
|
| 57 |
-
# encoding the input text
|
| 58 |
-
bert_legal_model(content)
|
| 59 |
-
summary = bert_legal_model(text, ratio = 0.01)
|
| 60 |
-
# summary = tokenizer_t5.decode(summary_ids[0], skip_special_tokens=True)
|
| 61 |
-
summary_text += str(summary) + "\n\n"
|
| 62 |
-
print("Summary:")
|
| 63 |
-
print(summary)
|
| 64 |
-
|
| 65 |
-
all_text = str(summary_text)
|
| 66 |
-
|
| 67 |
-
return all_text
|
| 68 |
|
| 69 |
|
| 70 |
iface = gr.Interface(
|
|
|
|
| 29 |
|
| 30 |
|
| 31 |
def lincoln(content):
|
| 32 |
+
|
| 33 |
+
bert_legal_model(content)
|
| 34 |
+
summary = bert_legal_model(content, min_length = 8, ratio = 0.05)
|
| 35 |
+
# summary = tokenizer_t5.decode(summary_ids[0], skip_special_tokens=True)
|
| 36 |
+
summary_text += str(summary) + "\n\n"
|
| 37 |
+
print("Summary:")
|
| 38 |
+
print(summary)
|
| 39 |
+
all_text = str(summary_text)
|
| 40 |
+
|
| 41 |
+
return all_text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 42 |
|
| 43 |
|
| 44 |
iface = gr.Interface(
|