Skip to content

Commit

Permalink
Add Optional check
Browse files Browse the repository at this point in the history
  • Loading branch information
Gabor Angeli authored and Stanford NLP committed Mar 5, 2016
1 parent b119acf commit 808b0fa
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 33 deletions.
41 changes: 9 additions & 32 deletions scripts/nndep/Makefile
Original file line number Diff line number Diff line change
@@ -1,29 +1,17 @@
ENGLISH_EMBEDDINGS=/u/nlp/data/depparser/nn/data/embeddings/en-cw.txt
CHINESE_EMBEDDINGS=/u/nlp/data/depparser/nn/data/embeddings/zh-word2vec.txt

DATA_DIR=/u/nlp/data/dependency_treebanks
PTB_STANFORD_TRAIN=/u/nlp/data/dependency_treebanks/PTB/Stanford_3_3_0/train.conll
PTB_STANFORD_DEV=/u/nlp/data/dependency_treebanks/PTB/Stanford_3_3_0/dev.conll
PTB_STANFORD_TEST=/u/nlp/data/dependency_treebanks/PTB/Stanford_3_3_0/test.conll

PTB_STANFORD_TRAIN=${DATA_DIR}/PTB/Stanford_3_3_0/train.conll
PTB_STANFORD_DEV=${DATA_DIR}/PTB/Stanford_3_3_0/dev.conll
PTB_STANFORD_TEST=${DATA_DIR}/PTB/Stanford_3_3_0/test.conll

PTB_CONLL_TRAIN=${DATA_DIR}/PTB/CoNLL/train.conll
PTB_CONLL_DEV=${DATA_DIR}/PTB/CoNLL/dev.conll
PTB_CONLL_TEST=${DATA_DIR}/PTB/CoNLL/test.conll

CTB_CONLL_TRAIN=${DATA_DIR}/CTB/train.gold.conll
CTB_CONLL_DEV=${DATA_DIR}/CTB/dev.gold.conll
CTB_CONLL_TEST=${DATA_DIR}/CTB/test.gold.conll

UD_GERMAN_TRAIN=${DATA_DIR}/UD/1.1/de/de-ud-train-clean.conllu
UD_GERMAN_DEV=${DATA_DIR}/UD/1.1/de/de-ud-dev-clean.conllu
UD_GERMAN_TEST=${DATA_DIR}/UD/1.1/de/de-ud-test-clean.conllu


UD_FRENCH_TRAIN=${DATA_DIR}/UD/1.1/fr/fr-ud-train-clean.conllu
UD_FRENCH_DEV=${DATA_DIR}/UD/1.1/fr/fr-ud-dev-clean.conllu
UD_FRENCH_TEST=${DATA_DIR}/UD/1.1/fr/fr-ud-test-clean.conllu
PTB_CONLL_TRAIN=/u/nlp/data/dependency_treebanks/PTB/CoNLL/train.conll
PTB_CONLL_DEV=/u/nlp/data/dependency_treebanks/PTB/CoNLL/dev.conll
PTB_CONLL_TEST=/u/nlp/data/dependency_treebanks/PTB/CoNLL/test.conll

CTB_CONLL_TRAIN=/u/nlp/data/dependency_treebanks/CTB/train.gold.conll
CTB_CONLL_DEV=/u/nlp/data/dependency_treebanks/CTB/dev.gold.conll
CTB_CONLL_TEST=/u/nlp/data/dependency_treebanks/CTB/test.gold.conll

PTB_Stanford:
java edu.stanford.nlp.parser.nndep.DependencyParser -props nndep.properties -trainFile $(PTB_STANFORD_TRAIN) -devFile $(PTB_STANFORD_DEV) -embedFile $(ENGLISH_EMBEDDINGS) -model $@.txt.gz > $@.log 2>&1
Expand All @@ -41,14 +29,3 @@ CTB_CoNLL:
java edu.stanford.nlp.parser.nndep.DependencyParser -props nndep.properties -trainFile $(CTB_CONLL_TRAIN) -language Chinese -devFile $(CTB_CONLL_DEV) -embedFile $(CHINESE_EMBEDDINGS) -model $@.txt.gz >> $@.log 2>&1
java edu.stanford.nlp.parser.nndep.DependencyParser -testFile $(CTB_CONLL_DEV) -language Chinese -model $@.txt.gz -outFile $@.out.dev >> $@.log 2>&1
java edu.stanford.nlp.parser.nndep.DependencyParser -testFile $(CTB_CONLL_TEST) -language Chinese -model $@.txt.gz -outFile $@.out.test >> $@.log 2>&1

UD_GERMAN:
java edu.stanford.nlp.parser.nndep.DependencyParser -props nndep.properties -trainFile $(UD_GERMAN_TRAIN) -language German -devFile $(UD_GERMAN_DEV) -model $@.txt.gz >> $@.log 2>&1
java edu.stanford.nlp.parser.nndep.DependencyParser -testFile $(UD_GERMAN_DEV) -language German -model $@.txt.gz -outFile $@.out.dev >> $@.log 2>&1
java edu.stanford.nlp.parser.nndep.DependencyParser -testFile $(UD_GERMAN_TEST) -language German -model $@.txt.gz -outFile $@.out.test >> $@.log 2>&1

UD_FRENCH:
java edu.stanford.nlp.parser.nndep.DependencyParser -props nndep.properties -trainFile $(UD_FRENCH_TRAIN) -language German -devFile $(UD_FRENCH_DEV) -model $@.txt.gz >> $@.log 2>&1
java edu.stanford.nlp.parser.nndep.DependencyParser -testFile $(UD_FRENCH_DEV) -language French -model $@.txt.gz -outFile $@.out.dev >> $@.log 2>&1
java edu.stanford.nlp.parser.nndep.DependencyParser -testFile $(UD_FRENCH_TEST) -language French -model $@.txt.gz -outFile $@.out.test >> $@.log 2>&1

4 changes: 3 additions & 1 deletion src/edu/stanford/nlp/naturalli/RelationTripleSegmenter.java
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,9 @@ public List<RelationTriple> extract(SemanticGraph parse, List<CoreLabel> tokens)
}
List<IndexedWord> prepChunk = Collections.EMPTY_LIST;
if (prepWord != null && !expected.equals("tmod")) {
prepChunk = getValidChunk(parse, prepWord, Collections.singleton("mwe"), Optional.empty(), true).get();
Optional<List<IndexedWord>> optionalPrepChunk = getValidChunk(parse, prepWord, Collections.singleton("mwe"), Optional.empty(), true);
if (!optionalPrepChunk.isPresent()) { continue; }
prepChunk = optionalPrepChunk.get();
Collections.sort(prepChunk, (a, b) -> {
double val = a.pseudoPosition() - b.pseudoPosition();
if (val < 0) { return -1; }
Expand Down

0 comments on commit 808b0fa

Please sign in to comment.