如何像 stackoverflow 搜索结果一样选择部分文本?
我正在寻找高效且快速的 php 解决方案,它可以从文档中选择部分文本并根据关键字对其进行切片,而不会像堆栈溢出搜索引擎那样丢失内容的含义。
我找到了一个 针对 C# 的类似问题,但没有任何示例。
您将如何在 PHP 中实现此类功能?
I'm looking for efficient and fast php solution, that can select portion of text from document and slice it based on keywords without loosing meaning of content similar as stack overflow search engine do.
I found one similar question for C# but without any examples.
How would you implement such functionality in PHP?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我知道这个问题很老了,但我讨厌看到这样的问题得不到答案。不管怎样,你需要使用像Sphinx Search这样的全文搜索引擎。他们有一个 PHP API,带有必要的内置函数来自动标记所选文本。在他们的 API 中查找 BuildExcerpts()。
我只有 Sphinx 的经验,但是,我愿意其他全文引擎也内置此功能。您要查找的关键字是“摘录”。
I know this question is old but I hate seeing questions like this go unanswered. Anyway, you need to use a full-text search engine like Sphinx Search. They have a PHP API with the necessary built-in function to automatically markup the selected text. Look up BuildExcerpts() in their API.
I only have experience with Sphinx, however, I am willing to be other Full text engines have this functionality built in as well. The keyword you're looking for is "excerpts".