Skip to content
Snippets Groups Projects
Commit b522742d authored by piotrmp's avatar piotrmp
Browse files

Tweaks in the evaluation script.

parent 0580d103
No related merge requests found
""" """
Evaluation of available model by comparing to UD gold standard Evaluation of available models by comparing to UD gold standard
""" """
from pathlib import Path from pathlib import Path
...@@ -10,8 +10,8 @@ from lambo.segmenter.lambo import Lambo ...@@ -10,8 +10,8 @@ from lambo.segmenter.lambo import Lambo
from lambo.segmenter.spacy import Spacy_segmenter from lambo.segmenter.spacy import Spacy_segmenter
if __name__ == '__main__': if __name__ == '__main__':
modelpath = Path.home() / 'PATH-TO/models/vanilla/' modelpath = Path.home() / 'PATH-TO/models/full211-s/'
modelPpath = Path.home() / 'PATH-TO/models/full' modelPpath = Path.home() / 'PATH-TO/models/full213-withunk/'
tmp_path = Path.home() / 'PATH-TO/out/tmp.conllu' tmp_path = Path.home() / 'PATH-TO/out/tmp.conllu'
treebanks = [line.split(' ')[0] for line in treebanks = [line.split(' ')[0] for line in
...@@ -22,19 +22,19 @@ if __name__ == '__main__': ...@@ -22,19 +22,19 @@ if __name__ == '__main__':
# Load spaCy segmenter as baseline # Load spaCy segmenter as baseline
spacy = Spacy_segmenter() spacy = Spacy_segmenter()
segmenters = {'spaCy': spacy, 'LAMBO': None, 'LAMBO pretrained': None} segmenters = {'spaCy': spacy, 'LAMBO': None, 'LAMBO modified': None}
print('Treebank\tMeasure (F1)\t' + '\t'.join(segmenters)) print('Treebank\tMeasure (F1)\t' + '\t'.join(segmenters))
for treebank in treebanks: for treebank in treebanks:
# Load LAMBO segmenter # Load LAMBO segmenter
lambo = Lambo.from_path(modelpath, treebank) lambo = Lambo.from_path(modelpath, treebank)
# Load pretrained LAMBO segmenter # Load modified LAMBO segmenter
lamboP = Lambo.from_path(modelPpath, treebank) lamboP = Lambo.from_path(modelPpath, treebank)
segmenters['LAMBO'] = lambo segmenters['LAMBO'] = lambo
segmenters['LAMBO pretrained'] = lamboP segmenters['LAMBO modified'] = lamboP
data_path = Path.home() / 'data' / 'lambo' / 'ud-treebanks-v2.9' / treebank data_path = Path.home() / 'data' / 'lambo' / 'ud-treebanks-v2.11' / treebank
text_file = list(data_path.glob('*-ud-test.txt')) text_file = list(data_path.glob('*-ud-test.txt'))
if len(text_file) != 1: if len(text_file) != 1:
continue continue
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment