# -*- coding: utf-8 -*- """NER_APP Automatically generated by Colab. Original file is located at https://colab.research.google.com/#fileId=https%3A//storage.googleapis.com/kaggle-colab-exported-notebooks/ner-app-4d7a2843-05be-4536-8268-25e14a665793.ipynb%3FX-Goog-Algorithm%3DGOOG4-RSA-SHA256%26X-Goog-Credential%3Dgcp-kaggle-com%2540kaggle-161607.iam.gserviceaccount.com/20250116/auto/storage/goog4_request%26X-Goog-Date%3D20250116T193935Z%26X-Goog-Expires%3D259200%26X-Goog-SignedHeaders%3Dhost%26X-Goog-Signature%3Da8514916063f2f41f6c07de8e2e3ff8b6a302fff2401fd4e3f97cc8e31eaa05faa728975260701754e4f739c8a30815b7c041548193448195812b23254b93d8e654e7a4b34a3a83437a6a9ef7fbc704caba614cac7098b39e0b4165f64960cadf1c413af998265888cc5bb89263cc34ab7580decc1c802c88c8b0e6364a1d7aa79952445153f5094b8a2a9578fc4a493ffcdbcce10f057fccdc5c1b39518ee4b9cd832835bdd8e2b256d515615344ea3d6b0bbbf52212f6dd46780fba5145cbd7d496cca18c9ae6d46c43b2b908dc33d2182a401232ff258c65d63c37bbded8182fcdfd17ee795f4132b026a15664a48f9bb668561007e2a9ff9fbd8243e5a38 """ # This Python 3 environment comes with many helpful analytics libraries installed # It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python # For example, here's several helpful packages to load from transformers import pipeline import gradio as gr # Load the NER pipeline ner_pipeline = pipeline("ner", model="Tirendaz/roberta-base-NER") # Function to process text and return entities def ner(text): output = ner_pipeline(text, aggregation_strategy="simple") return {"text": text, "entities": output} # Examples for the Gradio interface examples = [ "My name is Tim and I live in California", "Ich arbeite bei Google in Berlin", "In a world brimming with technological advancements, humanity finds itself on the cusp of unparalleled innovation and profound challenges" ] # Define the Gradio app demo = gr.Interface( fn=ner, inputs=gr.Textbox(placeholder="Enter sentence here..."), outputs=gr.HighlightedText(), examples=examples ) # Launch the Gradio app demo.launch()