PooryaPiroozfar
commited on
Commit
•
c2fe14b
1
Parent(s):
ee77e3c
Update README.md
Browse files
README.md
CHANGED
@@ -43,17 +43,31 @@ Requires: **[Flair](https://github.com/flairNLP/flair/)** (`pip install flair`)
|
|
43 |
```python
|
44 |
from flair.data import Sentence
|
45 |
from flair.models import SequenceTagger
|
|
|
46 |
# load tagger
|
47 |
-
tagger = SequenceTagger.load("PooryaPiroozfar/
|
|
|
48 |
# make example sentence
|
49 |
-
sentence = Sentence("
|
|
|
|
|
50 |
tagger.predict(sentence)
|
51 |
-
|
52 |
-
print
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
53 |
```
|
54 |
|
55 |
This yields the following output:
|
56 |
```
|
|
|
|
|
|
|
57 |
|
58 |
```
|
59 |
|
|
|
43 |
```python
|
44 |
from flair.data import Sentence
|
45 |
from flair.models import SequenceTagger
|
46 |
+
|
47 |
# load tagger
|
48 |
+
tagger = SequenceTagger.load("PooryaPiroozfar/Flair-Persian-NER")
|
49 |
+
|
50 |
# make example sentence
|
51 |
+
sentence = Sentence("اولین نمایش این فیلمها دوشنبه 13 اردیبهشت و از ساعت 21 در موزه سینماست.")
|
52 |
+
|
53 |
+
# predict NER tags
|
54 |
tagger.predict(sentence)
|
55 |
+
|
56 |
+
# print sentence
|
57 |
+
print(sentence)
|
58 |
+
|
59 |
+
# print predicted NER spans
|
60 |
+
print('The following NER tags are found:')
|
61 |
+
# iterate over entities and print
|
62 |
+
for entity in sentence.get_spans('ner'):
|
63 |
+
print(entity)
|
64 |
```
|
65 |
|
66 |
This yields the following output:
|
67 |
```
|
68 |
+
Span[4:7]: "دوشنبه 13 اردیبهشت" → TIM (0.8885)
|
69 |
+
Span[9:11]: "ساعت 21" → TIM (1.0)
|
70 |
+
Span[12:14]: "موزه سینماست" → LOC (1.0)
|
71 |
|
72 |
```
|
73 |
|