public void SetTranslation_UseStatisticalBestPartTranslationsRatherThanCommonPartialWord() { AddMockedKeyTerm("Isaac", "Isaac"); AddMockedKeyTerm("Paul", "Pablo"); TranslatablePhrase phraseBreakerA = new TranslatablePhrase("Now what?"); TranslatablePhrase phraseBreakerB = new TranslatablePhrase("What did Isaac say?"); TranslatablePhrase phraseBreakerC = new TranslatablePhrase("What could Isaac say?"); TranslatablePhrase phrase1 = new TranslatablePhrase("So now what did those two brothers do?"); TranslatablePhrase phrase2 = new TranslatablePhrase("So what could they do about the problem?"); TranslatablePhrase phrase3 = new TranslatablePhrase("So what did he do?"); TranslatablePhrase phrase4 = new TranslatablePhrase("So now what was Isaac complaining about?"); TranslatablePhrase phrase5 = new TranslatablePhrase("So what did the Apostle Paul say about that?"); TranslatablePhrase phrase6 = new TranslatablePhrase("Why did they treat the Apostle Paul so?"); PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] { phraseBreakerA, phraseBreakerB, phraseBreakerC, phrase1, phrase2, phrase3, phrase4, phrase5, phrase6 }, m_dummyKtList, m_keyTermRules, new List<Substitution>()); ReflectionHelper.SetField(pth, "m_justGettingStarted", false); Assert.AreEqual(3, phrase1.TranslatableParts.Count()); Assert.AreEqual(3, phrase1.GetParts().Count()); Assert.AreEqual(3, phrase2.TranslatableParts.Count()); Assert.AreEqual(3, phrase2.GetParts().Count()); Assert.AreEqual(3, phrase3.TranslatableParts.Count()); Assert.AreEqual(3, phrase3.GetParts().Count()); Assert.AreEqual(4, phrase4.TranslatableParts.Count()); Assert.AreEqual(5, phrase4.GetParts().Count()); Assert.AreEqual(4, phrase5.TranslatableParts.Count()); Assert.AreEqual(5, phrase5.GetParts().Count()); Assert.AreEqual(2, phrase6.TranslatableParts.Count()); Assert.AreEqual(3, phrase6.GetParts().Count()); phrase1.Translation = "Entonces AB Zuxelopitmyfor CD EF GH"; phrase2.Translation = "Entonces Vuxelopitmyfor IJ KL MN OP QR"; phrase3.Translation = "Entonces Wuxelopitmyfor ST"; phrase5.Translation = "Entonces Xuxelopitmyfor dijo Pablo UV WX YZ"; phrase6.Translation = "BG LP Yuxelopitmyfor DW MR Pablo"; Assert.AreEqual("Entonces Isaac", phrase4.Translation); }
public void SetTranslation_UseStatisticalBestPartTranslations() { AddMockedKeyTerm("Isaac", "Isaac"); AddMockedKeyTerm("Paul", "Pablo"); TranslatablePhrase phraseBreakerA = new TranslatablePhrase("Now what?"); TranslatablePhrase phraseBreakerB = new TranslatablePhrase("What did Isaac say?"); TranslatablePhrase phrase1 = new TranslatablePhrase("So now what did those two brothers do?"); TranslatablePhrase phrase2 = new TranslatablePhrase("So what did they do about the problem?"); TranslatablePhrase phrase3 = new TranslatablePhrase("So what did he do?"); TranslatablePhrase phrase4 = new TranslatablePhrase("So now what was Isaac complaining about?"); TranslatablePhrase phrase5 = new TranslatablePhrase("So what did the Apostle Paul say about that?"); PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] { phraseBreakerA, phraseBreakerB, phrase1, phrase2, phrase3, phrase4, phrase5 }, m_dummyKtList, m_keyTermRules, new List<Substitution>()); ReflectionHelper.SetField(pth, "m_justGettingStarted", false); Assert.AreEqual(3, phrase1.TranslatableParts.Count()); Assert.AreEqual(3, phrase1.GetParts().Count()); Assert.AreEqual(3, phrase2.TranslatableParts.Count()); Assert.AreEqual(3, phrase2.GetParts().Count()); Assert.AreEqual(3, phrase3.TranslatableParts.Count()); Assert.AreEqual(3, phrase3.GetParts().Count()); Assert.AreEqual(4, phrase4.TranslatableParts.Count()); Assert.AreEqual(5, phrase4.GetParts().Count()); Assert.AreEqual(4, phrase5.TranslatableParts.Count()); Assert.AreEqual(5, phrase5.GetParts().Count()); phrase1.Translation = "\u00BFEntonces ahora que\u0301 hicieron esos dos hermanos?"; phrase2.Translation = "\u00BFEntonces que\u0301 hicieron acerca del problema?"; phrase3.Translation = "\u00BFEntonces que\u0301 hizo?"; phrase5.Translation = "\u00BFEntonces que\u0301 dijo Pablo acerca de eso?"; Assert.AreEqual("\u00BFEntonces Isaac?", phrase4.Translation); }
public void SetTranslation_UseStatsAndConfidenceToDeterminePartTranslations() { AddMockedKeyTerm("ask"); AddMockedKeyTerm("give"); AddMockedKeyTerm("want"); AddMockedKeyTerm("whatever"); AddMockedKeyTerm("thing"); TranslatablePhrase phrase1 = new TranslatablePhrase("ABC ask DEF"); TranslatablePhrase phrase2 = new TranslatablePhrase("ABC give XYZ"); TranslatablePhrase phrase3 = new TranslatablePhrase("XYZ want ABC whatever EFG"); TranslatablePhrase phrase4 = new TranslatablePhrase("EFG thing ABC"); PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] { phrase1, phrase2, phrase3, phrase4 }, m_dummyKtList, m_keyTermRules, new List<Substitution>()); ReflectionHelper.SetField(pth, "m_justGettingStarted", false); Assert.AreEqual(2, phrase1.TranslatableParts.Count()); Assert.AreEqual(3, phrase1.GetParts().Count()); Assert.AreEqual(2, phrase2.TranslatableParts.Count()); Assert.AreEqual(3, phrase2.GetParts().Count()); Assert.AreEqual(3, phrase3.TranslatableParts.Count()); Assert.AreEqual(5, phrase3.GetParts().Count()); Assert.AreEqual(2, phrase4.TranslatableParts.Count()); Assert.AreEqual(3, phrase4.GetParts().Count()); phrase1.Translation = "def ASK abc"; phrase2.Translation = "abc xyz GIVE"; phrase3.Translation = "WANT xyz abc WHATEVER efg"; Assert.AreEqual("efg THING abc", phrase4.Translation); }
public void SetTranslation_PreventTranslationFromBeingUsedForMultipleParts() { AddMockedKeyTerm("Jacob", "Jacob"); AddMockedKeyTerm("John", "Juan"); AddMockedKeyTerm("Jesus", "Jesu\u0301s"); AddMockedKeyTerm("Mary", "Mari\u0301a"); AddMockedKeyTerm("Moses", "Moise\u0301s"); TranslatablePhrase phrase1 = new TranslatablePhrase("So what did Jacob do?"); TranslatablePhrase phrase2 = new TranslatablePhrase("So what did Jesus do?"); TranslatablePhrase phrase3 = new TranslatablePhrase("What did Jacob do?"); TranslatablePhrase phrase4 = new TranslatablePhrase("What did Moses ask?"); TranslatablePhrase phrase5 = new TranslatablePhrase("So what did John ask?"); TranslatablePhrase phrase6 = new TranslatablePhrase("So what did Mary want?"); TranslatablePhrase phrase7 = new TranslatablePhrase("What did Moses do?"); TranslatablePhrase phrase8 = new TranslatablePhrase("Did Moses ask, \"What did Jacob do?\""); PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] { phrase1, phrase2, phrase3, phrase4, phrase5, phrase6, phrase7, phrase8 }, m_dummyKtList, m_keyTermRules, new List<Substitution>()); ReflectionHelper.SetField(pth, "m_justGettingStarted", false); Assert.AreEqual(2, phrase1.TranslatableParts.Count()); Assert.AreEqual(3, phrase1.GetParts().Count()); Assert.AreEqual(2, phrase2.TranslatableParts.Count()); Assert.AreEqual(3, phrase2.GetParts().Count()); Assert.AreEqual(2, phrase3.TranslatableParts.Count()); Assert.AreEqual(3, phrase3.GetParts().Count()); Assert.AreEqual(2, phrase4.TranslatableParts.Count()); Assert.AreEqual(3, phrase4.GetParts().Count()); Assert.AreEqual(2, phrase5.TranslatableParts.Count()); Assert.AreEqual(3, phrase5.GetParts().Count()); Assert.AreEqual(2, phrase6.TranslatableParts.Count()); Assert.AreEqual(3, phrase6.GetParts().Count()); Assert.AreEqual(2, phrase7.TranslatableParts.Count()); Assert.AreEqual(3, phrase7.GetParts().Count()); Assert.AreEqual(4, phrase8.TranslatableParts.Count()); Assert.AreEqual(6, phrase8.GetParts().Count()); phrase1.Translation = "\u00BFEntonces que\u0301 hizo Jacob?"; phrase2.Translation = "\u00BFEntonces que\u0301 hizo Jesu\u0301s?"; phrase3.Translation = "\u00BFQue\u0301 hizo Jacob?"; phrase4.Translation = "\u00BFQue\u0301 pregunto\u0301 Moise\u0301s?"; phrase5.Translation = "\u00BFEntonces que\u0301 pregunto\u0301 Juan?"; Assert.AreEqual("\u00BFEntonces que\u0301 Mari\u0301a?", phrase6.Translation); Assert.AreEqual("\u00BFQue\u0301 hizo Moise\u0301s?", phrase7.Translation); Assert.AreEqual("Moise\u0301s pregunto\u0301 Que\u0301 Jacob hizo", phrase8.Translation); }
public void SetTranslation_GuessAtTwoPartPhraseThatDiffersBySingleKeyTerm() { AddMockedKeyTerm("Jacob", "Jacobo"); AddMockedKeyTerm("Matthew", "Mateo"); TranslatablePhrase phrase1 = new TranslatablePhrase("Was Jacob one of the disciples?"); TranslatablePhrase phrase2 = new TranslatablePhrase("Was Matthew one of the disciples?"); PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] { phrase1, phrase2 }, m_dummyKtList, m_keyTermRules, new List<Substitution>()); ReflectionHelper.SetField(pth, "m_justGettingStarted", false); Assert.AreEqual(2, phrase1.TranslatableParts.Count()); Assert.AreEqual(3, phrase1.GetParts().Count()); Assert.AreEqual(2, phrase2.TranslatableParts.Count()); Assert.AreEqual(3, phrase2.GetParts().Count()); const string frame = "\u00BFFue {0} uno de los discipulos?"; phrase1.Translation = string.Format(frame, "Jacobo"); Assert.AreEqual(string.Format(frame, "Jacobo"), phrase1.Translation); Assert.AreEqual(string.Format(frame, "Mateo"), phrase2.Translation); Assert.IsTrue(phrase1.HasUserTranslation); Assert.IsFalse(phrase2.HasUserTranslation); }
public void SetTranslation_GuessAtOnePartPhraseThatDiffersBySingleKeyTerm() { AddMockedKeyTerm("Timothy", "Timoteo"); AddMockedKeyTerm("Euticus", "Eutico"); TranslatablePhrase phrase1 = new TranslatablePhrase("Who was Timothy?"); TranslatablePhrase phrase2 = new TranslatablePhrase("Who was Euticus?"); PhraseTranslationHelper pth = new PhraseTranslationHelper(new[] { phrase1, phrase2 }, m_dummyKtList, m_keyTermRules, new List<Substitution>()); ReflectionHelper.SetField(pth, "m_justGettingStarted", false); Assert.AreEqual(1, phrase1.TranslatableParts.Count()); Assert.AreEqual(2, phrase1.GetParts().Count()); Assert.AreEqual(1, phrase2.TranslatableParts.Count()); Assert.AreEqual(2, phrase2.GetParts().Count()); const string frame = "\u00BFQuie\u0301n era {0}?"; phrase1.Translation = string.Format(frame, "Timoteo"); Assert.AreEqual(string.Format(frame, "Timoteo"), phrase1.Translation); Assert.AreEqual(string.Format(frame, "Eutico"), phrase2.Translation); Assert.IsTrue(phrase1.HasUserTranslation); Assert.IsFalse(phrase2.HasUserTranslation); }