Skip to content

Commit

Permalink
fixed error message that came from shared task setup + parser info pa…
Browse files Browse the repository at this point in the history
…ssing
  • Loading branch information
mdelhoneux committed Aug 28, 2017
1 parent aaa789d commit 2dfe83f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 29 deletions.
35 changes: 9 additions & 26 deletions barchybrid/src/options_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ def __init__(self,options):
--usehead (you can use multiple)")
#the diff between two is one is r/l/most child / the other is
#element in the sentence
#paper:
#Eli's paper:
#extended feature set
# rightmost and leftmost modifiers of s0, s1 and s2 + leftmost
# modifier of b0
Expand All @@ -32,13 +32,9 @@ def __init__(self,options):
self.conllu = (os.path.splitext(options.conll_dev.lower())[1] == '.conllu')
self.treebank = utils.Treebank(options.conll_train, \
options.conll_dev, options.conll_test)
#this contains bullshit if I don't specify stuff...
self.treebank.iso_id = None
prepare_data(self.treebank, options.output,\
options,self.conllu)

else:
#different models for all the languages
self.conllu = True
language_list = utils.parse_list_arg(options.include)
json_treebanks = utils.conll_dir_to_list(language_list,options.datadir,options.shared_task,
Expand All @@ -50,21 +46,17 @@ def __init__(self,options):
language.modelDir= "%s/%s"%(options.modelDir,language.iso_id)
model = "%s/%s"%(language.modelDir,options.model)
if options.predictFlag and not os.path.exists(model):
for otherl in json_treebanks:
if otherl.lcode == language.lcode:
if otherl.lcode == otherl.iso_id:
language.modelDir = "%s/%s"%(options.modelDir,otherl.iso_id)
if not options.shared_task:
raise Exception("Model not found. Path tried: %s"%model)
else:
#find model for the language in question
for otherl in json_treebanks:
if otherl.lcode == language.lcode:
if otherl.lcode == otherl.iso_id:
language.modelDir = "%s/%s"%(options.modelDir,otherl.iso_id)

if not os.path.exists(language.outdir):
os.mkdir(language.outdir)
try:
prepare_data(language, language.outdir, options,\
self.conllu)
except Exception as e:
message = "Failing on %s. Error: %s \n"%(language.iso_id,str(e))
print message
sys.stderr.write(message)
language.removeme =True

for language in self.languages:
if language.removeme:
Expand All @@ -79,12 +71,3 @@ def __init__(self,options):
#this is now useless
options.drop_proj = False


def prepare_data(treebank,outdir,options,conllu=True):
if conllu:
ext = '.conllu'
else:
ext = '.conll'
if not options.shared_task:
treebank.dev_gold = treebank.devfile
treebank.test_gold = treebank.testfile
6 changes: 3 additions & 3 deletions barchybrid/src/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,10 @@ def run(om,options,i):
else: #if predict - so
params = os.path.join(modelDir,options.params)
with open(params, 'r') as paramsfp:
words, w2i, pos, rels, cpos, langs, stored_opt, ch= pickle.load(paramsfp)
words, w2i, pos,rels, cpos,langs, stored_opt, ch= pickle.load(paramsfp)

parser = ArcHybridLSTM(words, pos, rels, cpos, langs,
w2i, ch, stored_opt)
parser = ArcHybridLSTM(words, pos, rels, cpos, langs, w2i,
ch, stored_opt)
model = os.path.join(modelDir, options.model)
parser.Load(model)

Expand Down
2 changes: 2 additions & 0 deletions barchybrid/src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(self,treebank_info,location, shared_task=False, shared_task_data_di
self.testfile = location + self.iso_id + '.txt'
if not os.path.exists(self.testfile):
self.testfile = shared_task_data_dir + self.iso_id + '.conllu'
self.dev_gold = shared_task_data_dir + self.iso_id + '.conllu'
self.test_gold = shared_task_data_dir + self.iso_id + '.conllu'
self.outfilename = treebank_info['outfile']
else:
Expand All @@ -79,6 +80,7 @@ def __init__(self,treebank_info,location, shared_task=False, shared_task_data_di
#TODO: change if using data that has the test sets
self.testfile = files_prefix + "-ud-dev.conllu"
self.test_gold= files_prefix + "-ud-dev.conllu"
self.dev_gold= files_prefix + "-ud-dev.conllu"
self.outfilename = self.iso_id + '.conllu'

class ParseForest:
Expand Down

0 comments on commit 2dfe83f

Please sign in to comment.