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);
}
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);
}
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);
}
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) + "%");
}
Aggregations