List of usage examples for edu.stanford.nlp.trees EnglishGrammaticalRelations POSSESSION_MODIFIER
GrammaticalRelation POSSESSION_MODIFIER
To view the source code for edu.stanford.nlp.trees EnglishGrammaticalRelations POSSESSION_MODIFIER.
Click Source Link
Examples:
From source file:knu.univ.lingvo.coref.Mention.java
License:Open Source License
public String getRelation() { if (headIndexedWord == null) return null; if (dependency.getRoots().isEmpty()) return null; // root relation if (dependency.getFirstRoot().equals(headIndexedWord)) return "root"; if (!dependency.vertexSet().contains(dependency.getParent(headIndexedWord))) return null; GrammaticalRelation relation = dependency.reln(dependency.getParent(headIndexedWord), headIndexedWord); // adjunct relations if (relation.toString().startsWith("prep") || relation == EnglishGrammaticalRelations.PREPOSITIONAL_OBJECT || relation == EnglishGrammaticalRelations.TEMPORAL_MODIFIER || relation == EnglishGrammaticalRelations.ADV_CLAUSE_MODIFIER || relation == EnglishGrammaticalRelations.ADVERBIAL_MODIFIER || relation == EnglishGrammaticalRelations.PREPOSITIONAL_COMPLEMENT) return "adjunct"; // subject relations if (relation == EnglishGrammaticalRelations.NOMINAL_SUBJECT || relation == EnglishGrammaticalRelations.CLAUSAL_SUBJECT || relation == EnglishGrammaticalRelations.CONTROLLING_SUBJECT) return "subject"; if (relation == EnglishGrammaticalRelations.NOMINAL_PASSIVE_SUBJECT || relation == EnglishGrammaticalRelations.CLAUSAL_PASSIVE_SUBJECT) return "subject"; // verbal argument relations if (relation == EnglishGrammaticalRelations.ADJECTIVAL_COMPLEMENT || relation == EnglishGrammaticalRelations.CLAUSAL_COMPLEMENT || relation == EnglishGrammaticalRelations.XCLAUSAL_COMPLEMENT || relation == EnglishGrammaticalRelations.AGENT || relation == EnglishGrammaticalRelations.DIRECT_OBJECT || relation == EnglishGrammaticalRelations.INDIRECT_OBJECT) return "verbArg"; // noun argument relations if (relation == EnglishGrammaticalRelations.RELATIVE_CLAUSE_MODIFIER || relation == EnglishGrammaticalRelations.NOUN_COMPOUND_MODIFIER || relation == EnglishGrammaticalRelations.ADJECTIVAL_MODIFIER || relation == EnglishGrammaticalRelations.APPOSITIONAL_MODIFIER || relation == EnglishGrammaticalRelations.POSSESSION_MODIFIER) return "nounArg"; return null;/*from w w w . j a va 2s .co m*/ }
From source file:knu.univ.lingvo.coref.Mention.java
License:Open Source License
public int getModifiers(Dictionaries dict) { if (headIndexedWord == null) return 0; int count = 0; List<Pair<GrammaticalRelation, IndexedWord>> childPairs = dependency.childPairs(headIndexedWord); for (Pair<GrammaticalRelation, IndexedWord> childPair : childPairs) { GrammaticalRelation gr = childPair.first; IndexedWord word = childPair.second; if (gr == EnglishGrammaticalRelations.ADJECTIVAL_MODIFIER || gr == EnglishGrammaticalRelations.VERBAL_MODIFIER || gr == EnglishGrammaticalRelations.RELATIVE_CLAUSE_MODIFIER || gr.toString().startsWith("prep_")) { count++;/* w ww . j av a 2 s . com*/ } // add noun modifier when the mention isn't a NER if (nerString.equals("O") && gr == EnglishGrammaticalRelations.NOUN_COMPOUND_MODIFIER) { count++; } // add possessive if not a personal determiner if (gr == EnglishGrammaticalRelations.POSSESSION_MODIFIER && !dict.determiners.contains(word.lemma())) { count++; } } return count; }
From source file:knu.univ.lingvo.coref.Mention.java
License:Open Source License
public String getQuantification(Dictionaries dict) { if (headIndexedWord == null) return null; if (!nerString.equals("O")) return "definite"; List<IndexedWord> quant = dependency.getChildrenWithReln(headIndexedWord, EnglishGrammaticalRelations.DETERMINER); List<IndexedWord> poss = dependency.getChildrenWithReln(headIndexedWord, EnglishGrammaticalRelations.POSSESSION_MODIFIER); String det = ""; if (!quant.isEmpty()) { det = quant.get(0).lemma();//from w w w. jav a 2s .c om if (dict.determiners.contains(det)) { return "definite"; } } else if (!poss.isEmpty()) { return "definite"; } else { quant = dependency.getChildrenWithReln(headIndexedWord, EnglishGrammaticalRelations.NUMERIC_MODIFIER); if (dict.quantifiers2.contains(det) || !quant.isEmpty()) { return "quantified"; } } return "indefinite"; }