Some checks failed
ci / 정본·보안·린트·타입·테스트 (push) Has been cancelled
deploy-site / deploy (push) Has been cancelled
ci / 워크스페이스 빌드 검증 (push) Has been cancelled
ci / 모바일 린트·타입·Jest (push) Has been cancelled
ci / Supabase Edge Functions + Cloudflare Worker (push) Has been cancelled
ci / .NET API 서버 테스트 (push) Has been cancelled
Typo auto-correct (INPUT-19) - TypoCorrectionService + core typo-correction: 2-set Korean layout mistypes both ways, always-wrong spellings, near-misses of the user's frequent words, optional model check re-validated in core; applied by backspace N + paste and cancelled on new keys or window change. Prediction quality (INPUT-20/21) - gemma models are sent raw with the user's unfinished sentence pre-filled into the model turn, so the model truly continues the text (mid-word joins and spacing exact). Other models keep the instruction prompt. - Context: text before the caret (opening lines and a fact list of names, dates, amounts outside the 400-char window), messages just sent in the same chat window (memory only, 30 min), personal-graph follow-ups and IDF-ranked related sentences with Korean stemming. - Guards: first sentence only, restated-prefix stripping (also fixes the instruction path), repeat drop, no invented dates/names/numbers (one retry), plain -다 register, no emoji unless the user uses them, search-box keywords. Fill loop mixes instruction prompts for variety. - Opt-in real-model probe: tests/integration/suggestion-quality.ollama.test.ts Suggestions now actually show up - Terminal (Claude Code): caret trust from the input line, not the whole screen (status line below the box blocked every keystroke); Korean composition counts as typing at the end; a grey placeholder filling the empty box at once is not user text. - Chrome: UIA focus flicker while typing no longer resets "edited". - KakaoTalk/RichEdit: trailing paragraph mark ignored for edit position and stripped so accepted text keeps its separating space. - While the overlay is visible the suggestion shortcuts are captured so Ctrl+Alt+Enter no longer also types a newline; released when hidden. - nut-js preloaded after boot (first accept waited 4.8 s).
80 lines
3.7 KiB
TypeScript
80 lines
3.7 KiB
TypeScript
// packages/core/__tests__/writing-context.test.ts
|
|
// 제안 문맥 분석 + 그래프 관련 문장 점수.
|
|
|
|
import { describe, expect, it } from 'vitest'
|
|
import {
|
|
analyzeWritingContext,
|
|
detectSentenceRegister,
|
|
detectWritingLanguage
|
|
} from '../src/writing-context'
|
|
import { buildQueryTerms, scoreRelatedNodes } from '../src/personal-graph'
|
|
|
|
describe('analyzeWritingContext', () => {
|
|
it('문장 중간이면 지금 문장과 직전 문장을 나누고 마저 쓰기 모드', () => {
|
|
const context = analyzeWritingContext('어제 배포는 잘 끝났습니다. 오늘은 모니터링 결과를')
|
|
expect(context.lastSentence).toBe('어제 배포는 잘 끝났습니다.')
|
|
expect(context.currentSentence).toBe('오늘은 모니터링 결과를')
|
|
expect(context.mode).toBe('complete-sentence')
|
|
expect(context.language).toBe('ko')
|
|
expect(context.register).toBe('formal')
|
|
})
|
|
|
|
it('종결 부호로 끝나면 다음 문장 모드', () => {
|
|
const context = analyzeWritingContext('회의 자료 보냈어요. 확인해 주세요! ')
|
|
expect(context.currentSentence).toBe('')
|
|
expect(context.lastSentence).toBe('확인해 주세요!')
|
|
expect(context.earlierText).toBe('회의 자료 보냈어요.')
|
|
expect(context.mode).toBe('next-sentence')
|
|
expect(context.register).toBe('polite')
|
|
})
|
|
|
|
it('줄바꿈도 문장 경계다', () => {
|
|
const context = analyzeWritingContext('안녕하세요\n다음 주 일정')
|
|
expect(context.lastSentence).toBe('안녕하세요')
|
|
expect(context.currentSentence).toBe('다음 주 일정')
|
|
})
|
|
|
|
it('언어 판별', () => {
|
|
expect(detectWritingLanguage('Thanks for the update')).toBe('en')
|
|
expect(detectWritingLanguage('今日は会議があります')).toBe('ja')
|
|
expect(detectWritingLanguage('')).toBe('other')
|
|
})
|
|
|
|
it('말투 판별', () => {
|
|
expect(detectSentenceRegister('확인했습니다.')).toBe('formal')
|
|
expect(detectSentenceRegister('확인했어요')).toBe('polite')
|
|
expect(detectSentenceRegister('확인했어')).toBe('casual')
|
|
expect(detectSentenceRegister('Done.')).toBeNull()
|
|
})
|
|
})
|
|
|
|
describe('scoreRelatedNodes', () => {
|
|
const now = Date.UTC(2026, 9, 3)
|
|
const nodes = [
|
|
{ text: '금요일 배포 전에 테스트를 끝내야 합니다', terms: ['금요일', '배포', '테스트'], count: 3, lastUsedAt: now, appName: 'slack.exe' },
|
|
{ text: '점심은 뭐 먹을까요', terms: ['점심', '먹을까요'], count: 9, lastUsedAt: now, appName: 'slack.exe' },
|
|
{ text: '배포 일정 공유드립니다', terms: ['배포', '일정', '공유드립니다'], count: 1, lastUsedAt: now - 30 * 86400000, appName: null }
|
|
]
|
|
|
|
it('겹치는 주제어가 많은 문장을 앞세우고, 무관한 문장은 빼낸다', () => {
|
|
const terms = buildQueryTerms([{ text: '이번 배포 테스트는', weight: 2 }])
|
|
const ranked = scoreRelatedNodes({ terms, now, appName: 'slack.exe' }, nodes)
|
|
expect(ranked[0].text).toBe('금요일 배포 전에 테스트를 끝내야 합니다')
|
|
expect(ranked.map((item) => item.text)).not.toContain('점심은 뭐 먹을까요')
|
|
})
|
|
|
|
it('저장된 옛 용어(조사 포함)도 어간으로 맞춘다', () => {
|
|
const terms = buildQueryTerms([{ text: '배포 일정', weight: 1 }])
|
|
const ranked = scoreRelatedNodes(
|
|
{ terms, now },
|
|
[{ text: '배포가 밀렸어요', terms: ['배포가', '밀렸어요'], count: 1, lastUsedAt: now, appName: null }]
|
|
)
|
|
expect(ranked).toHaveLength(1)
|
|
})
|
|
|
|
it('제외 조건을 지킨다', () => {
|
|
const terms = buildQueryTerms([{ text: '배포', weight: 1 }])
|
|
const ranked = scoreRelatedNodes({ terms, now, exclude: (text) => text.startsWith('금요일') }, nodes)
|
|
expect(ranked.map((item) => item.text)).toEqual(['배포 일정 공유드립니다'])
|
|
})
|
|
})
|