Lucene Entity Extraction

江枫思渺然 提交于 2019-12-22 08:07:02

问题


Given a finite dictionary of entity terms, I'm looking for a way to do Entity Extraction with intelligent tagging using Lucene. Currently I've been able to use Lucene for:
- Searching for complex phrases with some fuzzyness
- Highlighting results

However, I 'm not aware how to:
-Get accurate offsets of the matched phrases
-Do entity-specific annotaions per match(not just tags for every single hit)

I have tried using the explain() method - but this only gives the terms in the query which got the hit - not the offsets of the hit within the original text.

Has anybody faced a similar problem and is willing to share a potential solution?

Thank you in advance for you help!


回答1:


For the offset, see this question: How get the offset of term in Lucene?

I don't quite understand your second question. It sounds to me like you want to get the data from a stored field though. To get the data from a stored field:

TopDocs results = searcher.Search(query, filter, num);
foreach (ScoreDoc result in results.scoreDocs)
{
    Document resultDoc = searcher.Doc(result.doc);
    string valOfField = resultDoc.Get("My Field");
}


来源:https://stackoverflow.com/questions/4199382/lucene-entity-extraction

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!