本文介紹了如何將段落拆分為句子的處理方法,對大家解決問題具有一定的參考價值,需要的朋友們下面隨著小編來一起學習吧!
問題描述
我一直在嘗試使用:
$string="The Dr. is here!!! I am glad I'm in the U.S.A. for the Dr. quality is great!!!!!!";
preg_match_all('~.*?[?.!]~s',$string,$sentences);
print_r($sentences);
但它不適用于 Dr., U.S.A. 等
But it doesn't work on Dr., U.S.A., etc.
大家有更好的建議嗎?
推薦答案
沒有任何簡單的解決方案.您需要在應用程序中進行一些自然語言處理 (NLP) 并識別每個句子.有一種叫做 OpenNLP 的東西,它是一個基于 JAVA 的 NLP 解析器工具.或者 Stanford NLP 解析器 Ruby.你可以為 php 找到類似的東西.
there is not any simple solution for that. you need do some natural language processing(NLP) in your application and recognize each sentence. there is something call OpenNLP, it's a JAVA-based NLP parser tool. Or Stanford NLP parser in Ruby. you can find something like that for php.
這里 我在 PHP 中找到了一組用于自然語言處理的類.
here I found a set of classes for natural language processing in PHP.
這篇關于如何將段落拆分為句子的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!
【網站聲明】本站部分內容來源于互聯網,旨在幫助大家更快的解決問題,如果有圖片或者內容侵犯了您的權益,請聯系我們刪除處理,感謝您的支持!