Skip to content

Commit 5f62bc5

Browse files
committed
updates based on copilot
1 parent 0aa5002 commit 5f62bc5

2 files changed

Lines changed: 5 additions & 1 deletion

File tree

tika-ml/tika-ml-junkdetect/src/main/java/org/apache/tika/ml/junkdetect/tools/TrainJunkModel.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1161,7 +1161,8 @@ static float[] trainGlobalCombiner(JunkDetector fx,
11611161

11621162
// Mixed-encoding (korA-class) pair: coherent text with heavy
11631163
// undecodable FFFD widget bytes (~15-20% of high bytes) must BEAT
1164-
// coherent-looking mojibake of the same bytes. As a contrastive
1164+
// coherent-looking mojibake of the same source text (the clean w,
1165+
// without the FFFD widgets). As a contrastive
11651166
// PAIR (not a pointwise positive) it adds no class imbalance, and
11661167
// it forces z1/coherence to stay the discriminator: the correct
11671168
// side has MORE FFFD (z6 favors the wrong side) and equal z7

tika-ml/tika-ml-junkdetect/src/test/java/org/apache/tika/ml/junkdetect/JunkDetectorRoundTripTest.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -371,6 +371,9 @@ private static float expectedRunZ(BigramTables tables, String text, float mu, fl
371371
acc[1] += 1;
372372
}
373373
});
374+
if (acc[1] == 0) {
375+
throw new IllegalArgumentException("no scorable bigrams for: " + text);
376+
}
374377
return (float) ((acc[0] / acc[1] - mu) / sigma);
375378
}
376379

0 commit comments

Comments
 (0)