Search in sources :

Example 1 with ILPSolverFactory

use of edu.illinois.cs.cogcomp.infer.ilp.ILPSolverFactory 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());
}
Also used : ILPSolverFactory(edu.illinois.cs.cogcomp.infer.ilp.ILPSolverFactory) Dataset(edu.illinois.cs.cogcomp.verbsense.data.Dataset) ClassificationTester(edu.illinois.cs.cogcomp.core.experiments.ClassificationTester) SenseManager(edu.illinois.cs.cogcomp.verbsense.core.SenseManager) TokenLabelView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView) TextAnnotation(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation) ILPInference(edu.illinois.cs.cogcomp.verbsense.inference.ILPInference) CommandDescription(edu.illinois.cs.cogcomp.core.utilities.commands.CommandDescription)

Example 2 with ILPSolverFactory

use of edu.illinois.cs.cogcomp.infer.ilp.ILPSolverFactory 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();
}
Also used : ILPSolverFactory(edu.illinois.cs.cogcomp.infer.ilp.ILPSolverFactory) TokenLabelView(edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView) ILPInference(edu.illinois.cs.cogcomp.verbsense.inference.ILPInference) Constituent(edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)

Aggregations

TokenLabelView (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TokenLabelView)2 ILPSolverFactory (edu.illinois.cs.cogcomp.infer.ilp.ILPSolverFactory)2 ILPInference (edu.illinois.cs.cogcomp.verbsense.inference.ILPInference)2 Constituent (edu.illinois.cs.cogcomp.core.datastructures.textannotation.Constituent)1 TextAnnotation (edu.illinois.cs.cogcomp.core.datastructures.textannotation.TextAnnotation)1 ClassificationTester (edu.illinois.cs.cogcomp.core.experiments.ClassificationTester)1 CommandDescription (edu.illinois.cs.cogcomp.core.utilities.commands.CommandDescription)1 SenseManager (edu.illinois.cs.cogcomp.verbsense.core.SenseManager)1 Dataset (edu.illinois.cs.cogcomp.verbsense.data.Dataset)1