Skip to content

Commit 6655907

Browse files
committed
fix: isCJK
1 parent bd11847 commit 6655907

2 files changed

Lines changed: 5 additions & 3 deletions

File tree

‎src/expander/expand.ts‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,15 @@
33
*/
44

55
import type { QueryExpansionOptions } from '../types';
6+
import { containsCJK } from '../utils';
67

78
const WORD_BOUNDARY_RE = /[\s,,。.!!??;;::\(\)\[\]{}""''\"\'\-_\/\\|@#$%^&*+=<>~`]/;
89

910
function containsTerm(text: string, term: string): boolean {
1011
if (!text.includes(term)) return false;
1112

1213
// CJK terms use substring match
13-
const isCJK = /[一-鿿㐀-䶿豈-﫿]/.test(term);
14-
if (isCJK) return true;
14+
if (containsCJK(term)) return true;
1515

1616
// Latin terms use word boundary match
1717
let searchFrom = 0;

‎src/reranker/helpers.ts‎

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
1+
import { containsCJK } from '../utils';
2+
13
const WORD_BOUNDARY = /[\s\n.,;:!?,。!?、:;"'((【《\-_]/;
24

35
export function tokenizeQuery(query: string): string[] {
46
const tokens = query.split(/[\s,,。.!!??、::;;]+/).filter(Boolean);
57
const result: string[] = [];
68
for (const r of tokens) {
79
result.push(r);
8-
if (/[一-鿿]{3,}/.test(r)) {
10+
if (containsCJK(r)) {
911
for (let i = 0; i + 2 <= r.length; i++) result.push(r.slice(i, i + 2));
1012
}
1113
}

0 commit comments

Comments
 (0)