Search in sources :

Example 1 with CoNLL2000Parser

use of edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser in project cogcomp-nlp by CogComp.

the class ChunkTester method chunkTester.

public static void chunkTester(String testFile, String modeldir, String modelname) {
    Parser parser;
    String lcpath = modeldir + File.separator + modelname + ".lc";
    String lexpath = modeldir + File.separator + modelname + ".lex";
    parser = new CoNLL2000Parser(testFile);
    BIOTester tester = new BIOTester(new Chunker(lcpath, lexpath), new ChunkLabel(), new ChildrenFromVectors(parser));
    tester.test().printPerformance(System.out);
}
Also used : ChildrenFromVectors(edu.illinois.cs.cogcomp.lbjava.parse.ChildrenFromVectors) BIOTester(edu.illinois.cs.cogcomp.lbjava.nlp.seg.BIOTester) Chunker(edu.illinois.cs.cogcomp.chunker.main.lbjava.Chunker) ChunkLabel(edu.illinois.cs.cogcomp.chunker.main.lbjava.ChunkLabel) CoNLL2000Parser(edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser) Parser(edu.illinois.cs.cogcomp.lbjava.parse.Parser) CoNLL2000Parser(edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser)

Example 2 with CoNLL2000Parser

use of edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser in project cogcomp-nlp by CogComp.

the class ChunkerTrain method trainModels.

/**
     * Trains the chunker models with the specified training data which must be in CoNLL2000 format
     *
     * @param trainingData The labeled training data
     */
public void trainModels(String trainingData) {
    Parser parser = new CoNLL2000Parser(trainingData);
    trainModelsWithParser(parser);
}
Also used : CoNLL2000Parser(edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser) Parser(edu.illinois.cs.cogcomp.lbjava.parse.Parser) CoNLL2000Parser(edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser)

Example 3 with CoNLL2000Parser

use of edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser in project cogcomp-nlp by CogComp.

the class ChunkerTrain method trainModels.

public void trainModels(String trainingData, String modeldir, String modelname, double dev_ratio) {
    Parser parser = new CoNLL2000Parser(trainingData);
    trainModelsWithParser(parser, modeldir, modelname, dev_ratio);
}
Also used : CoNLL2000Parser(edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser) Parser(edu.illinois.cs.cogcomp.lbjava.parse.Parser) CoNLL2000Parser(edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser)

Example 4 with CoNLL2000Parser

use of edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser in project cogcomp-nlp by CogComp.

the class TestChunkerModels method testAccuracy.

public void testAccuracy() {
    Parser parser = new ChildrenFromVectors(new CoNLL2000Parser(labeledData));
    int numSeen = 0;
    int numEqual = 0;
    for (Token w = (Token) parser.next(); w != null; w = (Token) parser.next()) {
        String prediction = tagger.discreteValue(w);
        String raw = w.toString();
        String actualChunk = raw.substring(raw.indexOf('(') + 1, raw.indexOf(' '));
        if (prediction.equals(actualChunk)) {
            numEqual++;
        }
        numSeen++;
    }
    logger.info("Total accuracy over " + numSeen + " items: " + String.format("%.2f", 100.0 * (double) numEqual / (double) numSeen) + "%");
}
Also used : ChildrenFromVectors(edu.illinois.cs.cogcomp.lbjava.parse.ChildrenFromVectors) CoNLL2000Parser(edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser) Token(edu.illinois.cs.cogcomp.lbjava.nlp.seg.Token) Parser(edu.illinois.cs.cogcomp.lbjava.parse.Parser) CoNLL2000Parser(edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser)

Aggregations

CoNLL2000Parser (edu.illinois.cs.cogcomp.chunker.utils.CoNLL2000Parser)4 Parser (edu.illinois.cs.cogcomp.lbjava.parse.Parser)4 ChildrenFromVectors (edu.illinois.cs.cogcomp.lbjava.parse.ChildrenFromVectors)2 ChunkLabel (edu.illinois.cs.cogcomp.chunker.main.lbjava.ChunkLabel)1 Chunker (edu.illinois.cs.cogcomp.chunker.main.lbjava.Chunker)1 BIOTester (edu.illinois.cs.cogcomp.lbjava.nlp.seg.BIOTester)1 Token (edu.illinois.cs.cogcomp.lbjava.nlp.seg.Token)1