bug fixed: the empty input, which cannot be translated by the neural decoder, is now handled properly.
@@ -79,6 +79,10 @@ public class NeuralDecoder implements Decoder, DataListenerProvider {
long start = System.currentTimeMillis();
+
+ Translation translation;
+
+ if (text.hasWords()) {
ScoreEntry[] suggestions;
try {
@@ -87,19 +91,20 @@ public class NeuralDecoder implements Decoder, DataListenerProvider {
throw new NeuralDecoderException("Failed to retrieve suggestions from memory", e);
}
- Translation translation;
-
if (suggestions != null && suggestions.length > 0)
translation = executor.execute(direction, text, suggestions);
else
translation = executor.execute(direction, text);
-
+ } else {
+ translation = Translation.emptyTranslation(text);
+ }
long elapsed = System.currentTimeMillis() - start;
translation.setElapsedTime(elapsed);
logger.info("Translation of " + text.length() + " words took " + (((double) elapsed) / 1000.) + "s");
return translation;
+
}
// DataListenerProvider
