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

    <tfoot id='Y8hfh'></tfoot>
      1. <legend id='Y8hfh'><style id='Y8hfh'><dir id='Y8hfh'><q id='Y8hfh'></q></dir></style></legend>

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

      2. 在 Lucene.net 2.9.2 中突出显示整个句子

        时间:2023-09-14

        <legend id='7eTXY'><style id='7eTXY'><dir id='7eTXY'><q id='7eTXY'></q></dir></style></legend>

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

          • <bdo id='7eTXY'></bdo><ul id='7eTXY'></ul>

            <small id='7eTXY'></small><noframes id='7eTXY'>

                  <tbody id='7eTXY'></tbody>
                  本文介绍了在 Lucene.net 2.9.2 中突出显示整个句子的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

                  问题描述

                  目前我正在使用 Lucene.net 2.9.2 框架.作为我的搜索结果,我想获得带有突出显示的文本片段的结果页面(asp.net).我希望所选片段是一个整个句子,而不仅仅是几个单词.

                  Currently I'm working with the Lucene.net 2.9.2 framework. As a result of my search I would like to achieve result page (asp.net) with highlighted text fragment. I would like that the selected fragment is a whole sentence and not only few words.

                  例如,如果我有文字:

                  Lorem ipsum dolor sit amet,consectetur adipisicing elit,sed do eiusmod tempor incididunt ut labore et dolore magna aliqua.Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur.Exceptioneur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

                  Lorem ipsum dolor sit amet, consectetur adipisicing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

                  我正在搜索 cupidatat 我想获取片段:

                  and I'm searching for cupidatat I would like to get fragment:

                  Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.

                  我现在的代码是:

                  var scorer = new QueryScorer(q);
                  var formatter = new SimpleHTMLFormatter("<div>", "</div>");
                  
                  var highlighter = new Highlighter(formatter, scorer);
                  highlighter.SetTextFragmenter(new SimpleFragmenter(100));
                  
                  var fragments = highlighter.GetBestFragments(stream, text, 1);
                  

                  但它只返回大小为 100 的文本范围.

                  but it returns only text range of size 100.

                  如有任何建议,我将不胜感激.

                  I will be thankful for any suggestion.

                  推荐答案

                  你想创建一个新的 Fragmenter(类似于 SimpleFragmenter).您需要调整的功能是:

                  You want to create a new Fragmenter (Similar to SimpleFragmenter). The function you need to adjust is:

                  public virtual bool IsNewFragment(Token token)
                  {
                      bool isNewFrag = token.EndOffset() >= (fragmentSize * currentNumFrags);
                      if (isNewFrag)
                      {
                          currentNumFrags++;
                      }
                  
                      return isNewFrag;
                  }
                  

                  这可能需要一些调整,直到你得到正确的逻辑,但这应该会给你一个很好的开端

                  This will likely need some adjustment until you get the correct logic, but that should give you a pretty good head start

                  这篇关于在 Lucene.net 2.9.2 中突出显示整个句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

                  上一篇:在 SQL 数据库中进行手动更改时,Lucene.Net 索引更新 下一篇:Lucene.Net 模糊搜索速度

                  相关文章

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

                    1. <legend id='Gdtv2'><style id='Gdtv2'><dir id='Gdtv2'><q id='Gdtv2'></q></dir></style></legend>

                    2. <tfoot id='Gdtv2'></tfoot>
                        <bdo id='Gdtv2'></bdo><ul id='Gdtv2'></ul>
                    3. <small id='Gdtv2'></small><noframes id='Gdtv2'>