• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

Java CharFilterFactory类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

本文整理汇总了Java中org.apache.lucene.analysis.util.CharFilterFactory的典型用法代码示例。如果您正苦于以下问题:Java CharFilterFactory类的具体用法?Java CharFilterFactory怎么用?Java CharFilterFactory使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。



CharFilterFactory类属于org.apache.lucene.analysis.util包,在下文中一共展示了CharFilterFactory类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的Java代码示例。

示例1: doTestTokenizer

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
private void doTestTokenizer(String tokenizer) throws IOException {
  Class<? extends TokenizerFactory> factoryClazz = TokenizerFactory.lookupClass(tokenizer);
  TokenizerFactory factory = (TokenizerFactory) initialize(factoryClazz);
  if (factory != null) {
    // we managed to fully create an instance. check a few more things:
    
    // if it implements MultiTermAware, sanity check its impl
    if (factory instanceof MultiTermAwareComponent) {
      AbstractAnalysisFactory mtc = ((MultiTermAwareComponent) factory).getMultiTermComponent();
      assertNotNull(mtc);
      // its not ok to return e.g. a charfilter here: but a tokenizer could wrap a filter around it
      assertFalse(mtc instanceof CharFilterFactory);
    }
    
    // beast it just a little, it shouldnt throw exceptions:
    // (it should have thrown them in initialize)
    checkRandomData(random(), new FactoryAnalyzer(factory, null, null), 100, 20, false, false);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:TestFactories.java


示例2: doTestCharFilter

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
private void doTestCharFilter(String charfilter) throws IOException {
  Class<? extends CharFilterFactory> factoryClazz = CharFilterFactory.lookupClass(charfilter);
  CharFilterFactory factory = (CharFilterFactory) initialize(factoryClazz);
  if (factory != null) {
    // we managed to fully create an instance. check a few more things:
    
    // if it implements MultiTermAware, sanity check its impl
    if (factory instanceof MultiTermAwareComponent) {
      AbstractAnalysisFactory mtc = ((MultiTermAwareComponent) factory).getMultiTermComponent();
      assertNotNull(mtc);
      // its not ok to return a tokenizer or tokenfilter here, this makes no sense
      assertTrue(mtc instanceof CharFilterFactory);
    }
    
    // beast it just a little, it shouldnt throw exceptions:
    // (it should have thrown them in initialize)
    checkRandomData(random(), new FactoryAnalyzer(assertingTokenizer, null, factory), 100, 20, false, false);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:20,代码来源:TestFactories.java


示例3: doTestTokenizer

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
private void doTestTokenizer(String tokenizer) throws IOException {
  TokenizerFactory factory = TokenizerFactory.forName(tokenizer);
  if (initialize(factory)) {
    // we managed to fully create an instance. check a few more things:
    
    // if it implements MultiTermAware, sanity check its impl
    if (factory instanceof MultiTermAwareComponent) {
      AbstractAnalysisFactory mtc = ((MultiTermAwareComponent) factory).getMultiTermComponent();
      assertNotNull(mtc);
      // its not ok to return e.g. a charfilter here: but a tokenizer could wrap a filter around it
      assertFalse(mtc instanceof CharFilterFactory);
    }
    
    // beast it just a little, it shouldnt throw exceptions:
    // (it should have thrown them in initialize)
    checkRandomData(random(), new FactoryAnalyzer(factory, null, null), 100, 20, false, false);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:TestFactories.java


示例4: doTestCharFilter

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
private void doTestCharFilter(String charfilter) throws IOException {
  CharFilterFactory factory = CharFilterFactory.forName(charfilter);
  if (initialize(factory)) {
    // we managed to fully create an instance. check a few more things:
    
    // if it implements MultiTermAware, sanity check its impl
    if (factory instanceof MultiTermAwareComponent) {
      AbstractAnalysisFactory mtc = ((MultiTermAwareComponent) factory).getMultiTermComponent();
      assertNotNull(mtc);
      // its not ok to return a tokenizer or tokenfilter here, this makes no sense
      assertTrue(mtc instanceof CharFilterFactory);
    }
    
    // beast it just a little, it shouldnt throw exceptions:
    // (it should have thrown them in initialize)
    checkRandomData(random(), new FactoryAnalyzer(assertingTokenizer, null, factory), 100, 20, false, false);
  }
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:19,代码来源:TestFactories.java


示例5: reloadLuceneSPI

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
/**
 * Reloads all Lucene SPI implementations using the new classloader.
 * This method must be called after the new classloader has been created to
 * register the services for use.
 */
static void reloadLuceneSPI(ClassLoader loader) {
    // do NOT change the order of these method calls!

    // Codecs:
    PostingsFormat.reloadPostingsFormats(loader);
    DocValuesFormat.reloadDocValuesFormats(loader);
    Codec.reloadCodecs(loader);
    // Analysis:
    CharFilterFactory.reloadCharFilters(loader);
    TokenFilterFactory.reloadTokenFilters(loader);
    TokenizerFactory.reloadTokenizers(loader);
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:18,代码来源:PluginsService.java


示例6: lookupAnalysisClass

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
/**
 * This method looks up a class with its fully qualified name (FQN), or a short-name
 * class-simplename, or with a package suffix, assuming "org.apache.lucene.analysis."
 * as the package prefix (e.g. "standard.ClassicTokenizerFactory" ->
 * "org.apache.lucene.analysis.standard.ClassicTokenizerFactory").
 *
 * If className contains a period, the class is first looked up as-is, assuming that it
 * is an FQN.  If this fails, lookup is retried after prepending the Lucene analysis
 * package prefix to the class name.
 *
 * If className does not contain a period, the analysis SPI *Factory.lookupClass()
 * methods are used to find the class.
 *
 * @param className The name or the short name of the class.
 * @param expectedType The superclass className is expected to extend
 * @return the loaded class.
 * @throws ClassNotFoundException if lookup fails
 */
public <T> Class<? extends T> lookupAnalysisClass(String className, Class<T> expectedType)
    throws ClassNotFoundException {
  if (className.contains(".")) {
    try {
      // First, try className == FQN
      return Class.forName(className).asSubclass(expectedType);
    } catch (ClassNotFoundException e) {
      try {
        // Second, retry lookup after prepending the Lucene analysis package prefix
        return Class.forName(LUCENE_ANALYSIS_PACKAGE_PREFIX + className).asSubclass(expectedType);
      } catch (ClassNotFoundException e1) {
        throw new ClassNotFoundException("Can't find class '" + className
                                         + "' or '" + LUCENE_ANALYSIS_PACKAGE_PREFIX + className + "'");
      }
    }
  }
  // No dot - use analysis SPI lookup
  final String analysisComponentName = ANALYSIS_COMPONENT_SUFFIX_PATTERN.matcher(className).replaceFirst("");
  if (CharFilterFactory.class.isAssignableFrom(expectedType)) {
    return CharFilterFactory.lookupClass(analysisComponentName).asSubclass(expectedType);
  } else if (TokenizerFactory.class.isAssignableFrom(expectedType)) {
    return TokenizerFactory.lookupClass(analysisComponentName).asSubclass(expectedType);
  } else if (TokenFilterFactory.class.isAssignableFrom(expectedType)) {
    return TokenFilterFactory.lookupClass(analysisComponentName).asSubclass(expectedType);
  }

  throw new ClassNotFoundException("Can't find class '" + className + "'");
}
 
开发者ID:europeana,项目名称:search,代码行数:47,代码来源:AnalyzerFactoryTask.java


示例7: AnalyzerFactory

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
public AnalyzerFactory(List<CharFilterFactory> charFilterFactories,
                       TokenizerFactory tokenizerFactory,
                       List<TokenFilterFactory> tokenFilterFactories) {
  this.charFilterFactories = charFilterFactories;
  assert null != tokenizerFactory;
  this.tokenizerFactory = tokenizerFactory;
  this.tokenFilterFactories = tokenFilterFactories;
}
 
开发者ID:europeana,项目名称:search,代码行数:9,代码来源:AnalyzerFactory.java


示例8: toString

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
@Override
public String toString() {
  StringBuilder sb = new StringBuilder("AnalyzerFactory(");
  if (null != name) {
    sb.append("name:");
    sb.append(name);
    sb.append(", ");
  }
  if (null != positionIncrementGap) {
    sb.append("positionIncrementGap:");
    sb.append(positionIncrementGap);
    sb.append(", ");
  }
  if (null != offsetGap) {
    sb.append("offsetGap:");
    sb.append(offsetGap);
    sb.append(", ");
  }
  for (CharFilterFactory charFilterFactory: charFilterFactories) {
    sb.append(charFilterFactory);
    sb.append(", ");
  }
  sb.append(tokenizerFactory);
  for (TokenFilterFactory tokenFilterFactory : tokenFilterFactories) {
    sb.append(", ");
    sb.append(tokenFilterFactory);
  }
  sb.append(')');
  return sb.toString();
}
 
开发者ID:europeana,项目名称:search,代码行数:31,代码来源:AnalyzerFactory.java


示例9: test

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
public void test() throws IOException {
  for (String tokenizer : TokenizerFactory.availableTokenizers()) {
    doTestTokenizer(tokenizer);
  }
  
  for (String tokenFilter : TokenFilterFactory.availableTokenFilters()) {
    doTestTokenFilter(tokenFilter);
  }
  
  for (String charFilter : CharFilterFactory.availableCharFilters()) {
    doTestCharFilter(charFilter);
  }
}
 
开发者ID:europeana,项目名称:search,代码行数:14,代码来源:TestFactories.java


示例10: initReader

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
@Override
public Reader initReader(String fieldName, Reader reader) {
  if (charFilters != null && charFilters.length > 0) {
    Reader cs = reader;
    for (CharFilterFactory charFilter : charFilters) {
      cs = charFilter.create(cs);
    }
    reader = cs;
  }
  return reader;
}
 
开发者ID:europeana,项目名称:search,代码行数:12,代码来源:TokenizerChain.java


示例11: reloadLuceneSPI

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
/**
 * Reloads all Lucene SPI implementations using the new classloader.
 * This method must be called after {@link #addToClassLoader(String, FileFilter, boolean)}
 * and {@link #addToClassLoader(String,FileFilter,boolean)} before using
 * this ResourceLoader.
 */
void reloadLuceneSPI() {
  // Codecs:
  PostingsFormat.reloadPostingsFormats(this.classLoader);
  DocValuesFormat.reloadDocValuesFormats(this.classLoader);
  Codec.reloadCodecs(this.classLoader);
  // Analysis:
  CharFilterFactory.reloadCharFilters(this.classLoader);
  TokenFilterFactory.reloadTokenFilters(this.classLoader);
  TokenizerFactory.reloadTokenizers(this.classLoader);
}
 
开发者ID:europeana,项目名称:search,代码行数:17,代码来源:SolrResourceLoader.java


示例12: add

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
public void add(Object current)
{
    if (!(current instanceof MultiTermAwareComponent))
        return;
    AbstractAnalysisFactory newComponent = ((MultiTermAwareComponent) current).getMultiTermComponent();
    if (newComponent instanceof TokenFilterFactory)
    {
        if (filters == null)
        {
            filters = new ArrayList<TokenFilterFactory>(2);
        }
        filters.add((TokenFilterFactory) newComponent);
    }
    else if (newComponent instanceof TokenizerFactory)
    {
        tokenizer = (TokenizerFactory) newComponent;
    }
    else if (newComponent instanceof CharFilterFactory)
    {
        if (charFilters == null)
        {
            charFilters = new ArrayList<CharFilterFactory>(1);
        }
        charFilters.add((CharFilterFactory) newComponent);

    }
    else
    {
        throw new SolrException(SolrException.ErrorCode.SERVER_ERROR, "Unknown analysis component from MultiTermAwareComponent: " + newComponent);
    }
}
 
开发者ID:Alfresco,项目名称:community-edition-old,代码行数:32,代码来源:AlfrescoFieldType.java


示例13: init

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
@Override
protected void init(IndexSchema schema, Map<String, String> args) {
  super.init(schema, args);
  String p = args.remove("precisionStep");
  if (p != null) {
     precisionStepArg = Integer.parseInt(p);
  }
  // normalize the precisionStep
  precisionStep = precisionStepArg;
  if (precisionStep<=0 || precisionStep>=64) precisionStep=Integer.MAX_VALUE;
  String t = args.remove("type");

  if (t != null) {
    try {
      type = TrieTypes.valueOf(t.toUpperCase(Locale.ROOT));
    } catch (IllegalArgumentException e) {
      throw new SolrException(SolrException.ErrorCode.SERVER_ERROR,
              "Invalid type specified in schema.xml for field: " + args.get("name"), e);
    }
  }

  CharFilterFactory[] filterFactories = new CharFilterFactory[0];
  TokenFilterFactory[] tokenFilterFactories = new TokenFilterFactory[0];
  analyzer = new TokenizerChain(filterFactories, new TrieTokenizerFactory(type, precisionStep), tokenFilterFactories);
  // for query time we only need one token, so we use the biggest possible precisionStep:
  queryAnalyzer = new TokenizerChain(filterFactories, new TrieTokenizerFactory(type, Integer.MAX_VALUE), tokenFilterFactories);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:28,代码来源:TrieField.java


示例14: reloadLuceneSPI

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
/**
 * Reloads all Lucene SPI implementations using the new classloader.
 * This method must be called after {@link #addToClassLoader(String)}
 * and {@link #addToClassLoader(String,FileFilter)} before using
 * this ResourceLoader.
 */
void reloadLuceneSPI() {
  // Codecs:
  PostingsFormat.reloadPostingsFormats(this.classLoader);
  DocValuesFormat.reloadDocValuesFormats(this.classLoader);
  Codec.reloadCodecs(this.classLoader);
  // Analysis:
  CharFilterFactory.reloadCharFilters(this.classLoader);
  TokenFilterFactory.reloadTokenFilters(this.classLoader);
  TokenizerFactory.reloadTokenizers(this.classLoader);
}
 
开发者ID:pkarmstr,项目名称:NYBC,代码行数:17,代码来源:SolrResourceLoader.java


示例15: testCharFilters

import org.apache.lucene.analysis.util.CharFilterFactory; //导入依赖的package包/类
public void testCharFilters() {
    Set<String> missing = new TreeSet<String>(org.apache.lucene.analysis.util.CharFilterFactory.availableCharFilters());
    missing.removeAll(getCharFilters().keySet());
    assertTrue("new charfilters found, please update KNOWN_CHARFILTERS: " + missing.toString(), missing.isEmpty());
}
 
开发者ID:justor,项目名称:elasticsearch_my,代码行数:6,代码来源:AnalysisFactoryTestCase.java



注:本文中的org.apache.lucene.analysis.util.CharFilterFactory类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Java IRecipeInput类代码示例发布时间:2022-05-22
下一篇:
Java LongColumnVector类代码示例发布时间:2022-05-22
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap