osiria commited on
Commit
c7df203
1 Parent(s): 6a1036f

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +8 -6
README.md CHANGED
@@ -41,6 +41,7 @@ The model has been first fine-tuned on WikiNER, then focused on the Italian lang
41
 
42
  ```python
43
  from transformers import AutoModelForTokenClassification, AutoTokenizer
 
44
  import re
45
  import string
46
 
@@ -51,26 +52,27 @@ text = "mi chiamo marco rossi, vivo a roma e lavoro per l'agenzia spaziale itali
51
 
52
  for p in string.punctuation:
53
  text = text.replace(p, " " + p + " ")
54
-
55
- ner(text)
 
56
 
57
  [{'entity_group': 'PER',
58
- 'score': 0.9929622,
59
  'word': 'marco rossi',
60
  'start': 9,
61
  'end': 21},
62
  {'entity_group': 'LOC',
63
- 'score': 0.989851,
64
  'word': 'roma',
65
  'start': 31,
66
  'end': 36},
67
  {'entity_group': 'ORG',
68
- 'score': 0.99059105,
69
  'word': 'agenzia spaziale italiana',
70
  'start': 53,
71
  'end': 79},
72
  {'entity_group': 'MISC',
73
- 'score': 0.9247404,
74
  'word': 'missione prisma',
75
  'start': 85,
76
  'end': 101}]
 
41
 
42
  ```python
43
  from transformers import AutoModelForTokenClassification, AutoTokenizer
44
+ from transformers import pipeline
45
  import re
46
  import string
47
 
 
52
 
53
  for p in string.punctuation:
54
  text = text.replace(p, " " + p + " ")
55
+
56
+ ner = pipeline("ner", model=model, tokenizer=tokenizer)
57
+ ner(text, aggregation_strategy="simple")
58
 
59
  [{'entity_group': 'PER',
60
+ 'score': 0.9929623,
61
  'word': 'marco rossi',
62
  'start': 9,
63
  'end': 21},
64
  {'entity_group': 'LOC',
65
+ 'score': 0.9898509,
66
  'word': 'roma',
67
  'start': 31,
68
  'end': 36},
69
  {'entity_group': 'ORG',
70
+ 'score': 0.9905911,
71
  'word': 'agenzia spaziale italiana',
72
  'start': 53,
73
  'end': 79},
74
  {'entity_group': 'MISC',
75
+ 'score': 0.92474234,
76
  'word': 'missione prisma',
77
  'start': 85,
78
  'end': 101}]