- changed title to [XLIFF] NPE in RepetitionAnalysisStep when there is target locale and its content is empty and source not
[XLIFF] NPE in RepetitionAnalysisStep when there is target locale and its content is empty and source not
Issue #1084
resolved
Package: net.sf.okapi.steps.repetitionanalysis;
File: RepetitionAnalysisStep.java
...
for (Segment seg : ssegments) {
segCounter++;
Segment tseg = null;
if (tsegments != null) {
tseg = tsegments.get(seg.getId()); //Don't match when target is empty and source not.
}
...
In code tsegments.get(seg.getId())
to infer target segment the content of target is empty, thus the seg.getId()
don't corresponds to correct position, as the tsegments
is empty it ends up generating a null segment because the id don't match with the correct position.
if (tsegments != null) {
...
// For word counts
AltTranslationsAnnotation ata = tseg.getAnnotation(AltTranslationsAnnotation.class); //NPE here because tseg is null
...
}
If target content is empty I’d suggest you to check if tsSeg
is not null to proceed and avoid NPE.
Attached an example file.
Comments (4)
-
reporter -
Iverson, thanks for the good testcase and the pointers to the code. Your solution works for me, so I’ve opened a PR for it here:
https://bitbucket.org/okapiframework/okapi/pull-requests/551/fix-a-crash-in-the-repetition-analysis
-
- changed milestone to 1.42.0
-
assigned issue to
-
- changed status to resolved
Fixed
- Log in to comment