关键字邻近匹配 - 选项?
我有一个案例,我有一系列关键字。我想在给定的字符串中找到它们的匹配项,并在每个字符串之前和之后返回 x 个单词数。
我可以编写一个循环引擎,遍历每个数组,返回给定的索引,并根据这些循环执行连接的子字符串,但这似乎有点冗长。
我听说过 Lucene,但不确定实现整个框架来执行此操作是否值得。另外,如果可以的话,我该如何用Lucene来完成呢?
谢谢。
I have a case where I have an array of keywords. I want to find their matches within a given string and return x number of words before and after each.
I could write a looping engine that goes through an array of each, returning a given index, and performing concatenated sub-strings based on those loops, but this seems a bit lengthy.
I've heard of Lucene, but not sure if implementing an entire framework to do this is worth it. Also, if possible, how can I accomplish with Lucene?
Thanks.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
也许正则表达式会有所帮助......
这会构建一个匹配字符串列表(之前最多 3 个单词)关键字(之后最多 3 个单词)
编辑:我错过了几个 0 和一些 @。再试一次。
Perhaps regular expressions would help...
This builds a list of matching strings (up to 3 words before) keyword (up to 3 words after)
Edit: I missed a couple 0s and some @s. Try again.