/** * This gets used by GrammaticalStructureFactory (by reflection). DON'T DELETE. * * @param t Parse tree to make grammatical structure from * @param puncFilter Filter to remove punctuation dependencies */ public EnglishGrammaticalStructure(Tree t, Predicate<String> puncFilter) { this(t, puncFilter, new SemanticHeadFinder(true)); }
if (hasVerbalAuxiliary(kids, verbalAuxiliaries, true) || hasPassiveProgressiveAuxiliary(kids)) { if (hasVerbalAuxiliary(kids, copulars, true)) { tmpFilteredChildren = ArrayUtils.filter(kids, REMOVE_TMP_AND_ADV); Tree pti = traverseLocate(tmpFilteredChildren, how, false); if (DEBUG) { log.info("Determined head (case 1) for " + t.value() + " is: " + pti); if (hasVerbalAuxiliary(kids, copulars, false) && ! isExistential(t, parent) && ! isWHQ(t, parent)) { String[] how; if (motherCat.equals("SQ")) { tmpFilteredChildren = ArrayUtils.filter(kids, REMOVE_TMP_AND_ADV); Tree pti = traverseLocate(tmpFilteredChildren, how, false);
/** Create a SemanticHeadFinder. * * @param tlp The TreebankLanguagePack, used by the superclass to get basic * category of constituents. * @param noCopulaHead If true, a copular verb (a form of be) * is not treated as head when it has an AdjP or NP complement. If false, * a copula verb is still always treated as a head. But it will still * be treated as an auxiliary in periphrastic tenses with a VP complement. */ public SemanticHeadFinder(TreebankLanguagePack tlp, boolean noCopulaHead) { super(tlp); // TODO: reverse the polarity of noCopulaHead this.makeCopulaHead = !noCopulaHead; ruleChanges(); // make a distinction between auxiliaries and copula verbs to // get the NP has semantic head in sentences like "Bill is an honest man". (Added "sha" for "shan't" May 2009 verbalAuxiliaries = Generics.newHashSet(Arrays.asList(auxiliaries)); passiveAuxiliaries = Generics.newHashSet(Arrays.asList(EnglishPatterns.beGetVerbs)); //copula verbs having an NP complement copulars = Generics.newHashSet(); if (noCopulaHead) { copulars.addAll(Arrays.asList(EnglishPatterns.copularVerbs)); } verbalTags = Generics.newHashSet(Arrays.asList(verbTags)); unambiguousAuxiliaryTags = Generics.newHashSet(Arrays.asList(unambiguousAuxTags)); }
while (newHeadIdx >= 0 && shouldSkip(daughterTrees[newHeadIdx], origWasInterjection)) { newHeadIdx--; int nextHead = findPreviousHead(newHeadIdx, daughterTrees, origWasInterjection); if (nextHead < 0) { break;
log.info(" checking in " + kid); if (isVerbalAuxiliary(kid, passiveAuxiliaries, false)) { foundPassiveAux = true; } else if (kid.isPhrasal()) { log.info("hasPassiveAuxiliary found (VP (VP)), recursing"); foundParticipleInVp = vpContainsParticiple(kidkid); } else if (("CONJP".equals(catcat) || "PRN".equals(catcat)) && foundParticipleInVp) { // occasionally get PRN in CONJ-like structures foundPassiveVP = true;
/** * Returns true if this tree is a preterminal that is a verbal auxiliary. * * @param t A tree to examine for being an auxiliary. * @return Whether it is a verbal auxiliary (be, do, have, get) */ public boolean isVerbalAuxiliary(Tree t) { return isVerbalAuxiliary(t, verbalAuxiliaries, true); }
/** * Reinserted so samples.GetSubcats compiles ... should rework if * this is going to stay. * * @param t A tree to examine for being an auxiliary. * @return Whether it is a verbal auxiliary (be, do, have, get) */ public boolean isVerbalAuxiliary(Tree t) { Tree[] trees = new Tree[]{t}; return hasVerbalAuxiliary(trees, verbalAuxiliaries); }
System.err.println("hasPassiveAuxiliary found (VP (VP)), recursing"); foundParticipleInVp = vpContainsParticiple(kidkid); } else if (("CONJP".equals(catcat) || "PRN".equals(catcat)) && foundParticipleInVp) { // occasionally get PRN in CONJ-like structures foundPassiveVP = true;
System.err.println(" checking in " + kid); if (isVerbalAuxiliary(kid, passiveAuxiliaries, false)) { foundPassiveAux = true; } else if (kid.isPhrasal()) { System.err.println("hasPassiveAuxiliary found (VP (VP)), recursing"); foundParticipleInVp = vpContainsParticiple(kidkid); } else if (("CONJP".equals(catcat) || "PRN".equals(catcat)) && foundParticipleInVp) { // occasionally get PRN in CONJ-like structures foundPassiveVP = true;
while (newHeadIdx >= 0 && shouldSkip(daughterTrees[newHeadIdx], origWasInterjection)) { newHeadIdx--; int nextHead = findPreviousHead(newHeadIdx, daughterTrees, origWasInterjection); if (nextHead < 0) { break;
/** This looks to see whether any of the children is a preterminal headed by a word * which is within the set verbalSet (which in practice is either * auxiliary or copula verbs). It only returns true if it's a preterminal head, since * you don't want to pick things up in phrasal daughters. That is an error. * * @param kids The child trees * @param verbalSet The set of words * @param allowTagOnlyMatch If true, it's sufficient to match on an unambiguous auxiliary tag. * Make true iff verbalSet is "all auxiliaries" * @return Returns true if one of the child trees is a preterminal verb headed * by a word in verbalSet */ private boolean hasVerbalAuxiliary(Tree[] kids, Set<String> verbalSet, boolean allowTagOnlyMatch) { if (DEBUG) { log.info("Checking for verbal auxiliary"); } for (Tree kid : kids) { if (DEBUG) { log.info(" checking in " + kid); } if (isVerbalAuxiliary(kid, verbalSet, allowTagOnlyMatch)) { return true; } } if (DEBUG) { log.info("hasVerbalAuxiliary returns false"); } return false; }
if (hasVerbalAuxiliary(kids, verbalAuxiliaries) || hasPassiveProgressiveAuxiliary(kids, passiveAuxiliaries)) { Tree pti = traverseLocate(kids, how, false); if (DEBUG) { System.err.println("Determined head (case 1) for " + t.value() + " is: " + pti); if (hasVerbalAuxiliary(kids, copulars) && ! isExistential(t, parent) && ! isWHQ(t, parent)) { String[] how; if (motherCat.equals("SQ")) { how = new String[]{"left", "VP", "ADJP", "NP", "WHADJP", "WHNP"}; Tree pti = traverseLocate(kids, how, false);
public RuleBasedCorefMentionFinder(boolean allowReparsing) { SieveCoreferenceSystem.logger.fine("Using SEMANTIC HEAD FINDER!!!!!!!!!!!!!!!!!!!"); this.headFinder = new SemanticHeadFinder(); this.allowReparsing = allowReparsing; }
log.info(" checking in " + kid); if (isVerbalAuxiliary(kid, passiveAuxiliaries, false)) { foundPassiveAux = true; } else if (kid.isPhrasal()) { log.info("hasPassiveAuxiliary found (VP (VP)), recursing"); foundParticipleInVp = vpContainsParticiple(kidkid); } else if (("CONJP".equals(catcat) || "PRN".equals(catcat)) && foundParticipleInVp) { // occasionally get PRN in CONJ-like structures foundPassiveVP = true;
while (newHeadIdx >= 0 && shouldSkip(daughterTrees[newHeadIdx], origWasInterjection)) { newHeadIdx--; int nextHead = findPreviousHead(newHeadIdx, daughterTrees, origWasInterjection); if (nextHead < 0) { break;
/** Create a SemanticHeadFinder. * * @param tlp The TreebankLanguagePack, used by the superclass to get basic * category of constituents. * @param cop If true, a copular verb (be, seem, appear, stay, remain, resemble, become) * is not treated as head when it has an AdjP or NP complement. If false, * a copula verb is still always treated as a head. But it will still * be treated as an auxiliary in periphrastic tenses with a VP complement. */ public SemanticHeadFinder(TreebankLanguagePack tlp, boolean cop) { super(tlp); ruleChanges(); // make a distinction between auxiliaries and copula verbs to // get the NP has semantic head in sentences like "Bill is an honest man". (Added "sha" for "shan't" May 2009 verbalAuxiliaries = new HashSet<String>(); verbalAuxiliaries.addAll(Arrays.asList(auxiliaries)); passiveAuxiliaries = new HashSet<String>(); passiveAuxiliaries.addAll(Arrays.asList(beGetVerbs)); //copula verbs having an NP complement copulars = new HashSet<String>(); if (cop) { copulars.addAll(Arrays.asList(copulaVerbs)); } // a few times the apostrophe is missing on "'s" verbalTags = new HashSet<String>(); // include Charniak tags so can do BLLIP right verbalTags.addAll(Arrays.asList(verbTags)); }
/** * Returns true if this tree is a preterminal that is a verbal auxiliary. * * @param t A tree to examine for being an auxiliary. * @return Whether it is a verbal auxiliary (be, do, have, get) */ public boolean isVerbalAuxiliary(Tree t) { return isVerbalAuxiliary(t, verbalAuxiliaries, true); }
if (hasVerbalAuxiliary(kids, verbalAuxiliaries, true) || hasPassiveProgressiveAuxiliary(kids)) { tmpFilteredChildren = ArrayUtils.filter(kids, REMOVE_TMP_AND_ADV); Tree pti = traverseLocate(tmpFilteredChildren, how, false); if (DEBUG) { System.err.println("Determined head (case 1) for " + t.value() + " is: " + pti); if (hasVerbalAuxiliary(kids, copulars, false) && ! isExistential(t, parent) && ! isWHQ(t, parent)) { String[] how; if (motherCat.equals("SQ")) { tmpFilteredChildren = ArrayUtils.filter(kids, REMOVE_TMP_AND_ADV); Tree pti = traverseLocate(tmpFilteredChildren, how, false);
/** {@inheritDoc} */ @Override public HeadFinder typedDependencyHeadFinder() { if (generateOriginalDependencies) { return new SemanticHeadFinder(this, true); } else { return new UniversalSemanticHeadFinder(this, true); } }
log.info(" checking in " + kid); if (isVerbalAuxiliary(kid, passiveAuxiliaries, false)) { foundPassiveAux = true; } else if (kid.isPhrasal()) { log.info("hasPassiveAuxiliary found (VP (VP)), recursing"); foundParticipleInVp = vpContainsParticiple(kidkid); } else if (("CONJP".equals(catcat) || "PRN".equals(catcat)) && foundParticipleInVp) { // occasionally get PRN in CONJ-like structures foundPassiveVP = true;