Skip to content

Commit

Permalink
Merge pull request #4682 from inception-project/feature/4525-Support-…
Browse files Browse the repository at this point in the history
…recommendations-for-non-string-primitive-features

#4525 - Support recommendations for non-string primitive features
  • Loading branch information
reckart authored Apr 4, 2024
2 parents dda5615 + 7a4ec08 commit 47a17b6
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ public Range predict(PredictionContext aContext, CAS aCas, int aBegin, int aEnd)
var end = tokens.get(prediction.getEnd() - 1).getEnd();
var annotation = aCas.createAnnotation(predictedType, begin, end);

annotation.setStringValue(predictedFeature, label);
annotation.setFeatureValueFromString(predictedFeature, label);
if (scoreFeature != null) {
annotation.setDoubleValue(scoreFeature, prediction.getProb());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ public boolean accepts(AnnotationLayer aLayer, AnnotationFeature aFeature)

return (asList(SINGLE_TOKEN, TOKENS, SENTENCES).contains(aLayer.getAnchoringMode()))
&& SpanLayerSupport.TYPE.equals(aLayer.getType())
&& (CAS.TYPE_NAME_STRING.equals(aFeature.getType()) || aFeature.isVirtualFeature());
&& (asList(CAS.TYPE_NAME_STRING, CAS.TYPE_NAME_BOOLEAN).contains(aFeature.getType())
|| aFeature.isVirtualFeature());
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,10 @@ public void thatEvaluationWorks() throws Exception
var precision = result.computePrecisionScore();
var recall = result.computeRecallScore();

System.out.printf("F1-Score: %f%n", fscore);
System.out.printf("Accuracy: %f%n", accuracy);
System.out.printf("Precision: %f%n", precision);
System.out.printf("Recall: %f%n", recall);
LOG.info("F1-Score: {}", fscore);
LOG.info("Accuracy: {}", accuracy);
LOG.info("Precision: {}", precision);
LOG.info("Recall: {}", recall);

assertThat(fscore).isBetween(0.0, 1.0);
assertThat(precision).isBetween(0.0, 1.0);
Expand All @@ -243,10 +243,10 @@ public void thatEvaluationWorksNoLabels() throws Exception
var precision = result.computePrecisionScore();
var recall = result.computeRecallScore();

System.out.printf("F1-Score: %f%n", fscore);
System.out.printf("Accuracy: %f%n", accuracy);
System.out.printf("Precision: %f%n", precision);
System.out.printf("Recall: %f%n", recall);
LOG.info("F1-Score: {}", fscore);
LOG.info("Accuracy: {}", accuracy);
LOG.info("Precision: {}", precision);
LOG.info("Recall: {}", recall);

assertThat(fscore).isBetween(0.0, 1.0);
assertThat(precision).isBetween(0.0, 1.0);
Expand Down

0 comments on commit 47a17b6

Please sign in to comment.