-
Notifications
You must be signed in to change notification settings - Fork 0
/
test.py
26 lines (20 loc) · 889 Bytes
/
test.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
from flair.data import Sentence
from flair.models import SequenceTagger
from tqdm import tqdm
import json
from flair.data import Corpus
from flair.datasets import ColumnCorpus
from flair.embeddings import TransformerWordEmbeddings
from flair.models import SequenceTagger
from flair.trainers import ModelTrainer
from seqeval.metrics import classification_report
columns = {0: 'text', 3: 'ner'}
corpus: Corpus = ColumnCorpus('data/', columns,
train_file='bn_train.txt',
dev_file='bn_dev.txt',
test_file='bn_test.txt'
)
# load the model you trained
model_mean = SequenceTagger.load('/model/best-model.pt')
result_mean = model_mean.evaluate(corpus.test, gold_label_type='ner',mini_batch_size=4, out_path=f"/model/test.tsv")
print(result_mean)