ARtOrias11 commited on
Commit
d7a2aec
·
verified ·
1 Parent(s): fa33af5

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +65 -0
app.py ADDED
@@ -0,0 +1,65 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # -*- coding: utf-8 -*-
2
+ """NER_APP
3
+
4
+ Automatically generated by Colab.
5
+
6
+ Original file is located at
7
+ 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
8
+ """
9
+
10
+ # This Python 3 environment comes with many helpful analytics libraries installed
11
+ # It is defined by the kaggle/python Docker image: https://github.com/kaggle/docker-python
12
+ # For example, here's several helpful packages to load
13
+
14
+ import numpy as np # linear algebra
15
+ import pandas as pd # data processing, CSV file I/O (e.g. pd.read_csv)
16
+
17
+ # Input data files are available in the read-only "../input/" directory
18
+ # For example, running this (by clicking run or pressing Shift+Enter) will list all files under the input directory
19
+
20
+ import os
21
+ for dirname, _, filenames in os.walk('/kaggle/input'):
22
+ for filename in filenames:
23
+ print(os.path.join(dirname, filename))
24
+
25
+ # You can write up to 20GB to the current directory (/kaggle/working/) that gets preserved as output when you create a version using "Save & Run All"
26
+ # You can also write temporary files to /kaggle/temp/, but they won't be saved outside of the current session
27
+
28
+ !pip install -q transformers
29
+
30
+ from transformers import pipeline
31
+
32
+ ner_pipeline = pipeline("ner", model="Tirendaz/roberta-base-NER")
33
+
34
+ text = "I am Tim and I work at Google"
35
+
36
+ ner_pipeline(text)
37
+
38
+ text_tr = "Benim adım Ali ve Trendyol'da çalışıyorum"
39
+ ner_pipeline(text_tr)
40
+
41
+ ner_pipeline(text_tr, aggregation_strategy = "simple")
42
+
43
+ def ner(text):
44
+ output = ner_pipeline(text, aggregation_strategy="simple")
45
+ return {"text": text, "entities": output}
46
+
47
+ !pip install -q gradio
48
+
49
+ import gradio as gr
50
+
51
+ examples = [
52
+ "My name is Tim and I live in California",
53
+ "Ich arbeite bei Google in Berlin",
54
+ "Ali, Ankara'lı mı?"
55
+ ]
56
+
57
+ demo = gr.Interface(
58
+ ner,
59
+ gr.Textbox(placeholder="Enter sentence here..."),
60
+ gr.HighlightedText(),
61
+ examples=examples
62
+ )
63
+
64
+ demo.launch(share=True)
65
+