From ddc1a5cfe5405c1e80bca91630335731022e8d4d Mon Sep 17 00:00:00 2001 From: Matthew Honnibal Date: Tue, 28 Jul 2015 14:09:30 +0200 Subject: [PATCH] * Fix training under python3 --- bin/parser/train.py | 2 -- spacy/en/__init__.py | 10 +++++----- spacy/scorer.py | 6 ++++-- 3 files changed, 9 insertions(+), 9 deletions(-) diff --git a/bin/parser/train.py b/bin/parser/train.py index eeb5723e9..68217fcb3 100755 --- a/bin/parser/train.py +++ b/bin/parser/train.py @@ -10,8 +10,6 @@ import codecs import random import plac -import cProfile -import pstats import re import spacy.util diff --git a/spacy/en/__init__.py b/spacy/en/__init__.py index 52850ab2c..5bf83a253 100644 --- a/spacy/en/__init__.py +++ b/spacy/en/__init__.py @@ -162,11 +162,11 @@ class English(object): with open(path.join(data_dir, 'vocab', 'serializer.json'), 'w') as file_: file_.write( json.dumps([ - (TAG, self.tagger.freqs[TAG].items()), - (DEP, self.parser.moves.freqs[DEP].items()), - (ENT_IOB, self.entity.moves.freqs[ENT_IOB].items()), - (ENT_TYPE, self.entity.moves.freqs[ENT_TYPE].items()), - (HEAD, self.parser.moves.freqs[HEAD].items())])) + (TAG, list(self.tagger.freqs[TAG].items())), + (DEP, list(self.parser.moves.freqs[DEP].items())), + (ENT_IOB, list(self.entity.moves.freqs[ENT_IOB].items())), + (ENT_TYPE, list(self.entity.moves.freqs[ENT_TYPE].items())), + (HEAD, list(self.parser.moves.freqs[HEAD].items()))])) @property def tags(self): diff --git a/spacy/scorer.py b/spacy/scorer.py index 7172b93a4..8ec3617c6 100644 --- a/spacy/scorer.py +++ b/spacy/scorer.py @@ -1,4 +1,6 @@ from __future__ import division +from __future__ import print_function +from __future__ import unicode_literals from .gold import tags_to_entities @@ -118,6 +120,6 @@ class Scorer(object): if verbose: gold_words = [item[1] for item in gold.orig_annot] for w_id, h_id, dep in (cand_deps - gold_deps): - print 'F', gold_words[w_id], dep, gold_words[h_id] + print('F', gold_words[w_id], dep, gold_words[h_id]) for w_id, h_id, dep in (gold_deps - cand_deps): - print 'M', gold_words[w_id], dep, gold_words[h_id] + print('M', gold_words[w_id], dep, gold_words[h_id])