Example usage for edu.stanford.nlp.ling StringLabel factory

List of usage examples for edu.stanford.nlp.ling StringLabel factory

Introduction

In this page you can find the example usage for edu.stanford.nlp.ling StringLabel factory.

Prototype

public static LabelFactory factory() 

Source Link

Document

Return a factory for this kind of label.

Usage

From source file:de.tudarmstadt.ukp.dkpro.core.corenlp.internal.CoreNlp2DKPro.java

License:Open Source License

public static void convertPennTree(JCas aJCas, Annotation aDocument) {
    for (CoreMap s : aDocument.get(SentencesAnnotation.class)) {
        Tree tree = s.get(TreeCoreAnnotations.TreeAnnotation.class);
        int begin = s.get(CharacterOffsetBeginAnnotation.class);
        int end = s.get(CharacterOffsetEndAnnotation.class);

        // create tree with simple labels and get penn string from it
        tree = tree.deepCopy(tree.treeFactory(), StringLabel.factory());

        // write Penn Treebank-style string to cas
        PennTree pTree = new PennTree(aJCas, begin, end);
        pTree.setPennTree(tree.pennString());
        pTree.addToIndexes();//  ww w  . ja  v  a2  s.  co m
    }
}

From source file:de.tudarmstadt.ukp.dkpro.core.stanfordnlp.util.StanfordAnnotator.java

License:Open Source License

/**
 * Creates annotation with Penn Treebank style representations of the syntax tree
 * //from  w  ww  .  j ava2s . c o m
 * @param aBegin
 *            start offset.
 * @param aEnd
 *            end offset.
 */
public void createPennTreeAnnotation(int aBegin, int aEnd) {
    Tree t = tokenTree.getTree();

    // write Penn Treebank-style string to cas
    PennTree pTree = new PennTree(jCas, aBegin, aEnd);

    // create tree with simple labels and get penn string from it
    t = t.deepCopy(t.treeFactory(), StringLabel.factory());

    pTree.setPennTree(t.pennString());
    pTree.addToIndexes();
}

From source file:reck.trees.RECKCTTreeNodeImpl.java

License:Open Source License

/**
 * Return a <code>TreeFactory</code> that produces trees of the
 * same type as the current <code>Tree</code>.  That is, this
 * implementation, will produce trees of type
 * <code>LabeledScoredTree(Node|Leaf)</code>.
 * The <code>Label</code> of <code>this</code>
 * is examined, and providing it is not <code>null</code>, a
 * <code>LabelFactory</code> which will produce that kind of
 * <code>Label</code> is supplied to the <code>TreeFactory</code>.
 * If the <code>Label</code> is <code>null</code>, a
 * <code>StringLabelFactory</code> will be used.
 * The factories returned on different calls a different: a new one is
 * allocated each time./*from w w  w  .  j  a va 2  s .c  om*/
 *
 * @return a factory to produce labeled, scored trees
 */
public TreeFactory treeFactory() {
    LabelFactory lf;
    if (label() != null) {
        lf = label().labelFactory();
    } else {
        lf = StringLabel.factory();
    }
    return new LabeledScoredTreeFactory(lf);
}