initial model commit
Browse files
README.md
CHANGED
|
@@ -28,10 +28,10 @@ from flair.data import Sentence
|
|
| 28 |
from flair.models import SequenceTagger
|
| 29 |
|
| 30 |
# load tagger
|
| 31 |
-
tagger = SequenceTagger.load("flair/
|
| 32 |
|
| 33 |
# make example sentence
|
| 34 |
-
sentence = Sentence("
|
| 35 |
|
| 36 |
# predict NER tags
|
| 37 |
tagger.predict(sentence)
|
|
@@ -40,23 +40,20 @@ tagger.predict(sentence)
|
|
| 40 |
print(sentence)
|
| 41 |
|
| 42 |
# print predicted NER spans
|
| 43 |
-
print('The following
|
| 44 |
# iterate over entities and print
|
| 45 |
-
for entity in sentence.get_spans('
|
| 46 |
print(entity)
|
| 47 |
|
| 48 |
```
|
| 49 |
|
| 50 |
This yields the following output:
|
| 51 |
```
|
| 52 |
-
Span [
|
| 53 |
-
Span [
|
| 54 |
-
Span [3]: "Berlin" [− Labels: NNP (0.9999)]
|
| 55 |
-
Span [4]: "." [− Labels: . (1.0)]
|
| 56 |
-
|
| 57 |
```
|
| 58 |
|
| 59 |
-
So, the word "*
|
| 60 |
|
| 61 |
|
| 62 |
---
|
|
@@ -75,7 +72,6 @@ corpus = ColumnCorpus(
|
|
| 75 |
"resources/tasks/srl", column_format={1: "text", 11: "frame"}
|
| 76 |
)
|
| 77 |
|
| 78 |
-
|
| 79 |
# 2. what tag do we want to predict?
|
| 80 |
tag_type = 'frame'
|
| 81 |
|
|
@@ -87,9 +83,9 @@ embedding_types = [
|
|
| 87 |
|
| 88 |
BytePairEmbeddings("en"),
|
| 89 |
|
| 90 |
-
FlairEmbeddings("news-forward
|
| 91 |
|
| 92 |
-
FlairEmbeddings("news-backward
|
| 93 |
]
|
| 94 |
|
| 95 |
# embedding stack consists of Flair and GloVe embeddings
|
|
|
|
| 28 |
from flair.models import SequenceTagger
|
| 29 |
|
| 30 |
# load tagger
|
| 31 |
+
tagger = SequenceTagger.load("flair/frame-english")
|
| 32 |
|
| 33 |
# make example sentence
|
| 34 |
+
sentence = Sentence("George returned to Berlin to return his hat.")
|
| 35 |
|
| 36 |
# predict NER tags
|
| 37 |
tagger.predict(sentence)
|
|
|
|
| 40 |
print(sentence)
|
| 41 |
|
| 42 |
# print predicted NER spans
|
| 43 |
+
print('The following frame tags are found:')
|
| 44 |
# iterate over entities and print
|
| 45 |
+
for entity in sentence.get_spans('frame'):
|
| 46 |
print(entity)
|
| 47 |
|
| 48 |
```
|
| 49 |
|
| 50 |
This yields the following output:
|
| 51 |
```
|
| 52 |
+
Span [2]: "returned" [− Labels: return.01 (0.9951)]
|
| 53 |
+
Span [6]: "return" [− Labels: return.02 (0.6361)]
|
|
|
|
|
|
|
|
|
|
| 54 |
```
|
| 55 |
|
| 56 |
+
So, the word "*returned*" is labeled as **return.01** (as in *go back somewhere*) while "*return*" is labeled as **return.02** (as in *give back something*) in the sentence "*George returned to Berlin to return his hat*".
|
| 57 |
|
| 58 |
|
| 59 |
---
|
|
|
|
| 72 |
"resources/tasks/srl", column_format={1: "text", 11: "frame"}
|
| 73 |
)
|
| 74 |
|
|
|
|
| 75 |
# 2. what tag do we want to predict?
|
| 76 |
tag_type = 'frame'
|
| 77 |
|
|
|
|
| 83 |
|
| 84 |
BytePairEmbeddings("en"),
|
| 85 |
|
| 86 |
+
FlairEmbeddings("news-forward"),
|
| 87 |
|
| 88 |
+
FlairEmbeddings("news-backward"),
|
| 89 |
]
|
| 90 |
|
| 91 |
# embedding stack consists of Flair and GloVe embeddings
|