您的位置:时间博客>PHP>PHP实现英语短文自动拆句

PHP实现英语短文自动拆句

需求: 用户输入一篇英语短文系统自动拆分成句子。

短文示例: 

Do you know the 2022 world Cup will be held in Qatar? And FIFA has made a big decision.The 2022 Qatar World Cup will be held in November and December.It is the first time FIFA has moved he event from its traditional summer to winter.


业务实现:

// 安装自然语言处理(NLP)库
composer require yooper/php-text-analysis

$english = 'xxx此处为上方短文示例xxx';
$driver = new \TextAnalysis\Tokenizers\SentenceTokenizer();
$sentences = $driver->tokenize($english);


执行结果:

Array    
(    
    [0] => Do you know the 2022 world Cup will be held in Qatar?    
    [1] => And FIFA has made a big decision.    
    [2] => The 2022 Qatar World Cup will be held in November and December.    
    [3] => It is the first time FIFA has moved he event from its traditional summer to winter.    
)


转载请注明本文标题和链接:《 PHP实现英语短文自动拆句
分享到:

相关推荐

网友评论 0

未登陆 表情
Ctrl+Enter快速提交