mirror of https://github.com/explosion/spaCy.git
* Remove unused code in tagger.pyx
This commit is contained in:
parent
8f2f319c57
commit
327383e38a
|
@ -15,9 +15,6 @@ import cython
|
||||||
from thinc.features cimport Feature, count_feats
|
from thinc.features cimport Feature, count_feats
|
||||||
|
|
||||||
|
|
||||||
NULL_TAG = 0
|
|
||||||
|
|
||||||
|
|
||||||
def setup_model_dir(tag_type, tag_names, tag_counts, templates, model_dir):
|
def setup_model_dir(tag_type, tag_names, tag_counts, templates, model_dir):
|
||||||
if path.exists(model_dir):
|
if path.exists(model_dir):
|
||||||
shutil.rmtree(model_dir)
|
shutil.rmtree(model_dir)
|
||||||
|
@ -55,33 +52,6 @@ def train(train_sents, model_dir, nr_iter=10):
|
||||||
tagger.model.dump(path.join(model_dir, 'model'))
|
tagger.model.dump(path.join(model_dir, 'model'))
|
||||||
|
|
||||||
|
|
||||||
cdef object _get_gold_pos(i, golds):
|
|
||||||
if golds[i] == 0:
|
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return [golds[i]]
|
|
||||||
|
|
||||||
|
|
||||||
cdef object _get_gold_ner(i, golds, int* ner):
|
|
||||||
if golds[i] == 0:
|
|
||||||
return None
|
|
||||||
else:
|
|
||||||
return [golds[i]]
|
|
||||||
|
|
||||||
|
|
||||||
def evaluate(tagger, sents):
|
|
||||||
n_corr = 0
|
|
||||||
total = 0
|
|
||||||
for tokens, golds in sents:
|
|
||||||
for i, gold in enumerate(golds):
|
|
||||||
guess = tagger.predict(i, tokens)
|
|
||||||
tokens.set_tag(i, tagger.tag_type, guess)
|
|
||||||
if gold != NULL_TAG:
|
|
||||||
total += 1
|
|
||||||
n_corr += guess == gold
|
|
||||||
return n_corr / total
|
|
||||||
|
|
||||||
|
|
||||||
cdef class Tagger:
|
cdef class Tagger:
|
||||||
"""Assign part-of-speech, named entity or supersense tags, using greedy
|
"""Assign part-of-speech, named entity or supersense tags, using greedy
|
||||||
decoding. The tagger reads its model and configuration from disk.
|
decoding. The tagger reads its model and configuration from disk.
|
||||||
|
|
Loading…
Reference in New Issue