Example usage for edu.stanford.nlp.trees Constituent start

List of usage examples for edu.stanford.nlp.trees Constituent start

Introduction

In this page you can find the example usage for edu.stanford.nlp.trees Constituent start.

Prototype

public abstract int start();

Source Link

Document

access start node.

Usage

From source file:ims.cs.lingdata.Token.java

License:Open Source License

/**
 * Determines whether a constituent starts at this token
 * @return/*from ww w . j  ava  2 s . co m*/
 */
public boolean hasStartingConstituents() {
    Tree tree = sentence.tree;
    Set<Constituent> constituents = tree.constituents();

    for (Constituent c : constituents) {
        if (c.end() - c.start() > 1 && c.start() == predSentencePosition)
            return true;
    }

    return false;
}

From source file:ims.cs.lingdata.Token.java

License:Open Source License

/**
 * Determines whether a constituent ends at this token
 * @return//  ww  w. j av  a2s .c  om
 */
public boolean hasEndingConstituents() {
    Tree tree = sentence.tree;
    Set<Constituent> constituents = tree.constituents();

    for (Constituent c : constituents) {
        if (c.end() - c.start() > 1 && c.end() == predSentencePosition)
            return true;
    }

    return false;
}

From source file:ims.cs.qsample.features.SpanFeatures.java

License:Open Source License

/**
 * Add features related to constituent matches of the span
 * @param span//from   w  w  w.  jav a  2s .co  m
 * @param fs
 */
public static void matchesConstituent(Span span, FeatureSet fs) {
    Sentence sentence = span.first().sentence;
    if (sentence != span.last().sentence)
        return;

    // CONSTITUENT SEQUENCE MATCH
    if (span.first().boundaryFeatureSet.contains("HAS-STARTING-CONSTITUENT")
            && span.last().boundaryFeatureSet.contains("HAS-ENDING-CONSTITUENT")) {
        fs.add("MATCHES-AT-LEAST-ONE-CONSTITUENT");
    }

    // CONSTITUENT EXACT MATCH
    Set<Constituent> constituents = sentence.tree.constituents();
    for (Constituent constituent : constituents) {
        int begin = constituent.start();
        int end = constituent.end();

        // TODO POST-ACL: end - begin > 0 would be correct. change later.
        if (end - begin > 1 && begin == span.first().predSentencePosition
                && end == span.last().predSentencePosition) {
            fs.add("MATCHES-CONSTITUENT");
        }
    }
}