Example usage for edu.stanford.nlp.neural.rnn RNNCoreAnnotations getNodeVector

List of usage examples for edu.stanford.nlp.neural.rnn RNNCoreAnnotations getNodeVector

Introduction

In this page you can find the example usage for edu.stanford.nlp.neural.rnn RNNCoreAnnotations getNodeVector.

Prototype

public static SimpleMatrix getNodeVector(Tree tree) 

Source Link

Document

Get the vector (distributed representation) at a particular node.

Usage

From source file:opennlp.tools.parse_thicket.opinion_processor.DefaultSentimentProcessor.java

License:Apache License

/**
 * Outputs the vectors from the tree. Counts the tree nodes the same as
 * setIndexLabels.//from   w w w . j  a  v a2 s . com
 */
static int outputTreeVectors(PrintStream out, Tree tree, int index) {
    if (tree.isLeaf()) {
        return index;
    }

    out.print("  " + index + ":");
    SimpleMatrix vector = RNNCoreAnnotations.getNodeVector(tree);
    for (int i = 0; i < vector.getNumElements(); ++i) {
        out.print("  " + NF.format(vector.get(i)));
    }
    out.println();
    index++;
    for (Tree child : tree.children()) {
        index = outputTreeVectors(out, child, index);
    }
    return index;
}