mirror of
https://github.com/GrammaticalFramework/gf-core.git
synced 2026-04-23 11:42:49 -06:00
faster translation in the app
This commit is contained in:
@@ -319,19 +319,18 @@ public class Translator {
|
|||||||
Concr sourceLang = getSourceConcr();
|
Concr sourceLang = getSourceConcr();
|
||||||
Concr targetLang = getTargetConcr();
|
Concr targetLang = getTargetConcr();
|
||||||
|
|
||||||
Expr expr = sourceLang.parseBest(getGrammar().getStartCat(), input);
|
|
||||||
|
|
||||||
int count = NUM_ALT_TRANSLATIONS;
|
int count = NUM_ALT_TRANSLATIONS;
|
||||||
for (ExprProb ep : sourceLang.parse(getGrammar().getStartCat(), input)) {
|
for (ExprProb ep : sourceLang.parse(getGrammar().getStartCat(), input)) {
|
||||||
if (count-- <= 0)
|
if (count-- <= 0)
|
||||||
break;
|
break;
|
||||||
exprs.add(ep);
|
exprs.add(ep);
|
||||||
output = targetLang.linearize(expr);
|
if (output == null)
|
||||||
|
output = targetLang.linearize(ep.getExpr());
|
||||||
}
|
}
|
||||||
} catch (ParseError e) {
|
} catch (ParseError e) {
|
||||||
output = translateByLookup(input);
|
output = translateByLookup(input);
|
||||||
}
|
}
|
||||||
|
|
||||||
return new Pair<String,List<ExprProb>>(output, exprs);
|
return new Pair<String,List<ExprProb>>(output, exprs);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user