feat: scan

This commit is contained in:
hashbro
2026-09-13 02:12:06 +08:00
parent d7bd4d1b03
commit 1746e7b485
13 changed files with 266 additions and 40 deletions
+10 -2
View File
@@ -237,8 +237,8 @@ class MnemonicDetector
}
/**
* Keep list indices (1. 2. 12) from breaking a phrase, but digits/units
* like 200 or 1.5 split a run so "pipe 200 cable" is not 12 words.
* Keep list indices (1 / 1. / 1.during / 12)wrist) from breaking a phrase,
* but digits/units like 200 or 1.5 split a run so "pipe 200 cable" is not 12 words.
*
* @return list<string>
*/
@@ -247,6 +247,9 @@ class MnemonicDetector
$out = [];
foreach (preg_split('/\s+/u', strtolower($text)) ?: [] as $raw) {
$word = trim($raw, ".,!?;:\"'()[]");
if ($word === '') {
continue;
}
if (preg_match('/^[a-z]{3,8}$/', $word) === 1) {
$out[] = $word;
@@ -255,6 +258,11 @@ class MnemonicDetector
if (preg_match('/^\d{1,2}\.?$/', $word) === 1) {
continue;
}
if (preg_match('/^\d{1,2}[.)\]、.::]?([a-z]{3,8})$/u', $word, $m) === 1) {
$out[] = $m[1];
continue;
}
$out[] = '';
}