public void inform(ResourceLoader loader) { try { org.apache.lucene.analysis.CharArraySet cas = getWordSet(loader, keepTagFiles, false); keepTags = new HashSet<String>(); for (Object element : cas) { char chars[] = (char[]) element; keepTags.add(new String(chars)); } } catch (IOException e) { throw new RuntimeException(e); } }
public GosenPartOfSpeechKeepFilterFactory(Map<String, String> args) { super(args); keepTagFiles = require(args, "tags"); if (args.containsKey("enablePositionIncrements")) { throw new IllegalArgumentException("enablePositionIncrements is not a valid option as of Lucene 5.0"); } if (!args.isEmpty()) { throw new IllegalArgumentException("Unknown parameters: " + args); } }
@Test public void testBasics() throws IOException { String tags = "# verb-main:\n" + "動詞-自立\n"; GosenTokenizerFactory tokenizerFactory = new GosenTokenizerFactory(new HashMap<String,String>(){{ put("dictionaryDir", SenTestUtil.IPADIC_DIR); }}); tokenizerFactory.inform(new StringMockResourceLoader("")); Tokenizer tokenizer = tokenizerFactory.create(); tokenizer.setReader(new StringReader("私は制限スピードを超える。")); Map<String,String> args = new HashMap<String,String>(); args.put("luceneMatchVersion", Version.LATEST.toString()); args.put("tags", "stoptags.txt"); GosenPartOfSpeechKeepFilterFactory factory = new GosenPartOfSpeechKeepFilterFactory(args); factory.inform(new StringMockResourceLoader(tags)); TokenStream ts = factory.create(tokenizer); assertTokenStreamContents(ts, new String[] { "超える" } ); }
@Test public void testRequireArguments() throws Exception{ try{ new GosenPartOfSpeechKeepFilterFactory(new HashMap<String, String>() {{ put("bogusArg", "bogusValue"); }}); fail(); } catch (IllegalArgumentException expected) { assertTrue(expected.getMessage().contains("Configuration Error: missing parameter ")); } }
@Test public void testBogusArguments() throws Exception{ try{ new GosenPartOfSpeechKeepFilterFactory(new HashMap<String, String>() {{ put("tags", "tags"); put("bogusArg", "bogusValue"); }}); fail(); } catch (IllegalArgumentException expected) { assertTrue(expected.getMessage().contains("Unknown parameters")); } } }
public void inform(ResourceLoader loader) { try { org.apache.lucene.analysis.CharArraySet cas = getWordSet(loader, keepTagFiles, false); keepTags = new HashSet<String>(); for (Object element : cas) { char chars[] = (char[]) element; keepTags.add(new String(chars)); } } catch (IOException e) { throw new RuntimeException(e); } }
public GosenPartOfSpeechKeepFilterFactory(Map<String, String> args) { super(args); keepTagFiles = require(args, "tags"); if (args.containsKey("enablePositionIncrements")) { throw new IllegalArgumentException("enablePositionIncrements is not a valid option as of Lucene 5.0"); } if (!args.isEmpty()) { throw new IllegalArgumentException("Unknown parameters: " + args); } }