grapplerulrich commited on
Commit
037af6c
1 Parent(s): 526644d

First basic summarisation

Browse files
Files changed (2) hide show
  1. main.py +6 -1
  2. requirements.txt +1 -0
main.py CHANGED
@@ -7,6 +7,7 @@ import streamlit as st
7
  from dotenv import load_dotenv
8
  from googleapiclient.discovery import build
9
  from slugify import slugify
 
10
 
11
  from beautiful_soup.app import get_url_content
12
 
@@ -60,7 +61,11 @@ def main():
60
  for result in results:
61
  st.write(result['link'])
62
  try:
63
- st.write( get_url_content( result['link'] ) )
 
 
 
 
64
  except Exception as exception:
65
  st.exception(exception)
66
 
 
7
  from dotenv import load_dotenv
8
  from googleapiclient.discovery import build
9
  from slugify import slugify
10
+ from transformers import pipeline
11
 
12
  from beautiful_soup.app import get_url_content
13
 
 
61
  for result in results:
62
  st.write(result['link'])
63
  try:
64
+ content = get_url_content( result['link'] )
65
+ summarizer = pipeline("summarization", model="sshleifer/distilbart-cnn-12-6")
66
+ summary = summarizer(content, max_length=130, min_length=30, do_sample=False, truncation=True)
67
+ for sentence in summary:
68
+ st.write(sentence['summary_text'])
69
  except Exception as exception:
70
  st.exception(exception)
71
 
requirements.txt CHANGED
@@ -3,3 +3,4 @@ google
3
  python-dotenv
4
  beautifulsoup4
5
  python-slugify
 
 
3
  python-dotenv
4
  beautifulsoup4
5
  python-slugify
6
+ transformers[sentencepiece,torch]