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

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

Introduction

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

Prototype

@SuppressWarnings("unchecked")
public static GrammaticalRelation valueOf(Object o) 

Source Link

Document

Returns an EnglishGrammaticalRelation based on the argument.

Usage

From source file:dependencies.DependencyQuery.java

License:Open Source License

public DependencyQuery(String query) throws IllegalArgumentException {
    String[] args = query.split(" ");
    switch (args.length) {
    case 4://from w  w  w. j a  v  a 2  s.  com
        if (args[3].startsWith(">")) {
            comparison = NodeSentimentComparison.STRONGER_DEP;
        } else if (args[3].startsWith("<")) {
            comparison = NodeSentimentComparison.WEAKER_DEP;
        } else
            throw new IllegalArgumentException("Invalid relative comparison specifier in query string");

        // DO NOT break

    case 3:
        try {
            govQuery = new NodeQuery(args[2]);
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException(e.getMessage() + " (gov)", e);
        }

        try {
            depQuery = new NodeQuery(args[1]);
        } catch (IllegalArgumentException e) {
            throw new IllegalArgumentException(e.getMessage() + " (dep)", e);
        }

        // DO NOT break

    case 1:
        reln = EnglishGrammaticalRelations.valueOf(args[0]);
        if (reln == null)
            throw new IllegalArgumentException("Invalid grammatical relation specified in query string");
        break;

    default:
        throw new IllegalArgumentException("Invalid number of arguments in query string");
    }
}

From source file:dependencies.rules.DependencyRule.java

License:Open Source License

public void setRelations(String[] relnames) {
    reln.clear();/*from   w w w  .ja  v  a  2 s.c o  m*/
    if (relnames == null || relnames.length == 0) {
        reln.addAll(EnglishGrammaticalRelations.values());
    } else {
        for (String relname : relnames) {
            GrammaticalRelation relation = EnglishGrammaticalRelations.valueOf(relname);
            if (relation != null) {
                reln.add(relation);
            } else {
                if (relname.isEmpty() && relnames.length == 1) {
                    reln.addAll(EnglishGrammaticalRelations.values());
                } else {
                    AppLogger.error.log(Level.WARNING,
                            "Invalid relation \"" + relname + "\" was not included in dependency rule");
                }
            }
        }
    }

}

From source file:dependencies.rules.SimpleEnglishRules.java

License:Open Source License

private static Set<GrammaticalRelation> relations(String... relns) {
    HashSet<GrammaticalRelation> relnset = new HashSet<GrammaticalRelation>();
    for (String reln : relns) {
        relnset.add(EnglishGrammaticalRelations.valueOf(reln));
    }//from w  w w  .  j a va2s.  c o  m

    return relnset;
}