/** * Ensure the filter actually decomposes text. */ public void testWordBreak() throws Exception { assumeTrue("JRE does not support Thai dictionary-based BreakIterator", ThaiWordFilter.DBBI_AVAILABLE); Reader reader = new StringReader("การที่ได้ต้องแสดงว่างานดี"); TokenStream stream = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false); stream = tokenFilterFactory("ThaiWord").create(stream); assertTokenStreamContents(stream, new String[] {"การ", "ที่", "ได้", "ต้อง", "แสดง", "ว่า", "งาน", "ดี"}); }
/** Test that bogus arguments result in exception */ public void testBogusArguments() throws Exception { assumeTrue("JRE does not support Thai dictionary-based BreakIterator", ThaiWordFilter.DBBI_AVAILABLE); try { tokenFilterFactory("ThaiWord", "bogusArg", "bogusValue"); fail(); } catch (IllegalArgumentException expected) { assertTrue(expected.getMessage().contains("Unknown parameters")); } }
/** * Ensure the filter actually decomposes text. */ public void testWordBreak() throws Exception { assumeTrue("JRE does not support Thai dictionary-based BreakIterator", ThaiWordFilter.DBBI_AVAILABLE); Reader reader = new StringReader("การที่ได้ต้องแสดงว่างานดี"); Tokenizer tokenizer = new MockTokenizer(reader, MockTokenizer.WHITESPACE, false); ThaiWordFilterFactory factory = new ThaiWordFilterFactory(); factory.setLuceneMatchVersion(TEST_VERSION_CURRENT); Map<String, String> args = Collections.emptyMap(); factory.init(args); TokenStream stream = factory.create(tokenizer); assertTokenStreamContents(stream, new String[] {"การ", "ที่", "ได้", "ต้อง", "แสดง", "ว่า", "งาน", "ดี"}); }
@Override public ThaiWordFilter create(TokenStream input) { return new ThaiWordFilter(input); }
@Override public ThaiWordFilter create(TokenStream input) { assureMatchVersion(); return new ThaiWordFilter(luceneMatchVersion, input); }
@Override public ThaiWordFilter create(TokenStream input) { return new ThaiWordFilter(luceneMatchVersion, input); }