• <tfoot id='gvy81'></tfoot>
    <legend id='gvy81'><style id='gvy81'><dir id='gvy81'><q id='gvy81'></q></dir></style></legend>
  • <small id='gvy81'></small><noframes id='gvy81'>

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

      <i id='gvy81'><tr id='gvy81'><dt id='gvy81'><q id='gvy81'><span id='gvy81'><b id='gvy81'><form id='gvy81'><ins id='gvy81'></ins><ul id='gvy81'></ul><sub id='gvy81'></sub></form><legend id='gvy81'></legend><bdo id='gvy81'><pre id='gvy81'><center id='gvy81'></center></pre></bdo></b><th id='gvy81'></th></span></q></dt></tr></i><div id='gvy81'><tfoot id='gvy81'></tfoot><dl id='gvy81'><fieldset id='gvy81'></fieldset></dl></div>
      1. 如何使用 Lucene Analyzer 标记字符串?

        时间:2023-09-30

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

              <bdo id='dph6F'></bdo><ul id='dph6F'></ul>
            • <small id='dph6F'></small><noframes id='dph6F'>

                <tbody id='dph6F'></tbody>

                  <tfoot id='dph6F'></tfoot>
                1. <i id='dph6F'><tr id='dph6F'><dt id='dph6F'><q id='dph6F'><span id='dph6F'><b id='dph6F'><form id='dph6F'><ins id='dph6F'></ins><ul id='dph6F'></ul><sub id='dph6F'></sub></form><legend id='dph6F'></legend><bdo id='dph6F'><pre id='dph6F'><center id='dph6F'></center></pre></bdo></b><th id='dph6F'></th></span></q></dt></tr></i><div id='dph6F'><tfoot id='dph6F'></tfoot><dl id='dph6F'><fieldset id='dph6F'></fieldset></dl></div>
                  本文介绍了如何使用 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 标记字符串?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持html5模板网!

                  上一篇:Lucene 使用 FSDirectory 下一篇:如何在 solr 结果中获得构面范围?

                  相关文章

                  最新文章

                2. <tfoot id='hOuJn'></tfoot>
                  <legend id='hOuJn'><style id='hOuJn'><dir id='hOuJn'><q id='hOuJn'></q></dir></style></legend>

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

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