mirror of
https://github.com/explosion/spaCy.git
synced 2024-12-26 01:46:28 +03:00
* Fix training under python3
This commit is contained in:
parent
a8bbd7312c
commit
ddc1a5cfe5
|
@ -10,8 +10,6 @@ import codecs
|
||||||
import random
|
import random
|
||||||
|
|
||||||
import plac
|
import plac
|
||||||
import cProfile
|
|
||||||
import pstats
|
|
||||||
import re
|
import re
|
||||||
|
|
||||||
import spacy.util
|
import spacy.util
|
||||||
|
|
|
@ -162,11 +162,11 @@ class English(object):
|
||||||
with open(path.join(data_dir, 'vocab', 'serializer.json'), 'w') as file_:
|
with open(path.join(data_dir, 'vocab', 'serializer.json'), 'w') as file_:
|
||||||
file_.write(
|
file_.write(
|
||||||
json.dumps([
|
json.dumps([
|
||||||
(TAG, self.tagger.freqs[TAG].items()),
|
(TAG, list(self.tagger.freqs[TAG].items())),
|
||||||
(DEP, self.parser.moves.freqs[DEP].items()),
|
(DEP, list(self.parser.moves.freqs[DEP].items())),
|
||||||
(ENT_IOB, self.entity.moves.freqs[ENT_IOB].items()),
|
(ENT_IOB, list(self.entity.moves.freqs[ENT_IOB].items())),
|
||||||
(ENT_TYPE, self.entity.moves.freqs[ENT_TYPE].items()),
|
(ENT_TYPE, list(self.entity.moves.freqs[ENT_TYPE].items())),
|
||||||
(HEAD, self.parser.moves.freqs[HEAD].items())]))
|
(HEAD, list(self.parser.moves.freqs[HEAD].items()))]))
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def tags(self):
|
def tags(self):
|
||||||
|
|
|
@ -1,4 +1,6 @@
|
||||||
from __future__ import division
|
from __future__ import division
|
||||||
|
from __future__ import print_function
|
||||||
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from .gold import tags_to_entities
|
from .gold import tags_to_entities
|
||||||
|
|
||||||
|
@ -118,6 +120,6 @@ class Scorer(object):
|
||||||
if verbose:
|
if verbose:
|
||||||
gold_words = [item[1] for item in gold.orig_annot]
|
gold_words = [item[1] for item in gold.orig_annot]
|
||||||
for w_id, h_id, dep in (cand_deps - gold_deps):
|
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):
|
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])
|
||||||
|
|
Loading…
Reference in New Issue
Block a user