Example usage for edu.stanford.nlp.trees EnglishGrammaticalRelations ADV_CLAUSE_MODIFIER

List of usage examples for edu.stanford.nlp.trees EnglishGrammaticalRelations ADV_CLAUSE_MODIFIER

Introduction

In this page you can find the example usage for edu.stanford.nlp.trees EnglishGrammaticalRelations ADV_CLAUSE_MODIFIER.

Prototype

GrammaticalRelation ADV_CLAUSE_MODIFIER

To view the source code for edu.stanford.nlp.trees EnglishGrammaticalRelations ADV_CLAUSE_MODIFIER.

Click Source Link

Document

The "adverbial clause modifier" grammatical relation.

Usage

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 av a2 s.  c  om
}

From source file:knu.univ.lingvo.coref.Mention.java

License:Open Source License

public int getReportEmbedding(Dictionaries dict) {

    if (headIndexedWord == null)
        return 0;

    // check adverbial clause with marker "as"
    Collection<IndexedWord> siblings = dependency.getSiblings(headIndexedWord);
    for (IndexedWord sibling : siblings) {
        if (dict.reportVerb.contains(sibling.lemma())
                && dependency.hasParentWithReln(sibling, EnglishGrammaticalRelations.ADV_CLAUSE_MODIFIER)) {
            IndexedWord marker = dependency.getChildWithReln(sibling, EnglishGrammaticalRelations.MARKER);
            if (marker != null && marker.lemma().equals("as")) {
                return 1;
            }// ww  w. j a va  2  s  .  c  om
        }
    }

    // look at the path to root
    List<IndexedWord> path = dependency.getPathToRoot(headIndexedWord);
    if (path == null)
        return 0;
    boolean isSubject = false;

    // if the node itself is a subject, we will not take into account its parent in the path
    if (dependency.hasParentWithReln(headIndexedWord, EnglishGrammaticalRelations.NOMINAL_SUBJECT))
        isSubject = true;

    for (IndexedWord word : path) {
        if (!isSubject && (dict.reportVerb.contains(word.lemma()) || dict.reportNoun.contains(word.lemma()))) {
            return 1;
        }
        // check how to put isSubject
        isSubject = dependency.hasParentWithReln(word, EnglishGrammaticalRelations.NOMINAL_SUBJECT);
    }
    return 0;
}