urchade commited on
Commit
c59464c
1 Parent(s): 48c2230

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +60 -69
app.py CHANGED
@@ -2,101 +2,99 @@ from typing import Dict, Union
2
  from gliner import GLiNER
3
  import gradio as gr
4
 
5
- model = GLiNER.from_pretrained("urchade/gliner_multi-v2.1")
6
 
7
  examples = [
8
  [
9
- "Libretto by Marius Petipa, based on the 1822 novella ``Trilby, ou Le Lutin d'Argail`` by Charles Nodier, first presented by the Ballet of the Moscow Imperial Bolshoi Theatre on January 25/February 6 (Julian/Gregorian calendar dates), 1870, in Moscow with Polina Karpakova as Trilby and Ludiia Geiten as Miranda and restaged by Petipa for the Imperial Ballet at the Imperial Bolshoi Kamenny Theatre on January 17–29, 1871 in St. Petersburg with Adèle Grantzow as Trilby and Lev Ivanov as Count Leopold.",
10
- "person, book, location, date, actor, character",
11
- 0.3,
12
- True,
13
  ],
14
  [
15
- """
16
- * Data Scientist, Data Analyst, or Data Engineer with 1+ years of experience.
17
- * Experience with technologies such as Docker, Kubernetes, or Kubeflow
18
- * Machine Learning experience preferred
19
- * Experience with programming languages such as Python, C++, or SQL preferred
20
- * Experience with technologies such as Databricks, Qlik, TensorFlow, PyTorch, Python, Dash, Pandas, or NumPy preferred
21
- * BA or BS degree
22
- * Active Secret OR Active Top Secret or Active TS/SCI clearance
23
- """,
24
- "software package, programing language, software tool, degree, job title",
25
- 0.3,
26
  False,
27
  ],
28
  [
29
- "However, both models lack other frequent DM symptoms including the fibre-type dependent atrophy, myotonia, cataract and male-infertility.",
30
- "disease, symptom",
31
- 0.3,
32
  False,
33
  ],
34
  [
35
- "Synergy between signal transduction pathways is obligatory for expression of c-fos in B and T cell lines: implication for c-fos control via surface immunoglobulin and T cell antigen receptors.",
36
- "DNA, RNA, cell line, cell type, protein",
37
- 0.3,
38
  False,
39
  ],
40
  [
41
- "The choice of the encoder and decoder modules of dnpg can be quite flexible, for instance long short term memory networks (lstm) or convolutional neural network (cnn).",
42
- "short acronym, long acronym",
43
- 0.3,
44
  False,
45
  ],
46
  [
47
- "Amelia Earhart flew her single engine Lockheed Vega 5B across the Atlantic to Paris.",
48
- "person, company, location, airplane",
49
- 0.3,
50
- True,
51
  ],
52
  [
53
- "Feldman is a contributor to NBC Sports Boston's ``State of the Revs`` and ``Revolution Postgame Live`` programs as well as to 98.5 the SportsHub, SiriusXM FC's MLS coverage and to other New England and national radio outlets and podcasts.",
54
- "person, company, location",
55
- 0.3,
56
  False,
57
  ],
58
  [
59
- "On 25 July 1948, on the 39th anniversary of Bleriot's crossing of the English Channel, the Type 618 Nene-Viking flew Heathrow to Paris (Villacoublay) in the morning carrying letters to Bleriot's widow and son (secretary of the FAI), who met it at the airport.",
60
- "date, location, person, organization",
61
- 0.3,
62
  False,
63
  ],
64
  [
65
- "Leo & Ian won the 1962 Bathurst Six Hour Classic at Mount Panorama driving a Daimler SP250 sports car, (that year the 500 mile race for touring cars were held at Phillip Island)",
66
- "person, date, location, organization, competition",
67
- 0.3,
68
  False,
69
  ],
70
  [
71
- "The Shore Line route of the CNS & M until 1955 served, from south to north, the Illinois communities of Chicago, Evanston, Wilmette, Kenilworth, Winnetka, Glencoe, Highland Park, Highwood, Fort Sheridan, Lake Forest, Lake Bluff, North Chicago, Waukegan, Zion, and Winthrop Harbor as well as Kenosha, Racine, and Milwaukee (the ``KRM'') in Wisconsin.",
72
- "location, organization, date",
73
- 0.3,
74
  False,
75
  ],
76
  [
77
- "Comet C/2006 M4 (SWAN) is a non-periodic comet discovered in late June 2006 by Robert D. Matson of Irvine, California and Michael Mattiazzo of Adelaide, South Australia in publicly available images of the Solar and Heliospheric Observatory (SOHO).",
78
- "person, organization, date, location",
79
- 0.3,
80
  False,
81
  ],
82
  [
83
- "From November 29, 2011 to March 31, 2012, Karimloo returned to ``Les Misérables`` to play the lead role of Jean Valjean at The Queen's Theatre, London, for which he won the 2013 Theatregoers' Choice Award for Best Takeover in a Role.",
84
- "person, actor, award, date, location",
85
- 0.3,
86
  False,
87
  ],
88
  [
89
- "A Mexicali health clinic supported by former Baja California gubernatorial candidate Enrique Acosta Fregoso (PRI) was closed on June 15 after selling a supposed COVID-19 ``cure'' for between MXN $10,000 and $50,000.",
90
- "location, organization, person, date, currency",
91
- 0.3,
92
  False,
93
  ],
94
  [
95
- "Built in 1793, it was the home of Mary Young Pickersgill when she moved to Baltimore in 1806 and the location where she later sewed the ``Star Spangled Banner'', in 1813, the huge out-sized garrison flag that flew over Fort McHenry at Whetstone Point in Baltimore Harbor in the summer of 1814 during the British Royal Navy attack in the Battle of Baltimore during the War of 1812.",
96
- "date, person, location, organization, event, flag",
97
- 0.3,
98
  False,
99
  ],
 
 
 
 
 
 
100
  ]
101
 
102
 
@@ -153,14 +151,13 @@ with gr.Blocks(title="GLiNER-M-v2.1") as demo:
153
  '''
154
  from gliner import GLiNER
155
 
156
- model = GLiNER.from_pretrained("urchade/gliner_mediumv2.1")
157
 
158
  text = """
159
- Cristiano Ronaldo dos Santos Aveiro (Portuguese pronunciation: [kɾiʃˈtjɐnu ʁɔˈnaldu]; born 5 February 1985) is a Portuguese professional footballer who plays as a forward for and captains both Saudi Pro League club Al Nassr and the Portugal national team. Widely regarded as one of the greatest players of all time, Ronaldo has won five Ballon d'Or awards,[note 3] a record three UEFA Men's Player of the Year Awards, and four European Golden Shoes, the most by a European player. He has won 33 trophies in his career, including seven league titles, five UEFA Champions Leagues, the UEFA European Championship and the UEFA Nations League. Ronaldo holds the records for most appearances (183), goals (140) and assists (42) in the Champions League, goals in the European Championship (14), international goals (128) and international appearances (205). He is one of the few players to have made over 1,200 professional career appearances, the most by an outfield player, and has scored over 850 official senior career goals for club and country, making him the top goalscorer of all time.
160
  """
161
 
162
- labels = ["person", "award", "date", "competitions", "teams"]
163
-
164
  entities = model.predict_entities(text, labels)
165
 
166
  for entity in entities:
@@ -170,18 +167,12 @@ for entity in entities:
170
  )
171
  gr.Code(
172
  """
173
- Cristiano Ronaldo dos Santos Aveiro => person
174
- 5 February 1985 => date
175
- Al Nassr => teams
176
- Portugal national team => teams
177
- Ballon d'Or => award
178
- UEFA Men's Player of the Year Awards => award
179
- European Golden Shoes => award
180
- UEFA Champions Leagues => competitions
181
- UEFA European Championship => competitions
182
- UEFA Nations League => competitions
183
- Champions League => competitions
184
- European Championship => competitions
185
  """
186
  )
187
 
 
2
  from gliner import GLiNER
3
  import gradio as gr
4
 
5
+ model = GLiNER.from_pretrained("urchade/gliner_multi_pii-v1")
6
 
7
  examples = [
8
  [
9
+ "Pierre Dubois, résident de Paris, a fondé sa propre entreprise, Le Petit Café, située au 15 Rue de la Paix. Son numéro d'entreprise est FR-987654321-1, et il utilise le compte bancaire 9876543210 pour les transactions.",
10
+ "person, organization, address, company registration number, bank account number",
11
+ 0.5,
12
+ False,
13
  ],
14
  [
15
+ "Leticia Ramírez, una habitante de Barcelona, tiene una cita médica programada en el Hospital General de Cataluña, situado en 10 Calle de los Ángeles. Su número de la seguridad social es ES-123456789-A y su grupo sanguíneo es AB+.",
16
+ "person, location, address, social security number, blood type",
17
+ 0.5,
 
 
 
 
 
 
 
 
18
  False,
19
  ],
20
  [
21
+ "John Smith, from London, teaches mathematics at Royal Academy located at 25 King’s Road. His employee ID is UK-987654-321 and he has been working there since 2015.",
22
+ "person, profession, organization, address, employee ID number",
23
+ 0.5,
24
  False,
25
  ],
26
  [
27
+ "In Frankfurt, Claudia Weber frequently visits her local bank branch, Deutsche Bank, at 48 Hauptstraße. Her account number is DE-1234567890123456, used primarily for her mortgage payments.",
28
+ "person, location, address, bank account number",
29
+ 0.5,
30
  False,
31
  ],
32
  [
33
+ "Marta Rossi, residente a Roma, ha acquistato un appartamento al 123 Via Condotti. Il numero di registrazione della proprietà è IT-654321-2018 e il mutuo è gestito tramite la Banca d'Italia con numero di conto 3216549870.",
34
+ "person, address, property registration number, bank account number",
35
+ 0.5,
36
  False,
37
  ],
38
  [
39
+ "Paulo Coelho, um turista do Brasil, fez um seguro de viagem com a empresa Seguros PT antes de sua viagem para Lisboa. O número da apólice é BR-987654321-123 e inclui cobertura médica.",
40
+ "person, nationality, company, insurance policy number, coverage",
41
+ 0.5,
42
+ False,
43
  ],
44
  [
45
+ "Julia Fischer, eine Kundin aus München, hat bei der BayWa AG, einem großen Anbieter von Baustoffen mit Sitz am 77 Industriestraße, einen Kredit aufgenommen. Die Kreditnummer lautet DE-12345678.",
46
+ "person, city, organization, address, loan number",
47
+ 0.5,
48
  False,
49
  ],
50
  [
51
+ "Carlos Sánchez, profesor en la Universidad de Madrid, reside en el 5 Calle de Alcalá. Su número de identificación de profesor es ES-192837465 y tiene un doctorado en filosofía.",
52
+ "person, profession, address, teacher ID number, degree",
53
+ 0.5,
54
  False,
55
  ],
56
  [
57
+ "Sophie Dupont, une journaliste française, travaille pour Le Monde, basé au 33 rue des Écoles à Paris. Son numéro d'identification de presse est FR-75649023.",
58
+ "person, profession, organization, address, press ID number",
59
+ 0.5,
60
  False,
61
  ],
62
  [
63
+ "Manuel Oliveira, um agricultor em Porto, possui uma grande plantação de vinhas na Rua da Estrada, 120. O número de registro agrícola é PT-5678912345.",
64
+ "person, profession, address, agricultural registration number",
65
+ 0.5,
66
  False,
67
  ],
68
  [
69
+ "Elisa Müller, eine Künstlerin aus Berlin, hat ihre neueste Skulptur im öffentlichen Park am Alexanderplatz ausgestellt. Ihre Künstlernummer lautet DE-112233445.",
70
+ "person, profession, location, artist ID number",
71
+ 0.5,
72
  False,
73
  ],
74
  [
75
+ "Federico García, un jugador de fútbol de Sevilla, ha firmado un contrato de tres años con el club Real Betis. Su número de licencia deportiva es ES-9876543210.",
76
+ "person, profession, organization, sports license number",
77
+ 0.5,
78
  False,
79
  ],
80
  [
81
+ "Sarah White, a London-based actress, will be performing in 'Hamlet' at the Globe Theatre located at 21 New Globe Walk. Her Equity membership number is UK-1234567.",
82
+ "person, profession, location, address, membership number",
83
+ 0.5,
84
  False,
85
  ],
86
  [
87
+ "Ricardo Mello, engenheiro civil, trabalha na construção da nova barragem no Rio Douro, Portugal. Seu número de registro profissional é PT-987654321.",
88
+ "person, profession, project location, professional registration number",
89
+ 0.5,
90
  False,
91
  ],
92
+ [
93
+ "Giuseppe Conti, un cliente di Milano, ha fatto un acquisto presso il negozio La Rinascente situato in Piazza Duomo. Il numero della sua carta di credito è IT-4567891234567891.",
94
+ "person, location, address, credit card number",
95
+ 0.5,
96
+ False,
97
+ ]
98
  ]
99
 
100
 
 
151
  '''
152
  from gliner import GLiNER
153
 
154
+ model = GLiNER.from_pretrained("urchade/gliner_multi_pii-v1")
155
 
156
  text = """
157
+ Harilala Rasoanaivo, un homme d'affaires local d'Antananarivo, a enregistré une nouvelle société nommée "Rasoanaivo Enterprises" au Lot II M 92 Antohomadinika. Son numéro est le +261 32 22 345 67, et son adresse électronique est harilala.[email protected]. Il a fourni son numéro de sécu 501-02-1234 pour l'enregistrement.
158
  """
159
 
160
+ labels = ["work", "booking number", "personally identifiable information", "driver licence", "person", "book", "full address", "company", "actor", "character", "email", "passport number", "Social Security Number", "phone number"]
 
161
  entities = model.predict_entities(text, labels)
162
 
163
  for entity in entities:
 
167
  )
168
  gr.Code(
169
  """
170
+ Harilala Rasoanaivo => person
171
+ Rasoanaivo Enterprises => company
172
+ Lot II M 92 Antohomadinika => full address
173
+ +261 32 22 345 67 => phone number
174
+ [email protected] => email
175
+ 501-02-1234 => Social Security Number
 
 
 
 
 
 
176
  """
177
  )
178