X-Git-Url: https://git.localhorst.tv/?a=blobdiff_plain;f=app%2FModels%2FChatLib.php;fp=app%2FModels%2FChatLib.php;h=3f1530b396b9b752652918c45d9f0a0fdea3d596;hb=26d47ca368d8e7c2690cec49f6ae2ad509a0428d;hp=c89ef941be5f4c2802eb89c92cc2be6dd7bcfd9d;hpb=64f5be008ef28c812cb7ed87149f4eb86f6021eb;p=alttp.git diff --git a/app/Models/ChatLib.php b/app/Models/ChatLib.php index c89ef94..3f1530b 100644 --- a/app/Models/ChatLib.php +++ b/app/Models/ChatLib.php @@ -22,7 +22,7 @@ class ChatLib { $end = $num; for ($i = $start; $i < $end; ++$i) { $this->addTransition(array_slice($tokens, $i, $end - $i), $token); - if ($end - $i < 4) break; + if ($end - $i < 5) break; } } } @@ -75,6 +75,8 @@ class ChatLib { if (is_array(end($entry['examples']))) { // already processed $examples = $entry['examples']; + } else if ($key === ' ') { + $examples = [[' ', 0, 1]]; } else { $subsum = 0; foreach ($entry['examples'] as $example => $subweight) { @@ -162,6 +164,8 @@ class ChatLib { $str = ''; foreach ($tokens as $token) { $replaced = preg_replace('/\d+/', '0', $token); + $replaced = preg_replace('/\s+/', ' ', $token); + $replaced = preg_replace('/(.)\1{2,}/', '$1', $token); $replaced = strtolower($replaced); $str .= $replaced; } @@ -173,7 +177,7 @@ class ChatLib { return $example[0]; } - private $size = 5; + private $size = 7; private $transitions = []; }