Spaces:
Runtime error
Runtime error
Commit ·
c9a2e1a
1
Parent(s): 471b76d
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,16 +2,18 @@
|
|
| 2 |
import re
|
| 3 |
import nltk
|
| 4 |
from nltk.tokenize import sent_tokenize
|
| 5 |
-
nltk.download(
|
| 6 |
import gradio as gr
|
| 7 |
from gradio.mix import Parallel
|
| 8 |
|
|
|
|
| 9 |
# Defining a function to read in the text file
|
| 10 |
def read_in_text(url):
|
| 11 |
-
with open(
|
| 12 |
article = file.read()
|
| 13 |
return article
|
| 14 |
-
|
|
|
|
| 15 |
#Doing some text preprocessing, more will still be needed later
|
| 16 |
def clean_text(text):
|
| 17 |
#text = read_in_text(url)
|
|
@@ -38,6 +40,7 @@ from transformers import (
|
|
| 38 |
tokenizer = AutoTokenizer.from_pretrained("valurank/final_headline_generator")
|
| 39 |
model = AutoModelForSeq2SeqLM.from_pretrained("valurank/final_headline_generator")
|
| 40 |
|
|
|
|
| 41 |
#Defining a function to generate the headlines
|
| 42 |
def headline_generator_2(file):
|
| 43 |
input_text = file
|
|
|
|
| 2 |
import re
|
| 3 |
import nltk
|
| 4 |
from nltk.tokenize import sent_tokenize
|
| 5 |
+
nltk.download("punkt")
|
| 6 |
import gradio as gr
|
| 7 |
from gradio.mix import Parallel
|
| 8 |
|
| 9 |
+
|
| 10 |
# Defining a function to read in the text file
|
| 11 |
def read_in_text(url):
|
| 12 |
+
with open(URL, "r") as file:
|
| 13 |
article = file.read()
|
| 14 |
return article
|
| 15 |
+
|
| 16 |
+
|
| 17 |
#Doing some text preprocessing, more will still be needed later
|
| 18 |
def clean_text(text):
|
| 19 |
#text = read_in_text(url)
|
|
|
|
| 40 |
tokenizer = AutoTokenizer.from_pretrained("valurank/final_headline_generator")
|
| 41 |
model = AutoModelForSeq2SeqLM.from_pretrained("valurank/final_headline_generator")
|
| 42 |
|
| 43 |
+
|
| 44 |
#Defining a function to generate the headlines
|
| 45 |
def headline_generator_2(file):
|
| 46 |
input_text = file
|