arithescientist commited on
Commit
87c8857
·
1 Parent(s): eb83f46

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -36
app.py CHANGED
@@ -29,42 +29,16 @@ print('Using model {}\n'.format(model_name))
29
 
30
 
31
  def lincoln(content):
32
- summary_text = ""
33
- for i, paragraph in enumerate(content.split("\n\n")):
34
- # get rid of empty paragraphs and one word paras and extra whitespaces
35
- paragraph = paragraph.replace('\n',' ')
36
- paragraph = paragraph.replace('\t','')
37
- paragraph = ' '.join(paragraph.split())
38
- # count words in the paragraph and exclude if less than 4 words
39
- tokens = word_tokenize(paragraph)
40
- # only do real words
41
- tokens = [word for word in tokens if word.isalpha()]
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(