* Fix training under python3

This commit is contained in:
Matthew Honnibal 2015-07-28 14:09:30 +02:00
parent a8bbd7312c
commit ddc1a5cfe5
3 changed files with 9 additions and 9 deletions

View File

@ -10,8 +10,6 @@ import codecs
import random
import plac
import cProfile
import pstats
import re
import spacy.util

View File

@ -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):

View File

@ -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])