Commit 5b59101f authored by Martin Gregor's avatar Martin Gregor
Browse files

oprava parsovania viet

parent ac421a57
......@@ -56,7 +56,7 @@ class AdminPresenter extends BasePresenter
if ($values->paragraph)
{
$success = TRUE;
foreach (explode('.',$values->paragraph) as $sentence)
foreach (preg_split('/(?<=[.!?]|[.!?][\'"])(?!\d)\s+(?!\d)(?=[A-Z])/',$values->paragraph, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY) as $sentence)
{
if (!$this->insertSentence($sentence))
{
......@@ -73,7 +73,7 @@ class AdminPresenter extends BasePresenter
private function insertSentence($sentence)
{
$sentence = trim($sentence,'  "\'„“.');
$sentence = trim($sentence,'  "\'„“');
$word_count = count(explode(' ',$sentence));
$exists = $this->db->table('sentences')->where(['sentence' => $sentence])->count('*');
if ($word_count > 5 && !$exists)
......@@ -98,7 +98,7 @@ class AdminPresenter extends BasePresenter
{
$dom = HtmlDomParser::file_get_html( $url );
$text = $dom->find('#article-box #itext_content',0)->plaintext;
$sentences = preg_split('/[.?!]/',$text);
$sentences = preg_split('/(?<=[.!?]|[.!?][\'"])(?!\d)\s+(?!\d)(?=[A-Z])/ ',$text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
foreach ($sentences as $sentence)
{
$this->insertSentence($sentence);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment