Example usage for edu.stanford.nlp.sequences SeqClassifierFlags SeqClassifierFlags

List of usage examples for edu.stanford.nlp.sequences SeqClassifierFlags SeqClassifierFlags

Introduction

In this page you can find the example usage for edu.stanford.nlp.sequences SeqClassifierFlags SeqClassifierFlags.

Prototype

public SeqClassifierFlags() 

Source Link

Document

Create a new SeqClassifierFlags object initialized with default values.

Usage

From source file:org.jdmp.stanfordpos.StanfordTagger.java

License:Open Source License

public StanfordTagger(File file) throws Exception {
    crf = new CRFClassifier<CoreLabel>(new SeqClassifierFlags());
    crf.loadClassifierNoExceptions(file);
}

From source file:org.jdmp.stanfordpos.StanfordTagger.java

License:Open Source License

public void train(ListMatrix<ListMatrix<MapMatrix<String, String>>> listMatrix) throws Exception {
    List<List<CoreLabel>> sentenceList = new ArrayList<List<CoreLabel>>();
    for (ListMatrix<MapMatrix<String, String>> innerList : listMatrix) {
        List<CoreLabel> tokenList = new ArrayList<CoreLabel>();
        sentenceList.add(tokenList);/*from  w w w. j  a v  a2s .  c o  m*/
        for (MapMatrix<String, String> mapMatrix : innerList) {
            CoreLabel l = new CoreLabel();
            l.set(CoreAnnotations.TextAnnotation.class, mapMatrix.getAsString("Token"));
            l.set(CoreAnnotations.AnswerAnnotation.class, mapMatrix.getAsString("Class"));
            tokenList.add(l);
        }
    }

    SeqClassifierFlags flags = new SeqClassifierFlags();
    flags.maxLeft = 3;
    flags.useClassFeature = true;
    flags.useWord = true;
    flags.maxNGramLeng = 6;
    flags.usePrev = true;
    flags.useNext = true;
    flags.useDisjunctive = true;
    flags.useSequences = true;
    flags.usePrevSequences = true;
    flags.useTypeSeqs = true;
    flags.useTypeSeqs2 = true;
    flags.useTypeySequences = true;
    flags.wordShape = WordShapeClassifier.WORDSHAPECHRIS2;

    flags.useNGrams = true;
    crf = new CRFClassifier<CoreLabel>(flags);
    crf.train(sentenceList, null);
}