问题描述
我正在做一个关于文本摘要的PHP项目(使用Codeigniter),为此,我需要从Rich TextBox的内容(此内容包括标签)中提取句子。因此,是否有适当的方法或Codeigniter库从包含HTML标签的内容中提取句子?
I'm doing a PHP project (using Codeigniter) on text summarization and for that I need to extract sentences from content of a Rich TextBox (this content includes tags). Therefore is there a proper method or Codeigniter library to extract sentences from a content containing HTML tags?
推荐答案
php函数应该可以为您提供帮助。它返回没有php和html标签的字符串。如果只需要计数句子,则可以执行 count(explode(。,$ text))。分隔符是句子的典型结尾。
A php function strip_tags() should help you. It returns string without php and html tags. If you just need to count sentences, you could do count(explode(". ", $text)) The delimiter is a typical end of a sentence.
简单而受限制,但不需要任何库。
Plain simple and limited, but doesn't require any libraries.
这篇关于从PHP中的HTML提取句子的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!