Example #1
0
        public void TestPartOfSpeech()
        {
            UserDictionary dictionary = TestJapaneseTokenizer.ReadDict();

            int[]
            []
            result = dictionary.Lookup("日本経済新聞".toCharArray(), 0, 6);
            assertEquals(3, result.Length);
            int wordIdKeizai = result[1]
                               [0]; // wordId of 経済 in 日本経済新聞

            assertEquals("カスタム名詞", dictionary.GetPartOfSpeech(wordIdKeizai));
        }
Example #2
0
        public void TestReadings()
        {
            UserDictionary dictionary = TestJapaneseTokenizer.ReadDict();

            int[]
            []
            result = dictionary.Lookup("日本経済新聞".toCharArray(), 0, 6);
            assertEquals(3, result.Length);
            int wordIdNihon = result[0]
                              [0]; // wordId of 日本 in 日本経済新聞

            assertEquals("ニホン", dictionary.GetReading(wordIdNihon, "日本".toCharArray(), 0, 2));

            result = dictionary.Lookup("朝青龍".toCharArray(), 0, 3);
            assertEquals(1, result.Length);
            int wordIdAsashoryu = result[0]
                                  [0]; // wordId for 朝青龍

            assertEquals("アサショウリュウ", dictionary.GetReading(wordIdAsashoryu, "朝青龍".toCharArray(), 0, 3));
        }
Example #3
0
        public void TestLookup()
        {
            UserDictionary dictionary = TestJapaneseTokenizer.ReadDict();
            String         s          = "関西国際空港に行った";

            int[][] dictionaryEntryResult = dictionary.Lookup(s.toCharArray(), 0, s.Length);
            // Length should be three 関西, 国際, 空港
            assertEquals(3, dictionaryEntryResult.Length);

            // Test positions
            assertEquals(0, dictionaryEntryResult[0][1]); // index of 関西
            assertEquals(2, dictionaryEntryResult[1][1]); // index of 国際
            assertEquals(4, dictionaryEntryResult[2][1]); // index of 空港

            // Test lengths
            assertEquals(2, dictionaryEntryResult[0][2]); // length of 関西
            assertEquals(2, dictionaryEntryResult[1][2]); // length of 国際
            assertEquals(2, dictionaryEntryResult[2][2]); // length of 空港

            s = "関西国際空港と関西国際空港に行った";
            int[][] dictionaryEntryResult2 = dictionary.Lookup(s.toCharArray(), 0, s.Length);
            // Length should be six
            assertEquals(6, dictionaryEntryResult2.Length);
        }
Example #4
0
        public void TestRead()
        {
            UserDictionary dictionary = TestJapaneseTokenizer.ReadDict();

            assertNotNull(dictionary);
        }