MVesalA commited on
Commit
6e745f5
·
verified ·
1 Parent(s): 69b20cf

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +1 -33
app.py CHANGED
@@ -1,36 +1,4 @@
1
- import torch
2
- import gradio
3
- from transformers import pipeline
4
- from bs4 import BeautifulSoup
5
- import requests
6
-
7
- def SUMMARIZE(Url):
8
- summarizer = pipeline("summarization", model="stevhliu/my_awesome_billsum_model")
9
- r = requests.get(Url)
10
- soup = BeautifulSoup(r.text, 'html.parser')
11
- results = soup.find_all(['hl', 'p'])
12
- text = [result.text for result in results]
13
- Article = ''.join(text)
14
- sentences = Article.split(' ')
15
- current_chunk = 0
16
- chunks = []
17
- for sentence in sentences:
18
- if len(chunks) == current_chunk + 1:
19
- if len(chunks[current_chunk]) + len(sentence.split(' ')) <= max_chunk:
20
- chunks[current_chunk].extend(sentence.split(' '))
21
- else:
22
- current_chunk += 1
23
- chunks.append(sentence.split(' '))
24
- else:
25
- #print(current_chunk)
26
- chunks.append(sentence.split(' '))
27
-
28
- for chunk_id in range(len(chunks)):
29
- chunks[chunk_id] = ' '.join(chunks[chunk_id])
30
- res = summarizer(chunks, max_length=120, min_length=30, do_sample=False)
31
- for i in range(len(res)):
32
- return res[i].values()
33
-
34
 
35
  interface = gradio.Interface(fn=SUMMARIZE,
36
  inputs=gradio.TextArea(lines=2, value="https://medium.com/analytics-vidhya/openai-gpt-3-language-models-are-few-shot-learners-82531b3d3122"),
 
1
+ from util import SUMMARIZE
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
  interface = gradio.Interface(fn=SUMMARIZE,
4
  inputs=gradio.TextArea(lines=2, value="https://medium.com/analytics-vidhya/openai-gpt-3-language-models-are-few-shot-learners-82531b3d3122"),