private bool SearchAutoDectectInput(string inputWord)
 {
     if (StringHelper.IBasicLatinOnly(inputWord))
     {
         var hira = RomaConvert.ConvertRomaToHiraFullLoop(inputWord);
         if (!SearchRawJapInput(hira))
         {
             if (!SearchEnglish(inputWord))
             {
                 return(SearchJapanese(hira));
             }
             else
             {
                 return(true);
             }
         }
         else
         {
             return(true);
         }
     }
     else
     {
         return(SearchJapanese(inputWord));
     }
 }
        public void TestHiraToRomaPhrase()
        {
            string hiragana = "そのことばにじいくはけんそんをすることもなく、また、こうていをすることもなく、おだやかなびえみのひょうじょうだけをみせてくれた。";
            string actual   = RomaConvert.ConvertHiraToRomaFullLoop(hiragana);
            string expected = "sonokotobanijiikuhakensonwosurukotomonaku、mata、kouteiwosurukotomonaku、odayakanabieminohyoujoudakewomisetekureta。";

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
        public void TestRomaToHiraAllSilentVowel()
        {
            string hiragana = "wworrottoyyoppossoddoffuggohhojjokkozzokkoommo";
            string actual   = RomaConvert.ConvertRomaToHiraFullLoop(hiragana);
            string expected = "っをっろっとっよっぽっそっどっふっごっほっじょっこっぞっこおっも";

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
        public void TestKataToRomaAllSilentVowel()
        {
            string kata     = "ッヲッロットッヨッポッソッドッフッゴッホッジョッコッゾッコンオッモッ";
            string actual   = RomaConvert.ConvertKataToRomaFullLoop(kata);
            string expected = "wworrottoyyoppossoddoffuggohhojjokkozzokkonommo";

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
        public void TestRomaToHiraSilentVowel()
        {
            string hiragana = "「kaettadesuka?」 toitteimasu。";
            string actual   = RomaConvert.ConvertRomaToHiraFullLoop(hiragana);
            string expected = "「かえったですか?」 といっています。";

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
        public void TestKataToRomaSilentVowel()
        {
            string kata     = "「カエッタデスカ?」 トイッテイマス。";
            string actual   = RomaConvert.ConvertKataToRomaFullLoop(kata);
            string expected = "「kaettadesuka?」 toitteimasu。";

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
        public void TestKataToRomaPhrase()
        {
            string kata     = "ソノコトバニジークハケンソンヲスルコトモナク、マタ、コウテイヲスルコトモナク、オダヤカナビエミノヒョウジョウダケヲミセテクレタ。";
            string actual   = RomaConvert.ConvertKataToRomaFullLoop(kata);
            string expected = "sonokotobaniji-kuhakensonwosurukotomonaku、mata、kouteiwosurukotomonaku、odayakanabieminohyoujoudakewomisetekureta。";

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
 public void TestRomaToHiraFullTableFullLoop()
 {
     using (var file = File.OpenRead("./ConvertClasses/Resource/TableTest.txt"))
         using (var reader = new StreamReader(file))
         {
             while (!reader.EndOfStream)
             {
                 var    line     = reader.ReadLine().Split('@');
                 string actual   = RomaConvert.ConvertRomaToHiraFullLoop(line[0]);
                 string expected = line[1];
                 Assert.AreEqual(expected, actual);
             }
         }
 }
Exemplo n.º 9
0
        private static string[] MakeSureCorrectWords(List <WordInformation> words, string[] results)
        {
            if (results.Length != words.Count)
            {
                Debug.WriteLine("WordInformationViewModel.ConvertPronunicationToRomaji: String contains token word -> use extreme slow method");
                results = new string[words.Count];
                //WARNING: This is very slow
                for (int i = 0; i < words.Count; i++)
                {
                    results[i] = RomaConvert.ConvertKataToRomaFullLoop(words[i].Pronunciation);
                }
            }

            return(results);
        }
Exemplo n.º 10
0
        private static string[] ConvertPronunicationToRomaji(List <WordInformation> words)
        {
            StringBuilder builder = new StringBuilder();

            for (int i = 0; i < words.Count - 1; i++)
            {
                builder.Append(words[i].Pronunciation);
                builder.Append("\nRomaji\n");
            }
            builder.Append(words[words.Count - 1].Pronunciation);

            var results = RomaConvert.ConvertKataToRomaFullLoop(builder)
                          .Split(new string[] { "\nRomaji\n" }, StringSplitOptions.None);

            results = MakeSureCorrectWords(words, results);
            return(results);
        }
        public void TestKataExtend()
        {
            string roma     = "fafifefofyuwiwevavivevotsatsitsocheshejetelitoluyeulodelidelyukwavu";
            string actual   = RomaConvert.ConvertRomaToHiraFullLoop(roma);
            string expected = "ふぁふぃふぇふぉふゅうぃうぇヴぁヴぃヴぇヴぉつぁつぃつぉちぇしぇじぇてぃとぅいぇうぉでぃでゅくぁヴ";

            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }

            string kata = "ファフィフェフォフュウィウェヴァヴィヴェヴォツァツィツォチェシェジェティトゥイェウォディデュクァヴ";

            actual   = RomaConvert.ConvertKataToRomaFullLoop(kata);
            expected = "fafifefofyuwiwevavivevotsatsitsocheshejetituyewodidukwavu";
            for (int i = 0; i < expected.Length; i++)
            {
                Assert.AreEqual(expected[i], actual[i]);
            }
        }
        private bool SearchRomaji(string inputWord)
        {
            var hira = RomaConvert.ConvertRomaToHiraFullLoop(inputWord);

            return(SearchJapanese(hira));
        }