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);
}
}
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();
}
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);
}
Aggregations