Browse Source

提取单词的时候判断长度

visuddhinanda 1 year ago
parent
commit
82a7b62b48
1 changed files with 2 additions and 5 deletions
  1. 2 5
      api-v8/app/Console/Commands/UpgradeCompound.php

+ 2 - 5
api-v8/app/Console/Commands/UpgradeCompound.php

@@ -149,7 +149,8 @@ class UpgradeCompound extends Command
                 $to = $max;
             }
             $words = WordIndex::whereBetween('id', [$from, $to])
-                ->where('len', '>', $this->option('min'))
+                ->where('len', '>=', $this->option('min'))
+                ->where('len', '<=', $this->option('max'))
                 ->orderBy('id')
                 ->selectRaw('id,word as real')
                 ->cursor();
@@ -224,10 +225,6 @@ class UpgradeCompound extends Command
                 }
             }
             if (count($parts) === 0) {
-                if (mb_strlen($word->real, 'UTF-8') > $this->option('max')) {
-                    Log::error('超长,give up' . $word->real);
-                    continue;
-                }
                 $ts = new TurboSplit();
                 if ($this->option('debug')) {
                     $ts->debug(true);