[XLIFF] NPE in RepetitionAnalysisStep when there is target locale and its content is empty and source not

Create issue
Issue #1084 resolved
Iverson Pereira created an issue

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)

  1. Log in to comment