Sub-sentences and paragraphs
In the php environment, I pointed out a misunderstanding of the original clause. the decimal point and domain name are not considered for the clause. because the standard sentence is followed by a space, the only thing to consider is Mr. li.
The section-based approach is to consider that some references end with a colon.
- /* TWWY's ART */
- Function break_passage ($ text) {// split a paragraph
- Return preg_split ("/(\ r | \ n | \ r \ n)/", $ text,-1, PREG_SPLIT_NO_EMPTY );
- }
- Function break_sentence ($ text) {// separate sentences with spaces after the English periods
- $ Re = '/# Split sentences on whitespace between them.
- (? <= # Begin positive lookbehind.
- [.!?] # Either an end of sentence punct,
- | [.!?] [\ '"] # Or end of sentence punct and quote.
- ) # End positive lookbehind.
- (? Mr \. # Skip either "Mr ."
- | Mrs \. # or "Mrs .",
- | Ms \. # or "Ms .",
- | Jr \. # or "Jr .",
- | Dr \. # or "Dr .",
- | Prof \. # or "Prof .",
- | Sr \. # or "Sr .",
- # Or... (you get the idea ).
- ) # End negative lookbehind.
- \ S + # Split on whitespace between sentences.
- /Ix ';
- $ Sentences = preg_split ($ re, $ text,-1, PREG_SPLIT_NO_EMPTY );
- Return $ sentences;
- }
- Function get_sentence ($ text) {// splits a paragraph before dividing a sentence. [recommended]
- $ Passage = break_passage ($ text );
- $ Return = array ();
- Foreach ($ passage as $ key => $ value) $ return = array_merge ($ return, break_sentence ($ value ));
- Return $ return;
- }
- ?>
|