查找搜索词的偏移量lucene.net,C# [英] Finding offsets of a search term in lucene.net,c#

查看:415
本文介绍了查找搜索词的偏移量lucene.net,C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何能获得该在Lucene.net?I要搜索使用FastVector荧光笔突出显示文本?



注意我的标记偏移:我已经有一个已使用标准分析索引,现在我有兴趣获取特定符号



的偏移所有令牌的偏移量

  testhighlighter TST =新testhighlighter(); 


Lucene.Net.Analysis.Token净额= tokenstream.Next();
INT startoffset = net.StartOffset();
INT endoffset = net.EndOffset();


解决方案

您可以尝试TermVectorMapper获取方面的立场和偏移



http://permalink.gmane.org/gmane.comp.jakarta.lucene.net.user/3203

 类TVM:TermVectorMapper 
{
公共覆盖无效SetExpectations(串场,诠释numTerms,布尔storeOffsets,布尔storePositions)
{
}

公共覆盖无效地图(串词,INT频率,TermVectorOffsetInfo []偏移,INT []位置)
{
}
}

TVM TVM =新TVM( );
reader.GetTermFreqVector(docID的,现场,TVM);


How could I get offsets for the tokens that has to be searched in Lucene.net?I am using FastVector Highlighter for highlighting a text?

Note:I have already got the offsets of all the token that has been indexed using Standard Analyzer and now I would be interested in getting the offsets of the particular token?

 testhighlighter tst = new testhighlighter();


           Lucene.Net.Analysis.Token net = tokenstream.Next();                        
                    int startoffset = net.StartOffset();
                    int endoffset = net.EndOffset();

解决方案

You can try TermVectorMapper to get positions and offsets of terms.

http://permalink.gmane.org/gmane.comp.jakarta.lucene.net.user/3203

class TVM: TermVectorMapper
{
public override void SetExpectations(string field, int numTerms, bool storeOffsets, bool storePositions)
    {
    }

    public override void Map(string term, int frequency, TermVectorOffsetInfo[] offsets, int[] positions)
    {
    }
}

TVM tvm = new TVM();
reader.GetTermFreqVector(docID, field, tvm);

这篇关于查找搜索词的偏移量lucene.net,C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆