Example usage for edu.stanford.nlp.ling Label setValue

List of usage examples for edu.stanford.nlp.ling Label setValue

Introduction

In this page you can find the example usage for edu.stanford.nlp.ling Label setValue.

Prototype

public void setValue(String value);

Source Link

Document

Set the value for the label (if one is stored).

Usage

From source file:elkfed.mmax.pipeline.P2Chunker.java

License:Apache License

private void normalizeTree(Tree tree) {
    // for leaves -- add positions
    // for nps -- add whether they are basic or not

    int leaveIndex = 0;
    for (Iterator<Tree> treeIt = tree.iterator(); treeIt.hasNext();) {
        Tree currentTree = treeIt.next();
        Label nodeLabel = currentTree.label();
        if (currentTree.isLeaf()) {
            nodeLabel.setValue(nodeLabel.value() + INDEX_SEPARATOR + leaveIndex);
            leaveIndex++;/*from www .  j ava  2 s  . co m*/
        } else {

            if (currentTree.value().toLowerCase().startsWith("np")) {

                Boolean found = false;

                //adjust this np for keeping (if not already discarded
                if (!currentTree.value().endsWith("0") && !currentTree.value().endsWith("2"))
                    currentTree.label().setValue("NP" + NPSTATUS_SEPARATOR + "1");

                //adjust upper np for discarding

                Tree p = currentTree;
                Tree head = p.headTerminal(getHeadFinder());
                while (p != null && !found) {
                    p = p.parent(tree);
                    if (p != null && p.value().toLowerCase().startsWith("np")
                            && p.headTerminal(getHeadFinder()) == head && (!iscoordnp(p))) {
                        found = true;
                        p.label().setValue("NP" + NPSTATUS_SEPARATOR + "0");
                        currentTree.label().setValue("NP" + NPSTATUS_SEPARATOR + "2");
                    }
                }

            } else {
                nodeLabel.setValue(nodeLabel.value().toUpperCase());
            }
        }
    }
}

From source file:elkfed.mmax.pipeline.SemTagger.java

License:Apache License

/** Given a tree, uppercases all its non-terminal label (so that the
 *  CollinsHeadFinder can be applied to it) and add a positional index to
 *  the terminal nodes.//  ww w.j a  va 2  s  . c  om
 * 
 * @param tree the tree whose labels are to be uppercased
 */
private void normalizeTree(Tree tree) {
    int leaveIndex = 0;
    for (Iterator<Tree> treeIt = tree.iterator(); treeIt.hasNext();) {
        Tree currentTree = treeIt.next();
        Label nodeLabel = currentTree.label();
        if (currentTree.isLeaf()) {
            nodeLabel.setValue(nodeLabel.value() + INDEX_SEPARATOR + leaveIndex);
            leaveIndex++;
        } else {
            nodeLabel.setValue(nodeLabel.value().toUpperCase());
        }
    }
}