mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-11-24 16:46:18 -08:00
refactor(tokenizer): consolidate kana/POS helpers into token-classification (#161)
This commit is contained in:
1 parent
14070acceb
commit
21a06c12fb
11 files changed
+302
-396
No files matched your search
@@ -25,6 +25,7 @@ import {
|
||||
requestYomitanTermFrequencies,
|
||||
} from './tokenizer/yomitan-parser-runtime';
|
||||
import type { YomitanTermFrequency } from './tokenizer/yomitan-parser-runtime';
|
||||
import { isKanaChar } from './tokenizer/token-classification';
|
||||
|
||||
const logger = createLogger('main:tokenizer');
|
||||
|
||||
@@ -322,20 +323,6 @@ function normalizeFrequencyLookupText(rawText: string): string {
|
||||
return rawText.trim().toLowerCase();
|
||||
}
|
||||
|
||||
function isKanaChar(char: string): boolean {
|
||||
const code = char.codePointAt(0);
|
||||
if (code === undefined) {
|
||||
return false;
|
||||
}
|
||||
return (
|
||||
(code >= 0x3041 && code <= 0x3096) ||
|
||||
(code >= 0x309b && code <= 0x309f) ||
|
||||
code === 0x30fc ||
|
||||
(code >= 0x30a0 && code <= 0x30fa) ||
|
||||
(code >= 0x30fd && code <= 0x30ff)
|
||||
);
|
||||
}
|
||||
|
||||
function getTrailingKanaSuffix(surface: string): string {
|
||||
const chars = Array.from(surface);
|
||||
let splitIndex = chars.length;
|
||||
|
||||
Reference in new issue
Block a user