Skip to content

Commit

Permalink
Partial fix for '(QP up to ...)' as reported in #1363
Browse files Browse the repository at this point in the history
  • Loading branch information
AngledLuffa committed Jul 8, 2023
1 parent 5c57fde commit 8c46648
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
2 changes: 1 addition & 1 deletion src/edu/stanford/nlp/trees/CoordinationTransformer.java
Expand Up @@ -686,7 +686,7 @@ private static Tree findCCparent(Tree t, Tree root) {
TregexPattern.compile("@WHADVP < ((WRB=node1 < /^(?i:how)$/) $+ (VB=node2 < /^(?i)come$/))"), //how come
TregexPattern.compile("@VP < ((VBD=node1 < had|'d) $+ (@PRT|ADVP=node2 <: (RBR < /^(?i)better$/)))"), //had better
TregexPattern.compile("@QP|XS < ((JJR|RBR|IN=node1 < /^(?i)(more|less)$/) $+ (IN=node2 < /^(?i)than$/))"), //more/less than
TregexPattern.compile("@QP < ((JJR|RBR|IN=node1 < /^(?i)up$/) $+ (IN|TO=node2 < /^(?i)to$/))"), //up to
TregexPattern.compile("@QP < ((JJR|RBR|RP|IN=node1 < /^(?i)up$/) $+ (IN|TO=node2 < /^(?i)to$/))"), //up to
TregexPattern.compile("@S|SQ|VP|ADVP|PP < (@ADVP < ((IN|RB=node1 < /^(?i)at$/) $+ (JJS|RBS=node2 < /^(?i)least$/)) !$+ (RB < /(?i)(once|twice)/))"), //at least

};
Expand Down
10 changes: 9 additions & 1 deletion src/edu/stanford/nlp/trees/EnglishGrammaticalRelations.java
Expand Up @@ -980,7 +980,15 @@ private EnglishGrammaticalRelations() {}
public static final GrammaticalRelation QUANTIFIER_MODIFIER =
new GrammaticalRelation(Language.English, "quantmod", "quantifier modifier",
MODIFIER, "QP", tregexCompiler,
"QP < IN|RB|RBR|RBS|PDT|DT|JJ|JJR|JJS|XS=target");
// RP is because sometimes "up" in "up to ___" gets tagged RP in PTB
// this is probably a mistake - generally it is tagged IN
// but sometimes the tagger follows suit
// there are no conflicts elsewhere in the targets of a QP,
// so there should be no need to specifically check for the phrase "up to" for `up_RP`
"QP < IN|RB|RBR|RBS|PDT|DT|JJ|JJR|JJS|XS|RP=target",
// TO is for the "to" in "up to ___"
// TODO: but currently not working for up_IN to_IN foo_CD, since it wants to make TO the head of IN!
"(QP < (TO=target < /^(?i:to)$/) < (__=up < /^(?i:up)$/)) : (=up $++ =target)");


/**
Expand Down
Expand Up @@ -1066,6 +1066,8 @@ private UniversalEnglishGrammaticalRelations() {}
"/^(?:VP|ADJP|JJP|WHADJP|SQ?|SBARQ?|SINV|XS|RRC|(?:WH)?NP(?:-TMP|-ADV)?)$/ < (RB|RBR|RBS|WRB|ADVP|WHADVP=target !< " + ETC_PAT + " [!<+(/ADVP/) (@ADVP < (IN < /(?i:at)/)) | !<+(/ADVP/) (@ADVP < NP)] )",
"QP < IN|RB|RBR|RBS|PDT|DT|JJ|JJR|JJS|XS=target", //quantmod relation in original SD
"QP < (MWE=target < (JJR|RBR|IN < /^(?i)(more|less)$/) < (IN < /^(?i)than$/))", //more than / less than
// TODO: could condense with the previous rule to save a little time
"QP < (MWE=target < (__ < /^(?i)up$/) < (__ < /^(?i)to$/))", // up to
// avoids adverb conjunctions matching as advmod; added JJ to catch How long
// "!< no" so we can get neg instead for "no foo" when no is tagged as RB
// we allow CC|CONJP as long as it is not between the target and the head
Expand Down

0 comments on commit 8c46648

Please sign in to comment.