Example usage for edu.stanford.nlp.parser.lexparser TreebankLangParserParams treebankLanguagePack

List of usage examples for edu.stanford.nlp.parser.lexparser TreebankLangParserParams treebankLanguagePack

Introduction

In this page you can find the example usage for edu.stanford.nlp.parser.lexparser TreebankLangParserParams treebankLanguagePack.

Prototype

TreebankLanguagePack treebankLanguagePack();

Source Link

Document

returns a TreebankLanguagePack containing Treebank-specific (but not parser-specific) info such as what is punctuation, and also information about the structure of labels

Usage

From source file:gate.stanford.Parser.java

License:Open Source License

/**
 * Initialize the Parser resource.  In particular, load the trained data
 * file.//from   w  w  w  .j a v  a2 s. c o  m
 */
public Resource init() throws ResourceInstantiationException {
    instantiateStanfordParser();
    if (mappingFile != null) {
        loadTagMapping(mappingFile);
    }

    super.init();

    if (tlppClass == null || tlppClass.equals("")) {
        throw new ResourceInstantiationException("TLPP class name must be specified");
    }
    try {
        Class<?> tlppClassObj = Class.forName(tlppClass);
        if (!TreebankLangParserParams.class.isAssignableFrom(tlppClassObj)) {
            throw new ResourceInstantiationException(
                    tlppClassObj + " does not implement " + TreebankLangParserParams.class.getName());
        }
        TreebankLangParserParams tlpp = TreebankLangParserParams.class.cast(tlppClassObj.newInstance());
        gsf = tlpp.treebankLanguagePack().grammaticalStructureFactory();
    } catch (UnsupportedOperationException e) {
        throw new ResourceInstantiationException(e);
    } catch (ClassNotFoundException e) {
        throw new ResourceInstantiationException("Class " + tlppClass + " not found", e);
    } catch (InstantiationException e) {
        throw new ResourceInstantiationException("Error creating TLPP object", e);
    } catch (IllegalAccessException e) {
        throw new ResourceInstantiationException("Error creating TLPP object", e);
    }
    return this;
}

From source file:reck.parser.lexparser.RECKLexicalizedParser.java

License:Open Source License

/** Return a TreePrint for formatting parsed output trees.
 *  @return A TreePrint for formatting parsed output trees.
 *//*  w ww.  ja v a 2 s .c o m*/
public static RECKTreePrint getRECKTreePrint(Options op) {
    TreebankLangParserParams tlpParams = op.tlpParams;
    TreebankLanguagePack tlp = tlpParams.treebankLanguagePack();
    /**
     * Determines format of output trees: choose among penn, oneline
     */
    String outputFormat = "typedDependencies";
    String outputFormatOptions = "";
    return new RECKTreePrint(outputFormat, outputFormatOptions, tlp, tlpParams.headFinder());
}