use of edu.illinois.cs.cogcomp.verbsense.inference.ILPInference in project cogcomp-nlp by CogComp.
the class VerbSenseClassifierMain method evaluate.
@CommandDescription(description = "Performs evaluation.", usage = "evaluate")
public static void evaluate() throws Exception {
SenseManager manager = getManager(false);
Dataset testSet = Dataset.PTBTest;
ILPSolverFactory solver = new ILPSolverFactory(ILPSolverFactory.SolverType.JLISCuttingPlaneGurobi);
ClassificationTester senseTester = new ClassificationTester();
long start = System.currentTimeMillis();
int count = 0;
manager.getModelInfo().loadWeightVector();
IResetableIterator<TextAnnotation> dataset = SentenceDBHandler.instance.getDataset(testSet);
while (dataset.hasNext()) {
TextAnnotation ta = dataset.next();
if (!ta.hasView(SenseManager.getGoldViewName()))
continue;
TokenLabelView gold = (TokenLabelView) ta.getView(SenseManager.getGoldViewName());
ILPInference inference = manager.getInference(solver, gold.getConstituents());
assert inference != null;
TokenLabelView prediction = inference.getOutputView();
evaluateSense(gold, prediction, senseTester);
count++;
if (count % 1000 == 0) {
long end = System.currentTimeMillis();
log.info(count + " sentences done. Took " + (end - start) + "ms, Micro-F1 so far = " + senseTester.getMicroF1());
}
}
long end = System.currentTimeMillis();
System.out.println(count + " sentences done. Took " + (end - start) + "ms");
System.out.println("\n\n* Sense");
System.out.println(senseTester.getPerformanceTable(false).toOrgTable());
}
use of edu.illinois.cs.cogcomp.verbsense.inference.ILPInference in project cogcomp-nlp by CogComp.
the class VerbSenseLabeler method getPrediction.
public TokenLabelView getPrediction(TextAnnotation ta) throws Exception {
log.debug("Input: {}", ta.getText());
List<Constituent> predicates = manager.getPredicateDetector().getPredicates(ta);
// If there are no verb identified, return an empty TokenLabelView
if (predicates.isEmpty())
return new TokenLabelView(SenseManager.getPredictedViewName(), VerbSenseConstants.systemIdentifier, ta, 1.0);
ILPSolverFactory solver = new ILPSolverFactory(ILPSolverFactory.SolverType.JLISCuttingPlaneGurobi);
ILPInference inference = manager.getInference(solver, predicates);
return inference.getOutputView();
}
Aggregations