<bdo id='jfrWG'></bdo><ul id='jfrWG'></ul>

    <tfoot id='jfrWG'></tfoot>
  1. <small id='jfrWG'></small><noframes id='jfrWG'>

    <legend id='jfrWG'><style id='jfrWG'><dir id='jfrWG'><q id='jfrWG'></q></dir></style></legend>
  2. <i id='jfrWG'><tr id='jfrWG'><dt id='jfrWG'><q id='jfrWG'><span id='jfrWG'><b id='jfrWG'><form id='jfrWG'><ins id='jfrWG'></ins><ul id='jfrWG'></ul><sub id='jfrWG'></sub></form><legend id='jfrWG'></legend><bdo id='jfrWG'><pre id='jfrWG'><center id='jfrWG'></center></pre></bdo></b><th id='jfrWG'></th></span></q></dt></tr></i><div id='jfrWG'><tfoot id='jfrWG'></tfoot><dl id='jfrWG'><fieldset id='jfrWG'></fieldset></dl></div>

    1. 如何使用 Lucene Analyzer 标记字符串?

      How to use a Lucene Analyzer to tokenize a String?(如何使用 Lucene Analyzer 标记字符串?)

      1. <legend id='BjGNk'><style id='BjGNk'><dir id='BjGNk'><q id='BjGNk'></q></dir></style></legend>
      2. <small id='BjGNk'></small><noframes id='BjGNk'>

          • <bdo id='BjGNk'></bdo><ul id='BjGNk'></ul>
            <i id='BjGNk'><tr id='BjGNk'><dt id='BjGNk'><q id='BjGNk'><span id='BjGNk'><b id='BjGNk'><form id='BjGNk'><ins id='BjGNk'></ins><ul id='BjGNk'></ul><sub id='BjGNk'></sub></form><legend id='BjGNk'></legend><bdo id='BjGNk'><pre id='BjGNk'><center id='BjGNk'></center></pre></bdo></b><th id='BjGNk'></th></span></q></dt></tr></i><div id='BjGNk'><tfoot id='BjGNk'></tfoot><dl id='BjGNk'><fieldset id='BjGNk'></fieldset></dl></div>

              <tbody id='BjGNk'></tbody>
                <tfoot id='BjGNk'></tfoot>
                本文介绍了如何使用 Lucene Analyzer 标记字符串?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                问题描述

                有没有一种简单的方法可以使用 Lucene 的 Analyzer 的任何子类来解析/标记 String?

                Is there a simple way I could use any subclass of Lucene's Analyzer to parse/tokenize a String?

                类似:

                String to_be_parsed = "car window seven";
                Analyzer analyzer = new StandardAnalyzer(...);
                List<String> tokenized_string = analyzer.analyze(to_be_parsed);
                

                推荐答案

                据我所知,你必须自己编写循环.像这样的东西(直接取自我的源代码树):

                As far as I know, you have to write the loop yourself. Something like this (taken straight from my source tree):

                public final class LuceneUtils {
                
                    public static List<String> parseKeywords(Analyzer analyzer, String field, String keywords) {
                
                        List<String> result = new ArrayList<String>();
                        TokenStream stream  = analyzer.tokenStream(field, new StringReader(keywords));
                
                        try {
                            while(stream.incrementToken()) {
                                result.add(stream.getAttribute(TermAttribute.class).term());
                            }
                        }
                        catch(IOException e) {
                            // not thrown b/c we're using a string reader...
                        }
                
                        return result;
                    }  
                }
                

                这篇关于如何使用 Lucene Analyzer 标记字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

                相关文档推荐

                Lucene Porter Stemmer not public(Lucene Porter Stemmer 未公开)
                How to index pdf, ppt, xl files in lucene (java based or python or php any of these is fine)?(如何在 lucene 中索引 pdf、ppt、xl 文件(基于 java 或 python 或 php 中的任何一个都可以)?)
                KeywordAnalyzer and LowerCaseFilter/LowerCaseTokenizer(KeywordAnalyzer 和 LowerCaseFilter/LowerCaseTokenizer)
                How to search between dates (Hibernate Search)?(如何在日期之间搜索(休眠搜索)?)
                How to get positions from a document term vector in Lucene?(如何从 Lucene 中的文档术语向量中获取位置?)
                Java Lucene 4.5 how to search by case insensitive(Java Lucene 4.5如何按不区分大小写进行搜索)

                    <bdo id='fjHHp'></bdo><ul id='fjHHp'></ul>
                      <tbody id='fjHHp'></tbody>

                      <i id='fjHHp'><tr id='fjHHp'><dt id='fjHHp'><q id='fjHHp'><span id='fjHHp'><b id='fjHHp'><form id='fjHHp'><ins id='fjHHp'></ins><ul id='fjHHp'></ul><sub id='fjHHp'></sub></form><legend id='fjHHp'></legend><bdo id='fjHHp'><pre id='fjHHp'><center id='fjHHp'></center></pre></bdo></b><th id='fjHHp'></th></span></q></dt></tr></i><div id='fjHHp'><tfoot id='fjHHp'></tfoot><dl id='fjHHp'><fieldset id='fjHHp'></fieldset></dl></div>
                      <tfoot id='fjHHp'></tfoot>

                          <small id='fjHHp'></small><noframes id='fjHHp'>

                          <legend id='fjHHp'><style id='fjHHp'><dir id='fjHHp'><q id='fjHHp'></q></dir></style></legend>