From 992559bf9aebc77951c5182cd5e3931cdcebb5cd Mon Sep 17 00:00:00 2001 From: ines Date: Thu, 1 Jun 2017 12:47:18 +0200 Subject: [PATCH] Fix formatting and remove unused imports --- examples/training/train_ner.py | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/examples/training/train_ner.py b/examples/training/train_ner.py index e50e36756..e9ae013d3 100644 --- a/examples/training/train_ner.py +++ b/examples/training/train_ner.py @@ -1,9 +1,8 @@ from __future__ import unicode_literals, print_function -import json -import pathlib + import random -import spacy.lang.en +from spacy.lang.en import English from spacy.gold import GoldParse, biluo_tags_from_offsets @@ -34,7 +33,7 @@ def main(model_dir=None): (len('I like London and '), len('I like London and Berlin'), 'LOC')] ) ] - nlp = spacy.lang.en.English(pipeline=['tensorizer', 'ner']) + nlp = English(pipeline=['tensorizer', 'ner']) get_data = lambda: reformat_train_data(nlp.tokenizer, train_data) optimizer = nlp.begin_training(get_data) for itn in range(100): @@ -55,7 +54,7 @@ def main(model_dir=None): print("Load from", model_dir) nlp = spacy.lang.en.English(pipeline=['tensorizer', 'ner']) nlp.from_disk(model_dir) - for raw_text, _ in train_data: + for raw_text, _ in train_data: doc = nlp(raw_text) for word in doc: print(word.text, word.ent_type_, word.ent_iob_)