Skip to content

Commit

Permalink
Merge branch 'attardi-master'
Browse files Browse the repository at this point in the history
  • Loading branch information
mdelhoneux committed Jul 29, 2019
2 parents b4a8391 + bc0e2b1 commit a7632d7
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
2 changes: 1 addition & 1 deletion barchybrid/src/elmo.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
class ELMo(object):

def __init__(self, elmo_file, gamma=1.0, learn_gamma=False):
print "Reading ELMo embeddings from '%s'" % elmo_file
print("Reading ELMo embeddings from '%s'" % elmo_file)
self.sentence_data = h5py.File(elmo_file, 'r')
self.weights = []

Expand Down
9 changes: 3 additions & 6 deletions barchybrid/src/mstlstm.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,7 @@ def Predict(self, treebanks, datasplit, options):
if len(test_langs) > 1 and test_embeddings["words"]:
print("External embeddings found for %i words "\
"(out of %i)" % \
(len(test_embeddings["words"]),
len(new_test_words)))
(len(test_embeddings["words"]), len(new_test_words)))

if options.char_emb_size > 0:
new_test_chars = \
Expand All @@ -108,8 +107,7 @@ def Predict(self, treebanks, datasplit, options):
if len(test_langs) > 1 and test_embeddings["chars"]:
print("External embeddings found for %i chars "\
"(out of %i)" % \
(len(test_embeddings["chars"]),
len(new_test_chars)))
(len(test_embeddings["chars"]), len(new_test_chars)))

data = utils.read_conll_dir(treebanks,datasplit,char_map=char_map)
for iSentence, osentence in enumerate(data,1):
Expand All @@ -126,8 +124,7 @@ def Predict(self, treebanks, datasplit, options):
## ADD for handling multi-roots problem
rootHead = [head for head in heads if head==0]
if len(rootHead) != 1:
print("it has multi-root, changing it for heading first root\
for other roots")
print("it has multi-root, changing it for heading first root for other roots")
rootHead = [seq for seq, head in enumerate(heads) if head == 0]
for seq in rootHead[1:]:heads[seq] = rootHead[0]
## finish to multi-roots
Expand Down
2 changes: 1 addition & 1 deletion barchybrid/src/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ def run(experiment,options):

params = os.path.join(experiment.modeldir,options.params)
print('Reading params from ' + params)
with open(params, 'r') as paramsfp:
with open(params, 'rb') as paramsfp:
stored_vocab, stored_opt = pickle.load(paramsfp)

# we need to update/add certain options based on new user input
Expand Down

0 comments on commit a7632d7

Please sign in to comment.