@Override public Language getForeignLanguage() { return base.getForeignLanguage(); }
constrainedOutputSpace, (constrainedOutputSpace == null ? null : constrainedOutputSpace.getAllowableSequences()), beamCapacity); return Collections.singletonList(convert(translation, phraseTable.getForeignLanguage(), phraseTable.getTranslationLanguage())); } else { List<RichTranslation<IString, String>> translations = inferer.nbest( List<Translation> monnetTrans = new ArrayList<Translation>(translations.size()); for (RichTranslation<IString, String> richTranslation : translations) { monnetTrans.add(convert(richTranslation, phraseTable.getForeignLanguage(), phraseTable.getTranslationLanguage()));
private List<Translation> decode(List<String> phrase, PhraseTable phraseTable, List<String> featureNames, int nBest, int beamSize, boolean useLazy) { FidelDecoder.wordMap = invWordMap; FidelDecoder.srcWordMap = srcWordMap; int[] src = convertPhrase(phrase); Object2ObjectMap<Phrase, Collection<PhraseTranslation>> pt = convertPT(phraseTable, trgWordMap, featureNames, beamSize+10); int lmN = languageModel.order(); double[] wts = new double[featureNames.size() + FidelDecoder.PT]; int i = FidelDecoder.PT; //wts[FidelDecoder.UNK] = -100 * (weights.containsKey("UnknownWord") ? weights.get("UnknownWord") : 1.0); wts[FidelDecoder.UNK] = -100; wts[FidelDecoder.DIST] = weights.containsKey("LinearDistortion") ? weights.get("LinearDistortion") : 0.0; wts[FidelDecoder.LM] = weights.containsKey("LM") ? weights.get("LM") : 0.0; for (String feat : featureNames) { wts[i++] = weights.containsKey(feat) ? weights.get(feat) : (weights.containsKey("TM:" + feat) ? weights.get("TM:" + feat) : 0); } final Solution[] translations = FidelDecoder.decode(src, pt, languageModel, lmN, wts, distortionLimit, nBest, beamSize, useLazy); final StringBuilder sb = new StringBuilder(); for (String w : phrase) { if (sb.length() != 0) { sb.append(" "); } sb.append(w); } return convertTranslations(translations, new StringLabel(sb.toString(), phraseTable.getForeignLanguage()), phraseTable.getTranslationLanguage(), featureNames); }