OnlyMostSpecificTemporal implements AnswerKeyToResponseMappingRule { private OnlyMostSpecificTemporal() { } private  OnlyMostSpecificTemporal(); static ScoringDataTransformation asTransformationForBoth(); @Override ResponseMapping computeResponseTransformation(final AnswerKey answerKey);  }
@Test public void testOnlyMostSpecificTemporal() { final Symbol d = Symbol.from("foo"); final Symbol type = Symbol.from("type"); final Symbol role = Symbol.from("Time"); final KBPString d19821231 = KBPString.from("1982-12-31", CharOffsetSpan.fromOffsetsOnly(0, 1)); final KBPString d198212XX = KBPString.from("1982-12-XX", CharOffsetSpan.fromOffsetsOnly(0, 1)); final KBPString d198212XXOther = KBPString.from("1982-12-XX", CharOffsetSpan.fromOffsetsOnly(2, 3)); final CharOffsetSpan bf1 = CharOffsetSpan.fromOffsetsOnly(0, 1); final CharOffsetSpan pj1 = CharOffsetSpan.fromOffsetsOnly(0, 10); final KBPString d19840304 = KBPString.from("1984-03-04", CharOffsetSpan.fromOffsetsOnly(20, 21)); final KBPString d198403XX = KBPString.from("1984-03-XX", CharOffsetSpan.fromOffsetsOnly(20, 21)); final CharOffsetSpan bf2 = CharOffsetSpan.fromOffsetsOnly(20, 21); final CharOffsetSpan pj2 = CharOffsetSpan.fromOffsetsOnly(20, 30); final CorefAnnotation corefAnnotation = CorefAnnotation.strictBuilder(d) .corefCAS(d19821231, 1) .corefCAS(d19840304, 2) .corefCAS(d198212XX, 3) .corefCAS(d198212XXOther, 4) .corefCAS(d198403XX, 5).build(); final Response d19821231Response = Response.of(d, type, role, d19821231, bf1, ImmutableSet.<CharOffsetSpan>of(), ImmutableSet.of(pj1), KBPRealis.Actual); final Response d198212XXResponse = Response.of(d, type, role, d198212XX, bf1, ImmutableSet.<CharOffsetSpan>of(), ImmutableSet.of(pj1), KBPRealis.Actual); final Response d198212XXOtherResponse = Response.of(d, type, role, d198212XXOther, bf2, ImmutableSet.<CharOffsetSpan>of(), ImmutableSet.of(pj2), KBPRealis.Actual); final Response d198403XXResponse = Response.of(d, type, role, d198403XX, bf2, ImmutableSet.<CharOffsetSpan>of(), ImmutableSet.of(pj2), KBPRealis.Actual); final Response d19840304Response = Response.of(d, type, role, d19840304, bf2, ImmutableSet.<CharOffsetSpan>of(), ImmutableSet.of(pj2), KBPRealis.Actual); final ResponseAssessment correctAssessment = ResponseAssessment.of(Optional.of(FieldAssessment.CORRECT), Optional.of(FieldAssessment.CORRECT), Optional.of(FieldAssessment.CORRECT), Optional.of(KBPRealis.Actual), Optional.of(FieldAssessment.CORRECT), Optional.of(FillerMentionType.NOMINAL)); final ResponseAssessment incorrectAssessment = ResponseAssessment.of(Optional.of(FieldAssessment.CORRECT), Optional.of(FieldAssessment.CORRECT), Optional.of(FieldAssessment.INCORRECT), Optional.of(KBPRealis.Actual), Optional.of(FieldAssessment.CORRECT), Optional.of(FillerMentionType.NOMINAL)); final AnswerKey answerKey = AnswerKey.from(d, ImmutableList.of( AssessedResponse.of(d19821231Response, correctAssessment), AssessedResponse.of(d19840304Response, incorrectAssessment), AssessedResponse.of(d198403XXResponse, incorrectAssessment), AssessedResponse.of(d198212XXResponse, correctAssessment), AssessedResponse.of(d198212XXOtherResponse, correctAssessment)), ImmutableList.<Response>of(), corefAnnotation); final ArgumentOutput argumentOutput = ArgumentOutput.from(d, ImmutableList .of(Scored.from(d198212XXResponse, 1.0), Scored.from(d198212XXOtherResponse, 1.0), Scored.from(d19821231Response, 1.0), Scored.from(d198403XXResponse, 1.0))); final ArgumentOutput reference = ArgumentOutput.from(d, ImmutableList.of( Scored.from(d19821231Response, 1.0), Scored.from(d198403XXResponse, 1.0))); final ScoringDataTransformation transformation = OnlyMostSpecificTemporal.asTransformationForBoth(); final ScoringData output = transformation.transform(ScoringData.builder() .argumentOutput(argumentOutput).answerKey(answerKey).build()); assertEquals(reference, output.argumentOutput().get()); }