| @@ 167-171 (lines=5) @@ | ||
| 164 | ||
| 165 | /* Then look for the first sentence ending. We could probably use a nice regex, but for now this will do */ |
|
| 166 | $words = preg_split('/\s+/', $paragraph); |
|
| 167 | foreach ($words as $i => $word) { |
|
| 168 | if (preg_match('/(!|\?|\.)$/', $word) && !preg_match('/(Dr|Mr|Mrs|Ms|Miss|Sr|Jr|No)\.$/i', $word)) { |
|
| 169 | return implode(' ', array_slice($words, 0, $i+1)); |
|
| 170 | } |
|
| 171 | } |
|
| 172 | ||
| 173 | /* If we didn't find a sentence ending, use the summary. We re-call rather than using paragraph so that |
|
| 174 | * Summary will limit the result this time */ |
|
| @@ 101-105 (lines=5) @@ | ||
| 98 | if( !$paragraph ) return ""; |
|
| 99 | ||
| 100 | $words = preg_split('/\s+/', $paragraph); |
|
| 101 | foreach ($words as $i => $word) { |
|
| 102 | if (preg_match('/(!|\?|\.)$/', $word) && !preg_match('/(Dr|Mr|Mrs|Ms|Miss|Sr|Jr|No)\.$/i', $word)) { |
|
| 103 | return implode(' ', array_slice($words, 0, $i+1)); |
|
| 104 | } |
|
| 105 | } |
|
| 106 | ||
| 107 | /* If we didn't find a sentence ending, use the summary. We re-call rather than using paragraph so that |
|
| 108 | * Summary will limit the result this time */ |
|