entity-scraper / app.py
ikashyaprathod's picture
Update app.py
592c0ca verified
raw
history blame contribute delete
804 Bytes
import gradio as gr
from transformers import pipeline
# Load BERT NER pipeline
ner_pipeline = pipeline("ner", model="dslim/bert-base-NER", aggregation_strategy="simple")
def extract_entities(text):
entities = ner_pipeline(text)
results = []
for ent in entities:
results.append({
"Entity": ent["word"],
"Label": ent["entity_group"],
"Score": round(ent["score"] * 100, 2)
})
return results
iface = gr.Interface(
fn=extract_entities,
inputs=gr.Textbox(lines=10, placeholder="Paste your content here"),
outputs=gr.Dataframe(headers=["Entity", "Label", "Score"]),
title="Semantic Keyword + Entity Extractor",
description="Extracts BERT-based Named Entities for semantic coverage and AI optimization."
)
iface.launch()