当前位置: 首页>>代码示例>>Java>>正文


Java JapaneseTokenizer类代码示例

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


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

示例1: TokenizerWrapper

import org.codelibs.neologd.ipadic.lucene.analysis.ja.JapaneseTokenizer; //导入依赖的package包/类
TokenizerWrapper() {
    super();

    tokenizerTimestamp = dictionaryTimestamp;
    tokenizer = new JapaneseTokenizer(userDictionary, discartPunctuation, mode);

    try {
        Field attributesField = getAccessibleField(AttributeSource.class, "attributes");
        final Object attributesObj = attributesField.get(tokenizer);
        attributesField.set(this, attributesObj);

        Field attributeImplsField = getAccessibleField(AttributeSource.class, "attributeImpls");
        final Object attributeImplsObj = attributeImplsField.get(tokenizer);
        attributeImplsField.set(this, attributeImplsObj);

        Field currentStateField = getAccessibleField(AttributeSource.class, "currentState");
        final Object currentStateObj = currentStateField.get(tokenizer);
        currentStateField.set(this, currentStateObj);
    } catch (final Exception e) {
        throw new IllegalStateException(
                "Failed to update the tokenizer.", e);
    }
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-kuromoji-neologd,代码行数:24,代码来源:ReloadableKuromojiTokenizerFactory.java

示例2: KuromojiAnalyzerProvider

import org.codelibs.neologd.ipadic.lucene.analysis.ja.JapaneseTokenizer; //导入依赖的package包/类
public KuromojiAnalyzerProvider(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, name, settings);
    final Set<?> stopWords =
            Analysis.parseStopWords(env, indexSettings.getIndexVersionCreated(), settings, JapaneseAnalyzer.getDefaultStopSet());
    final JapaneseTokenizer.Mode mode = KuromojiTokenizerFactory.getMode(settings);
    final UserDictionary userDictionary = KuromojiTokenizerFactory.getUserDictionary(env, settings);
    analyzer = new JapaneseAnalyzer(userDictionary, mode, CharArraySet.copy(stopWords), JapaneseAnalyzer.getDefaultStopTags());
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-kuromoji-neologd,代码行数:9,代码来源:KuromojiAnalyzerProvider.java

示例3: getMode

import org.codelibs.neologd.ipadic.lucene.analysis.ja.JapaneseTokenizer; //导入依赖的package包/类
public static JapaneseTokenizer.Mode getMode(Settings settings) {
    JapaneseTokenizer.Mode mode = JapaneseTokenizer.DEFAULT_MODE;
    String modeSetting = settings.get("mode", null);
    if (modeSetting != null) {
        if ("search".equalsIgnoreCase(modeSetting)) {
            mode = JapaneseTokenizer.Mode.SEARCH;
        } else if ("normal".equalsIgnoreCase(modeSetting)) {
            mode = JapaneseTokenizer.Mode.NORMAL;
        } else if ("extended".equalsIgnoreCase(modeSetting)) {
            mode = JapaneseTokenizer.Mode.EXTENDED;
        }
    }
    return mode;
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-kuromoji-neologd,代码行数:15,代码来源:KuromojiTokenizerFactory.java

示例4: create

import org.codelibs.neologd.ipadic.lucene.analysis.ja.JapaneseTokenizer; //导入依赖的package包/类
@Override
public Tokenizer create() {
    return new JapaneseTokenizer(userDictionary, discartPunctuation, mode);
}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-kuromoji-neologd,代码行数:5,代码来源:KuromojiTokenizerFactory.java

示例5: ReloadableKuromojiTokenizerFactory

import org.codelibs.neologd.ipadic.lucene.analysis.ja.JapaneseTokenizer; //导入依赖的package包/类
public ReloadableKuromojiTokenizerFactory(IndexSettings indexSettings, Environment env, String name, Settings settings) {
    super(indexSettings, name, settings);
    this.env = env;
    this.settings = settings;
    mode = KuromojiTokenizerFactory.getMode(settings);
    userDictionary = KuromojiTokenizerFactory.getUserDictionary(env,
            settings);
    discartPunctuation = settings.getAsBoolean("discard_punctuation", true);

    inputPendingField = getAccessibleField(Tokenizer.class, "inputPending");
    userDictionaryField = getAccessibleField(JapaneseTokenizer.class, "userDictionary");
    userFSTField = getAccessibleField(JapaneseTokenizer.class, "userFST");
    userFSTReaderField = getAccessibleField(JapaneseTokenizer.class, "userFSTReader");
    dictionaryMapField = getAccessibleField(JapaneseTokenizer.class, "dictionaryMap");

    dictionaryTimestamp = System.currentTimeMillis();

    final String monitoringFilePath = settings.get("user_dictionary");
    if (monitoringFilePath != null) {
        Path path = env.configFile().resolve(monitoringFilePath);

        try {
            final File file = path.toFile();
            if (file.exists()) {
                reloadableFile = file;
                dictionaryTimestamp = reloadableFile.lastModified();

                reloadInterval = settings.getAsTime("reload_interval",
                        TimeValue.timeValueMinutes(1)).getMillis();

                if (VERBOSE) {
                    System.out.println("Check "
                            + reloadableFile.getAbsolutePath()
                            + " (interval: " + reloadInterval + "ms)");
                }
            }
        } catch (Exception e) {
            throw new IllegalArgumentException(
                    "Could not access " + monitoringFilePath, e);
        }
    }

}
 
开发者ID:codelibs,项目名称:elasticsearch-analysis-kuromoji-neologd,代码行数:44,代码来源:ReloadableKuromojiTokenizerFactory.java

示例6: NeologdJapaneseTokenizer

import org.codelibs.neologd.ipadic.lucene.analysis.ja.JapaneseTokenizer; //导入依赖的package包/类
public NeologdJapaneseTokenizer() {
    this.tokenizer = new JapaneseTokenizer(new StringReader(""), null, false, JapaneseTokenizer.Mode.NORMAL);
}
 
开发者ID:redpen-cc,项目名称:redpen,代码行数:4,代码来源:NeologdJapaneseTokenizer.java


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