computerline1z / okapi

Automatically exported from code.google.com/p/okapi
0 stars 0 forks source link

Issue with sending empty textunits to BatchTmLeveraging step #331

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
What steps will reproduce the problem?
1.Create an XLIFF with few text units having no text. 
2.Create a pipeline with BatchTmLeveragingStep with xliff filter to raw 
document and writer in place. 
3.Pass the xliff with empty text units through this pipeline. You will see 
exception 
--------------------
java.lang.IndexOutOfBoundsException: Index: 29, Size: 29
        at java.util.ArrayList.rangeCheck(ArrayList.java:604)
        at java.util.ArrayList.get(ArrayList.java:382)
        at
net.sf.okapi.lib.translation.BaseConnector.batchLeverageUsingBatchQuery(BaseConn
ector.java:333)
        at
net.sf.okapi.connectors.microsoft.MicrosoftMTConnector.batchLeverage(MicrosoftMT
Connector.java:492)
        at
net.sf.okapi.steps.leveraging.BatchTmLeveragingStep.batchLeverage(BatchTmLeverag
ingStep.java:245)
        at
net.sf.okapi.steps.leveraging.BatchTmLeveragingStep.handleTextUnit(BatchTmLevera
gingStep.java:139)
        at
net.sf.okapi.steps.leveraging.BatchTmLeveragingStep.handleEvent(BatchTmLeveragin
gStep.java:106)
        at net.sf.okapi.common.pipeline.Pipeline.execute(Pipeline.java:123)
        at net.sf.okapi.common.pipeline.Pipeline.process(Pipeline.java:235)
        at net.sf.okapi.common.pipeline.Pipeline.process(Pipeline.java:205)
        at
net.sf.okapi.common.pipelinedriver.PipelineDriver.processBatch(PipelineDriver.ja
va:162)
---------------------

What is the expected output? What do you see instead?
We should not be sending the text units for MT. 

What version of the product are you using? On what operating system?
M20 on RHEL 5.4

Please provide any additional information below.
I did fixed this issue on my local by changing the method canLeverageTU()
*********************************
private boolean canLeverageTu(ITextUnit tu) {
        // Do not leverage non-translatable entries
        if (!tu.isTranslatable()) {
            return false;
        }

        boolean approved = false;
        Property prop = tu.getTargetProperty(targetLocale, Property.APPROVED);
        if (prop != null) {
            if ("yes".equals(prop.getValue())) {
                approved = true;
            }
        }

        // Do not leverage pre-approved entries
        if (approved) {
            return false;
        }

        // do not leverage if has been Diff Leveraged
        if (wasDiffLeveraged(tu)) {
            return false;
        }

        //This code was specifically added not to send any empty textunit/ place holders for leveraging 
        //As it wont make sense to translate empty texts. 
        if (tu.getSource().getFirstContent().getText().equals("")) {
            return false;
        }
        return true;
    }
********************************* 
Not sure if its a right approach but this fixes the exception and i dont see 
this issue happening any more. 

Original issue reported on code.google.com by anoopsin...@gmail.com on 26 Apr 2013 at 7:19

GoogleCodeExporter commented 9 years ago
Using:
// Do not leverage entries without text
if ( !tu.getSource().hasText() ) {
   return false;
}
should work better.
I've made the change. It's in the dev branch and will be in the next snapshot.

Original comment by yves.sav...@gmail.com on 30 Apr 2013 at 12:40