bauerem commited on
Commit
d75d460
1 Parent(s): 70f8354

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -3
app.py CHANGED
@@ -5,18 +5,22 @@ import re
5
  model_path = "model/MemSum_Final/model.pt"
6
  summarizer = MemSum(model_path, "model/glove/vocabulary_200dim.pkl")
7
 
8
- sent_tokenize = lambda txt: re.split(r'(?<=[.!?])\s(?=[A-Z])', txt)
 
 
 
9
 
10
- preprocess = lambda text: re.sub(r'[\n\s]+', ' ', text)
11
 
12
  def summarize(text):
13
 
14
  text = sent_tokenize( preprocess(text) )
15
 
16
- summary = "\n".join( summarizer.summarize(text) )
17
 
18
  return summary
19
 
 
20
  input = gr.Textbox(label="Input text", placeholder="Court opinion text goes here...")
21
  output = gr.Textbox(label="Summary", placeholder="Output summary will appear here...")
22
 
 
5
  model_path = "model/MemSum_Final/model.pt"
6
  summarizer = MemSum(model_path, "model/glove/vocabulary_200dim.pkl")
7
 
8
+ def preprocess(text):
9
+ text = text.replace('- ', '')
10
+ text = re.sub(r'[\n\s]+', ' ', text)
11
+ return text
12
 
13
+ sent_tokenize = lambda txt: re.split(r'(?<=[.!?])\s(?=[A-Z])', txt)
14
 
15
  def summarize(text):
16
 
17
  text = sent_tokenize( preprocess(text) )
18
 
19
+ summary = "\n\n".join( summarizer.summarize(text) )
20
 
21
  return summary
22
 
23
+
24
  input = gr.Textbox(label="Input text", placeholder="Court opinion text goes here...")
25
  output = gr.Textbox(label="Summary", placeholder="Output summary will appear here...")
26