fix(input,core): fix live punctuation typo triggers, expected insert cleanup, and ngram scan
This commit is contained in:
parent
a37dd63909
commit
2a009e421a
8 changed files with 640 additions and 53 deletions
|
|
@ -947,11 +947,11 @@ export function isUrlOrPathRun(prefix: string, tokenStart: number, tokenEnd: num
|
|||
if (run.includes('://')) return true
|
||||
if (/^(?:www\.|~\/|\.\/|\.\.\/|localhost:)/iu.test(run)) return true
|
||||
if ((run.match(/\//gu)?.length ?? 0) >= 2) return true
|
||||
if (/[A-Za-z0-9]\.[A-Za-z]{2,}\//u.test(run)) return true
|
||||
if (/[A-Za-z0-9]\.[A-Za-z]{2,}[/?]/u.test(run)) return true
|
||||
if (/[A-Za-z0-9._+-]@[A-Za-z0-9]/u.test(run)) return true
|
||||
if (/[\\_$#`<>{}=]/u.test(run)) return true
|
||||
|
||||
// 토큰 바로 앞이나 뒤가 도메인 점(example.com)인 경우 (단, L.A.fh 처럼 대문자 약어 뒤 조사는 허용)
|
||||
// 토큰 바로 앞이나 뒤가 도메인 점(example.com)인 경우 (단, L.A.fh 처럼 대문자 약어 뒤 조사와 한글 말줄임표(...) 뒤 한영 오타는 허용)
|
||||
const before = prefix[tokenStart - 1] ?? ''
|
||||
const after = prefix[tokenEnd] ?? ''
|
||||
if (after === '.' && /[A-Za-z]/u.test(prefix[tokenEnd + 1] ?? '')) return true
|
||||
|
|
@ -959,7 +959,8 @@ export function isUrlOrPathRun(prefix: string, tokenStart: number, tokenEnd: num
|
|||
const beforeDot = prefix.slice(runStart, tokenStart)
|
||||
const tokenText = prefix.slice(tokenStart, tokenEnd)
|
||||
const isAbbrevWithParticle = /^(?:[A-Z]\.){2,}$/u.test(beforeDot) && PARTICLE_KEYS.has(tokenText)
|
||||
if (!isAbbrevWithParticle) return true
|
||||
const isHangulEllipsis = /[가-힣ㄱ-ㆎ][!?~]*\.{2,}$/u.test(beforeDot)
|
||||
if (!isAbbrevWithParticle && !isHangulEllipsis) return true
|
||||
}
|
||||
if (before === ':' || after === ':') {
|
||||
const beforeColon = prefix.slice(runStart, tokenStart)
|
||||
|
|
|
|||
|
|
@ -169,8 +169,7 @@ export class PersonalNgramModel {
|
|||
const extends_ = (word: string) => word.length > partial.length && word.startsWith(partial)
|
||||
first = context.length > 0 ? this._next(context, extends_, passes) : null
|
||||
if (!first) {
|
||||
const unigram = new Map([...this._unigram].filter(([word]) => extends_(word)))
|
||||
const pick = best(unigram, () => true)
|
||||
const pick = best(this._unigram, extends_)
|
||||
first = passes(pick) ? pick : null
|
||||
}
|
||||
joint = 'attach'
|
||||
|
|
|
|||
|
|
@ -2024,6 +2024,8 @@ function resolveTokenAsEnglishPreview(tokenText: string): string | null {
|
|||
return null
|
||||
}
|
||||
|
||||
const WORD_BOUNDARY_AFTER_RE = /[ \t.,!?;:~…?!。]/u
|
||||
|
||||
/**
|
||||
* 커서 앞 구간에서 결정적으로 확실한 오타를 찾는다.
|
||||
*
|
||||
|
|
@ -2120,7 +2122,7 @@ export function detectTypos(prefix: string, options: TypoDetectOptions = {}): Ty
|
|||
afterEnglishWord,
|
||||
nextIsEnglish,
|
||||
nextEnglishWord,
|
||||
hasWordBoundaryAfter: /[ \t.,!?;:]/u.test(after),
|
||||
hasWordBoundaryAfter: WORD_BOUNDARY_AFTER_RE.test(after),
|
||||
vocabulary: options.vocabulary
|
||||
})
|
||||
|
||||
|
|
@ -2199,7 +2201,7 @@ export function detectTypos(prefix: string, options: TypoDetectOptions = {}): Ty
|
|||
!options.terminalMode &&
|
||||
/^(?:self|selves)$/iu.test(token.text) &&
|
||||
index > 0 &&
|
||||
(/[ \t.,!?;:]/u.test(after) || !options.layoutOnly)
|
||||
(WORD_BOUNDARY_AFTER_RE.test(after) || !options.layoutOnly)
|
||||
) {
|
||||
const prevToken = tokens[index - 1]
|
||||
if (
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue