web_summarizer / app.py
0x11c11e
Add application file
d29611d
import gradio as gr
import spacy
import requests
from bs4 import BeautifulSoup
# Load the pre-trained model
nlp = spacy.load("en_core_web_sm")
def extract_entities(url):
# Step 1: Web scraping
response = requests.get(url)
soup = BeautifulSoup(response.text, 'html.parser')
page_text = soup.get_text()
# Apply the model to the text
doc = nlp(page_text)
# Extract entities and return as a formatted string
results = "\n".join([f"{entity.text} ({entity.label_})" for entity in doc.ents])
return results
iface = gr.Interface(fn=extract_entities,
inputs="textbox",
outputs="text",
interpretation="default")
iface.launch()