@Override public void init(Map<String, String> args) { super.init(args); withOriginal = getBoolean("withOriginal", true); maxPosAsterisk = getInt("maxPosAsterisk", 2); maxPosQuestion = getInt("maxPosQuestion", 1); minTrailing = getInt("minTrailing", 2); maxFractionAsterisk = getFloat("maxFractionAsterisk", 0.0f); }
@Override public void init(Map<String, String> args) { super.init(args); assureMatchVersion(); }
/** * Returns a description of the given analyzer, by either reporting the Analyzer class name (and * optionally luceneMatchVersion) if it's not a TokenizerChain, or if it is, querying each * analysis factory for its name and args. */ protected static SimpleOrderedMap<Object> getAnalyzerProperties(Analyzer analyzer) { SimpleOrderedMap<Object> analyzerProps = new SimpleOrderedMap<>(); if (analyzer instanceof TokenizerChain) { Map<String, String> factoryArgs; TokenizerChain tokenizerChain = (TokenizerChain) analyzer; CharFilterFactory[] charFilterFactories = tokenizerChain.getCharFilterFactories(); if (0 < charFilterFactories.length) { List<SimpleOrderedMap<Object>> charFilterProps = new ArrayList<>(); for (CharFilterFactory charFilterFactory : charFilterFactories) { SimpleOrderedMap<Object> props = new SimpleOrderedMap<>(); props.add(CLASS_NAME, charFilterFactory.getClassArg()); factoryArgs = charFilterFactory.getOriginalArgs(); if (null != factoryArgs) { for (String key : factoryArgs.keySet()) { if (!CLASS_NAME.equals(key)) { if (LUCENE_MATCH_VERSION_PARAM.equals(key)) { if (charFilterFactory.isExplicitLuceneMatchVersion()) { props.add(key, factoryArgs.get(key)); } } else { props.add(key, factoryArgs.get(key)); } } } } charFilterProps.add(props); } analyzerProps.add(CHAR_FILTERS, charFilterProps); } SimpleOrderedMap<Object> tokenizerProps = new SimpleOrderedMap<>(); TokenizerFactory tokenizerFactory = tokenizerChain.getTokenizerFactory(); tokenizerProps.add(CLASS_NAME, tokenizerFactory.getClassArg()); factoryArgs = tokenizerFactory.getOriginalArgs(); if (null != factoryArgs) { for (String key : factoryArgs.keySet()) { if (!CLASS_NAME.equals(key)) { if (LUCENE_MATCH_VERSION_PARAM.equals(key)) { if (tokenizerFactory.isExplicitLuceneMatchVersion()) { tokenizerProps.add(key, factoryArgs.get(key)); } } else { tokenizerProps.add(key, factoryArgs.get(key)); } } } } analyzerProps.add(TOKENIZER, tokenizerProps); TokenFilterFactory[] filterFactories = tokenizerChain.getTokenFilterFactories(); if (0 < filterFactories.length) { List<SimpleOrderedMap<Object>> filterProps = new ArrayList<>(); for (TokenFilterFactory filterFactory : filterFactories) { SimpleOrderedMap<Object> props = new SimpleOrderedMap<>(); props.add(CLASS_NAME, filterFactory.getClassArg()); factoryArgs = filterFactory.getOriginalArgs(); if (null != factoryArgs) { for (String key : factoryArgs.keySet()) { if (!CLASS_NAME.equals(key)) { if (LUCENE_MATCH_VERSION_PARAM.equals(key)) { if (filterFactory.isExplicitLuceneMatchVersion()) { props.add(key, factoryArgs.get(key)); } } else { props.add(key, factoryArgs.get(key)); } } } } filterProps.add(props); } analyzerProps.add(FILTERS, filterProps); } } else { // analyzer is not instanceof TokenizerChain analyzerProps.add(CLASS_NAME, analyzer.getClass().getName()); if (analyzer.getVersion() != Version.LATEST) { analyzerProps.add(LUCENE_MATCH_VERSION_PARAM, analyzer.getVersion().toString()); } } return analyzerProps; }