Search in sources :

Example 1 with IInstance

use of edu.illinois.cs.cogcomp.sl.core.IInstance in project cogcomp-nlp by CogComp.

the class JLISCuttingPlaneILPSolverGurobi method populateViolatedConstraints.

private void populateViolatedConstraints(List<List<ILPConstraint>> violated) {
    violated.clear();
    IStructure y = outputGenerator.getOutput(baseSolver, variables, x);
    for (ILPConstraintGenerator c : this.cuttingPlaneConstraints) {
        // see if the constraint generator has anything to say about the input
        // upon which it operates. If not, then use the input to the inference,
        // namely x
        IInstance input = c.getConstraintInput();
        if (input == null)
            input = x;
        IStructure output = c.getConstraintOutput(y);
        List<ILPConstraint> cs = c.getViolatedILPConstraints(input, output, variables);
        violated.add(cs);
    }
}
Also used : IStructure(edu.illinois.cs.cogcomp.sl.core.IStructure) IInstance(edu.illinois.cs.cogcomp.sl.core.IInstance)

Example 2 with IInstance

use of edu.illinois.cs.cogcomp.sl.core.IInstance in project cogcomp-nlp by CogComp.

the class JLISLearner method evaluateSenseStructure.

public static double evaluateSenseStructure(AbstractInferenceSolver inference, StructuredProblem testSet, WeightVector weights) throws Exception {
    EvaluationRecord evalRecord = new EvaluationRecord();
    for (int i = 0; i < testSet.input_list.size(); i++) {
        IInstance x = testSet.input_list.get(i);
        SenseStructure gold = (SenseStructure) testSet.output_list.get(i);
        SenseStructure bestStructure = (SenseStructure) inference.getBestStructure(weights, x);
        if (gold.getLabel() == bestStructure.getLabel())
            evalRecord.incrementCorrect();
        evalRecord.incrementGold();
        evalRecord.incrementPredicted();
    }
    log.info("Predicted = " + evalRecord.getPredictedCount() + ", Gold = " + evalRecord.getGoldCount() + " Correct = " + evalRecord.getCorrectCount());
    return evalRecord.getF1();
}
Also used : SenseStructure(edu.illinois.cs.cogcomp.verbsense.jlis.SenseStructure) IInstance(edu.illinois.cs.cogcomp.sl.core.IInstance) EvaluationRecord(edu.illinois.cs.cogcomp.core.experiments.EvaluationRecord)

Example 3 with IInstance

use of edu.illinois.cs.cogcomp.sl.core.IInstance in project cogcomp-nlp by CogComp.

the class RealMeasureAverager method getFoldData.

public Pair<StructuredProblem, StructuredProblem> getFoldData(StructuredProblem problem, int foldId) {
    int testStart = splitIds[foldId];
    int testEnd = splitIds[foldId + 1];
    StructuredProblem train = new StructuredProblem();
    StructuredProblem test = new StructuredProblem();
    train.input_list = new ArrayList<IInstance>();
    test.input_list = new ArrayList<IInstance>();
    train.output_list = new ArrayList<IStructure>();
    test.output_list = new ArrayList<IStructure>();
    for (int i = 0; i < problem.input_list.size(); i++) {
        IInstance x = problem.input_list.get(i);
        IStructure y = problem.output_list.get(i);
        if (i < testStart || i >= testEnd) {
            train.input_list.add(x);
            train.output_list.add(y);
        } else {
            test.input_list.add(x);
            test.output_list.add(y);
        }
    }
    return new Pair<StructuredProblem, StructuredProblem>(train, test);
}
Also used : StructuredProblem(edu.illinois.cs.cogcomp.sl.core.StructuredProblem) IInstance(edu.illinois.cs.cogcomp.sl.core.IInstance) IStructure(edu.illinois.cs.cogcomp.sl.core.IStructure) Pair(edu.illinois.cs.cogcomp.core.datastructures.Pair)

Aggregations

IInstance (edu.illinois.cs.cogcomp.sl.core.IInstance)3 IStructure (edu.illinois.cs.cogcomp.sl.core.IStructure)2 Pair (edu.illinois.cs.cogcomp.core.datastructures.Pair)1 EvaluationRecord (edu.illinois.cs.cogcomp.core.experiments.EvaluationRecord)1 StructuredProblem (edu.illinois.cs.cogcomp.sl.core.StructuredProblem)1 SenseStructure (edu.illinois.cs.cogcomp.verbsense.jlis.SenseStructure)1