LUCENE-7776 - visualize diff btwn BytesRef values in ClassificationTestBase

This commit is contained in:
Tommaso Teofili 2017-04-11 17:12:13 +02:00
parent 1bf3696228
commit 9c00fc6795
1 changed files with 3 additions and 2 deletions

View File

@ -88,8 +88,9 @@ public abstract class ClassificationTestBase<T> extends LuceneTestCase {
protected ClassificationResult<T> checkCorrectClassification(Classifier<T> classifier, String inputDoc, T expectedResult) throws Exception {
ClassificationResult<T> classificationResult = classifier.assignClass(inputDoc);
assertNotNull(classificationResult.getAssignedClass());
assertEquals("got an assigned class of " + classificationResult.getAssignedClass(), expectedResult, classificationResult.getAssignedClass());
T assignedClass = classificationResult.getAssignedClass();
assertNotNull(assignedClass);
assertEquals("got an assigned class of " + assignedClass, expectedResult instanceof BytesRef ? ((BytesRef) expectedResult).utf8ToString() : expectedResult, assignedClass instanceof BytesRef ? ((BytesRef) assignedClass).utf8ToString() : assignedClass);
double score = classificationResult.getScore();
assertTrue("score should be between 0 and 1, got:" + score, score <= 1 && score >= 0);
return classificationResult;