Java 类org.apache.lucene.analysis.ja.TestJapaneseTokenizer 实例源码

项目:search    文件:UserDictionaryTest.java   
@Test
public void testLookup() throws IOException {
  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);
}
项目:NYBC    文件:UserDictionaryTest.java   
@Test
public void testLookup() throws IOException {
  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);
}
项目:Maskana-Gestor-de-Conocimiento    文件:UserDictionaryTest.java   
@Test
public void testLookup() throws IOException {
  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);
}
项目:search    文件:UserDictionaryTest.java   
@Test
public void testReadings() throws IOException {
  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));
}
项目:search    文件:UserDictionaryTest.java   
@Test
public void testPartOfSpeech() throws IOException {
  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));
}
项目:NYBC    文件:UserDictionaryTest.java   
@Test
public void testReadings() throws IOException {
  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));
}
项目:NYBC    文件:UserDictionaryTest.java   
@Test
public void testPartOfSpeech() throws IOException {
  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));
}
项目:Maskana-Gestor-de-Conocimiento    文件:UserDictionaryTest.java   
@Test
public void testReadings() throws IOException {
  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));
}
项目:Maskana-Gestor-de-Conocimiento    文件:UserDictionaryTest.java   
@Test
public void testPartOfSpeech() throws IOException {
  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));
}
项目:search    文件:UserDictionaryTest.java   
@Test
public void testRead() throws IOException {
  UserDictionary dictionary = TestJapaneseTokenizer.readDict();
  assertNotNull(dictionary);
}
项目:NYBC    文件:UserDictionaryTest.java   
@Test
public void testRead() throws IOException {
  UserDictionary dictionary = TestJapaneseTokenizer.readDict();
  assertNotNull(dictionary);
}
项目:Maskana-Gestor-de-Conocimiento    文件:UserDictionaryTest.java   
@Test
public void testRead() throws IOException {
  UserDictionary dictionary = TestJapaneseTokenizer.readDict();
  assertNotNull(dictionary);
}