Skip to content

Commit

Permalink
Merge branch 'master' of origin
Browse files Browse the repository at this point in the history
  • Loading branch information
sebschu authored and Stanford NLP committed Apr 28, 2015
1 parent 2352624 commit 3cc3604
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 4 deletions.
Expand Up @@ -64,6 +64,10 @@ public class ClauseSplitterSearchProblem {
add("clone_nsubj");
add("simple");
}});
put("csubj", new ArrayList<String>() {{
add("clone_dobj");
add("simple");
}});
}});

/**
Expand Down
2 changes: 1 addition & 1 deletion src/edu/stanford/nlp/naturalli/OpenIE.java
Expand Up @@ -65,7 +65,7 @@ private static enum OutputFormat { REVERB, OLLIE, DEFAULT }
private boolean noModel = false;

@Execution.Option(name="splitter.threshold", gloss="The minimum threshold for accepting a clause.")
private double splitterThreshold = 0.5;
private double splitterThreshold = 0.1;

@Execution.Option(name="max_entailments_per_clause", gloss="The maximum number of entailments allowed per sentence of input.")
private int entailmentsPerSentence = 100;
Expand Down
19 changes: 17 additions & 2 deletions src/edu/stanford/nlp/naturalli/RelationTripleSegmenter.java
Expand Up @@ -306,12 +306,14 @@ public List<RelationTriple> extract(SemanticGraph parse, List<CoreLabel> tokens)
/** A set of valid arcs denoting a subject entity we are interested in */
private final Set<String> VALID_SUBJECT_ARCS = Collections.unmodifiableSet(new HashSet<String>(){{
add("amod"); add("compound"); add("aux"); add("nummod"); add("nmod:poss"); add("nmod:tmod"); add("expl");
add("nsubj");
}});

/** A set of valid arcs denoting an object entity we are interested in */
private final Set<String> VALID_OBJECT_ARCS = Collections.unmodifiableSet(new HashSet<String>(){{
add("amod"); add("compound"); add("aux"); add("nummod"); add("nmod"); add("nsubj"); add("nmod:*"); add("nmod:poss");
add("nmod:tmod"); add("conj:and"); add("advmod"); add("acl"); add("advcl");
add("nmod:tmod"); add("conj:and"); add("advmod"); add("acl");
// add("advcl"); // Born in Hawaii, Obama is a US citizen; citizen -advcl-> Born.
}});

/** A set of valid arcs denoting an entity we are interested in */
Expand Down Expand Up @@ -561,8 +563,21 @@ public Optional<RelationTriple> segment(SemanticGraph parse, Optional<Double> co
objNoopArc = Optional.ofNullable(m.getRelnString("objIgnored"));
}

// Find the subject
// By default, this is just the subject node; but, occasionally we want to follow a
// csubj clause to find the real subject.
IndexedWord subject = m.getNode("subject");
/*
if (parse.outDegree(subject) == 1) {
SemanticGraphEdge edge = parse.outgoingEdgeIterator(subject).next();
if (edge.getRelation().toString().contains("subj")) {
subject = edge.getDependent();
}
}
*/

// Subject+Object
Optional<List<CoreLabel>> subjectSpan = getValidSubjectChunk(parse, m.getNode("subject"), subjNoopArc);
Optional<List<CoreLabel>> subjectSpan = getValidSubjectChunk(parse, subject, subjNoopArc);
Optional<List<CoreLabel>> objectSpan = getValidObjectChunk(parse, object, objNoopArc);
// Create relation
if (subjectSpan.isPresent() && objectSpan.isPresent() &&
Expand Down
Expand Up @@ -4,7 +4,6 @@
import edu.stanford.nlp.international.Language;
import edu.stanford.nlp.ling.CoreLabel;
import edu.stanford.nlp.ling.IndexedWord;
import edu.stanford.nlp.naturalli.RelationTripleSegmenter;
import edu.stanford.nlp.semgraph.SemanticGraph;
import edu.stanford.nlp.trees.GrammaticalRelation;
import junit.framework.TestCase;
Expand Down Expand Up @@ -221,6 +220,17 @@ public void testCatsAreCute() {
assertEquals("1.0\tcats\tare\tcute", extraction.get().toString());
}

public void testPropagateCSubj() {
Optional<RelationTriple> extraction = mkExtraction(
"1\ttruffles\t2\tnsubj\n" +
"2\tpicked\t4\tcsubj\n" +
"3\tare\t4\tcop\n" +
"4\ttasty\t0\troot\n"
);
assertTrue("No extraction for sentence!", extraction.isPresent());
assertEquals("1.0\ttruffles picked\tare\ttasty", extraction.get().toString());
}

public void testHeWasInaugurated() {
Optional<RelationTriple> extraction = mkExtraction(
"1\the\t3\tnsubjpass\n" +
Expand Down

0 comments on commit 3cc3604

Please sign in to comment.