* Tests translation model parsing.
*/
@Test
public void testParse() {
StringReader reader = new StringReader(TRANSLATION_MODEL);
Vocabulary sourceVocabulary = new Vocabulary();
Vocabulary targetVocabulary = new Vocabulary();
TranslationModel translationModel = TranslationModelUtil.parse(reader,
sourceVocabulary, targetVocabulary);
SourceData sourceData;
sourceData = translationModel.get(sourceVocabulary.getWid("a"));
assertEquals(1, sourceData.getTranslationList().size());
assertEquals(0.0, sourceData.getTranslationProbability(targetVocabulary.getWid("A")), 0.0001);
assertEquals(1.0, sourceData.getTranslationProbability(targetVocabulary.getWid("D")), 0.0001);
sourceData = translationModel.get(sourceVocabulary.getWid("b"));
assertEquals(2, sourceData.getTranslationList().size());
assertEquals(0.25, sourceData.getTranslationProbability(targetVocabulary.getWid("C")), 0.0001);
assertEquals(0.75, sourceData.getTranslationProbability(targetVocabulary.getWid("D")), 0.0001);
sourceData = translationModel.get(sourceVocabulary.getWid("c"));
assertEquals(1, sourceData.getTranslationList().size());
assertEquals(1.0, sourceData.getTranslationProbability(targetVocabulary.getWid("A")), 0.0001);
sourceData = translationModel.get(100);
assertEquals(0, sourceData.getTranslationList().size());
}