feat(desktop): typo auto-correct and context-aware sentence prediction
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).
This commit is contained in:
Yun Chan 2026-10-03 21:48:28 +09:00
parent 5ca3709b32
commit 3cac14f668
56 changed files with 4700 additions and 258 deletions

View file

@ -9,6 +9,14 @@ import {
renderInstruction,
type RenderedInstruction,
} from '@d3ro/core/instruction-template'
import {
analyzeDocumentContext,
analyzeWritingContext,
type WritingContext,
type WritingLanguage,
type WritingRegister
} from '@d3ro/core/writing-context'
import { containsEmoji } from '@d3ro/core/input-intelligence'
const logger = getLogger('llm-prompts')
@ -174,7 +182,7 @@ export { BASE_SYSTEM_PROMPTS }
// ============================================================
/**
* 추론 모델이 `thinking` 블록을 지 않게 하는 prefix.
* 추론 모델이 `thinking` 블록을 쓰지 않게 하는 prefix.
*
* `LocalLLMService.processText` 가 같은 목적으로 쓰는 값과 같다. 제안 경로는
* `streamGenerate` 를 직접 부르므로 여기서 직접 붙인다.
@ -182,31 +190,71 @@ export { BASE_SYSTEM_PROMPTS }
export const SUGGESTION_NO_THINK_PREFIX = '/no_think'
/**
* 제안 시스템 프롬프트.
* 제안 시스템 프롬프트 (지시형 — 템플릿을 모르는 모델용).
*
* 지시문은 **시스템 프롬프트에만** 둔다. 지시문이 처리 대상 텍스트 자리에 들어가
* 지시문 자체를 다듬어 돌려주던 회귀(밋 9c2b4d4)와 같은 부류의 사고를 막는다.
* 지시문 자체를 다듬어 돌려주던 회귀(커밋 9c2b4d4)와 같은 부류의 사고를 막는다.
*/
const SUGGESTION_SYSTEM_PROMPT = `사용자가 지금 입력창에 글을 쓰는 중입니다. 사용자가 마지막으로 쓴 글 뒤에 이어질 다음 문장을 제안하세요.
const SUGGESTION_SYSTEM_PROMPT = `사용자가 지금 입력창에 글을 쓰는 중입니다. 사용자 메시지의 [이어 쓰기 지시]에 따라, 커서 바로 뒤에 이어질 다음 문장(또는 지금 쓰는 문장의 나머지)을 제안하세요.
규칙:
- 당신은 사용자와 대화하는 비서가 아닙니다. 사용자 본인이 다음에 직접 칠 문장만, 사용자 자신의 목소리로 쓰세요.
- 당신은 사용자와 대화하는 비서가 아닙니다. 사용자 본인이 다음에 직접 칠 글만, 사용자 자신의 목소리로 쓰세요.
- 사용자에게 질문하지 말고, 도와주겠다고 제안하지 말고, 사용자를 부르듯 말하지 마세요. ("궁금한 점이 있으신가요?", "도와드릴까요?" 같은 응답 금지)
- [지금 쓰는 문장]이 있으면 그 문장의 나머지만 쓰세요. 이미 쓴 부분을 되풀이하지 말고, 바로 이어 붙일 수 있게 쓰세요.
- 앞 문맥의 주제·대상·사실(이름, 날짜, 숫자, 용어)과 어긋나지 않게 쓰고, 앞에서 이미 한 말은 반복하지 마세요. [글에 나온 사실]의 이름·날짜·숫자는 그대로 쓰고 새로 지어내지 마세요.
- [이 창에서 조금 전에 쓴 글]은 같은 대화·문서에서 사용자가 앞서 쓴 글입니다. 흐름을 이어 가는 데 쓰세요.
- 입력이 검색어나 폼 입력처럼 보이면(문장이 아니라 키워드 나열 등), 같은 종류의 텍스트로 짧게 이어 쓰세요.
- 사용자가 언어와 같은 언어로 쓰세요.
- 사용자가 쓴 언어와 같은 언어로 쓰세요.
- 사용자의 말투와 문체를 유지하세요. 존댓말/반말, 격식/비격식을 바꾸지 마세요.
- 이미 나온 단어를 되풀이하지 말고 이어지는 내용만 쓰세요.
- [사용자가 평소 이어 쓴 문장]과 [관련해서 사용자가 쓴 문장]은 사용자의 실제 글입니다. 내용이 지금 문맥과 맞으면 그 표현과 흐름을 적극적으로 따르세요. 맞지 않으면 무시하세요.
- 후보를 한 줄에 하나씩, 번호나 따옴표, 설명 없이 출력하세요.
- 각 후보는 한 문장, 최대 {{maxChars}}자입니다.
- 확신이 없으면 짧게 쓰세요. 리말, 요약, 빈 줄을 출력하지 마세요.`
- 확신이 없으면 짧게 쓰세요. 머리말, 요약, 빈 줄을 출력하지 마세요.`
/**
* 제안 시스템 프롬프트 (이어 쓰기형 — 모델 차례에 사용자 글을 미리 넣는 prefill 경로).
*
* 모델은 "답변" 이 아니라 사용자 글의 다음 글자부터 쓴다. 지시형보다 문장 이음새·말투·단어 중간
* 이어 쓰기가 정확하다(실측 2026-10-03, gemma4:e4b).
*/
const SUGGESTION_CONTINUE_SYSTEM_PROMPT = `사용자가 지금 입력창에 직접 글을 쓰고 있습니다. 당신의 차례에는 사용자가 쓰던 글의 끝부분이 이미 적혀 있습니다. 그 바로 뒤를, 사용자 본인이 이어서 치는 것처럼 이어 쓰세요.
규칙:
- 사용자 본인의 목소리로 씁니다. 비서처럼 대답하거나, 사용자에게 질문하거나, 설명을 붙이지 마세요.
- 문장이 끝나지 않았으면 그 문장만 자연스럽게 끝맺고 멈추세요. 문장이 이미 끝났으면 다음 문장 하나만 쓰고 멈추세요.
- 단어 중간에서 끊겼으면 그 단어의 나머지부터 쓰세요. 이미 쓴 부분을 되풀이하지 마세요.
- 이름·날짜·시각·숫자·용어는 [글에 나온 사실]과 앞 문맥에 있는 그대로 쓰세요. 사람 이름은 앞 글에 나온 이름만 쓰세요.
- 앞 글에 없는 날짜·시각·숫자·이름이 필요하면 지어내지 말고, 그 사실 없이 쓸 수 있는 말로 쓰세요.
- 앞에서 이미 한 말은 다시 하지 마세요. 글의 흐름(인사 → 용건 → 세부 → 요청 → 맺음)에서 바로 다음에 올 내용을 쓰세요.
- 언어와 말투(존댓말/반말, 격식/비격식, ㅋㅋ 같은 습관)를 앞 글과 똑같이 유지하세요. 앞 글에 이모지가 없으면 이모지를 쓰지 마세요.
- [이 창에서 조금 전에 쓴 글]은 같은 대화·문서에서 사용자가 앞서 쓴 글입니다. 대화가 이어지는 흐름을 잡는 데 쓰세요.
- [사용자가 …] 로 시작하는 항목은 사용자의 실제 글입니다. 지금 문맥과 맞으면 그 표현을 그대로 따르고, 맞지 않으면 무시하세요.
- 검색창·폼처럼 문장이 아닌 입력이면 같은 종류로 짧게 이어 쓰세요.
- 최대 {{maxChars}}자. 이어지는 글만 쓰고 따옴표·머리말·설명을 붙이지 마세요.`
/** 이 창에서 조금 전에 쓴 글 — 채팅처럼 보내고 나면 입력칸이 비는 곳의 앞 대화. */
export interface RecentWriteHint {
text: string
/** 쓴 지 얼마나 지났나 (ms) */
ageMs: number
}
export interface SuggestionPromptInput {
/** 어렛 앞까지의 텍스트 */
/** 커서 앞까지의 텍스트 (세션 접두) */
prefix: string
/** 활성 앱/창 (맥락 트) */
/**
* 커서 앞 문서 전체 (원문 — 뒤 공백 포함). 있으면 앞 문맥·첫머리·사실을 여기서 읽는다.
* 세션 접두는 400자 창이라 글 앞쪽의 이름·날짜·인사를 모델이 못 본다.
*/
documentText?: string | null
/** 커서 뒤 텍스트 (문서 중간에서 쓸 때) — 겹치지 않게 참고만 한다 */
suffix?: string | null
/** 활성 앱/창 (맥락 힌트) */
appName?: string | null
windowTitle?: string | null
/** 사용자가 자주 쓰는 표현 (개인화 힌트) */
/** 같은 창에서 조금 전에 쓴(보낸) 글 — 오래된 것부터 */
recentWrites?: readonly RecentWriteHint[]
/** 사용자가 자주 쓰는 표현 (개인화 힌트 — 지금 문맥과 용어가 겹치는 것) */
phraseHints?: readonly string[]
/**
* 과거에 같은 꼬리 뒤에 실제로 이어 쓴 문장 (개인 기억).
@ -214,6 +262,8 @@ export interface SuggestionPromptInput {
* 자주 쓰는 표현보다 훨씬 강한 문맥 신호다 — 사용자 자신의 실제 이어쓰기다.
*/
continuationHints?: readonly string[]
/** 직전 문장 뒤에 사용자가 실제로 이어 쓴 문장 (개인 그래프 follows) */
followUpHints?: readonly string[]
/**
* 이미 이 세션에서 제안한 문장들 — 채우기 루프가 중복을 피하려고 넘긴다.
* 지시문이 아니라 데이터 섹션으로만 들어간다(기존 continuationHints 와 같은 방식).
@ -223,61 +273,210 @@ export interface SuggestionPromptInput {
candidates?: number
/** 후보당 최대 길이 */
maxChars?: number
/**
* true 면 이어 쓰기형(prefill) 요청을 만든다 — `assistantPrefix` 를 모델 차례 앞에 넣어
* 원형 템플릿으로 보내야 한다. 후보는 1개다.
*/
prefill?: boolean
}
export interface SuggestionPrompt {
systemPrompt: string
text: string
/** prefill 경로에서 모델 차례 앞에 넣을 사용자 글 (지시형이면 null) */
assistantPrefix: string | null
/** 접두 분석 결과 — 후처리(extractContinuation)가 같은 분해를 쓴다 */
writing: WritingContext
/** 사용자가 친 원문이 공백으로 끝났는가 (단어를 끝냈는가) */
wordFinished: boolean
/** 사용자가 이모지를 쓰는가 (앞 글·이 창의 앞 글 기준) */
allowEmoji: boolean
/** 사실 검사용 원문 — 문서 + 창 제목 + 이 창에서 조금 전에 쓴 글 + 개인 힌트 */
factSource: string
}
const LANGUAGE_LABEL: Record<WritingLanguage, string> = {
ko: '한국어',
en: '영어',
ja: '일본어',
zh: '중국어',
other: '사용자가 쓴 언어'
}
const REGISTER_LABEL: Record<WritingRegister, string> = {
formal: '격식체 존댓말 (-습니다/-ㅂ니다)',
polite: '해요체 존댓말 (-요)',
plain: '평서체 (-다, -었다 — 일기·메모·문서체. 반말 -어/-야 를 섞지 말 것)',
casual: '반말 (-어, -야, -지)'
}
/** 프롬프트에 원문으로 보여 줄 앞 문맥 길이. 모델 문맥(4096 토큰)과 지연 사이의 절충. */
const PROMPT_EARLIER_CHARS = 900
/** 원문 창 — 앞 문맥 + 직전 문장 + 지금 문장이 대략 이 안에 든다. 첫머리는 이 밖일 때만 보여 준다. */
const PROMPT_WINDOW_CHARS = 1200
const SEARCH_CONTEXT = /(google|naver|네이버|daum|다음 검색|bing|duckduckgo|youtube|검색|search)/iu
/**
* 검색창 입력인가 — 검색 페이지·검색 창 제목이고, 짧고, 문장 부호가 없다.
*
* 실측: "서울 강남 파스타" 뒤에 "맛집 추천 좀 해주세요." 같은 문장을 붙였다. 검색어는 키워드로 잇는다.
*/
function looksLikeSearchInput(input: SuggestionPromptInput, raw: string): boolean {
const where = `${input.appName ?? ''} ${input.windowTitle ?? ''}`
const text = raw.trim()
return SEARCH_CONTEXT.test(where) && text.length > 0 && text.length <= 60 && !/[.!?。\n]/u.test(text)
}
function formatAge(ageMs: number): string {
return ageMs < 60_000 ? '방금' : `${Math.round(ageMs / 60_000)}분 전`
}
/**
* 제안 요청용 (systemPrompt, text) 를 만든다.
* prefill 할 사용자 글 — 지금 문장(마저 쓰기) 또는 직전 문장(다음 문장), 원문의 끝 공백·줄바꿈 포함.
*
* 시스템 프롬프트에 지시문, 사용자 메시지에는 **지금까지 쓴 텍스트와 맥락**만 는다.
* 끝 공백은 "단어를 끝냈다" 는 신호다. 지우면 모델이 그 단어에 글자를 붙여 쓴다.
*/
export function buildSuggestionPrompt(input: SuggestionPromptInput): {
systemPrompt: string
text: string
} {
const candidates = Math.max(1, Math.min(input.candidates ?? 3, 5))
function buildAssistantPrefix(writing: WritingContext, raw: string): string {
const body = writing.currentSentence || writing.lastSentence
// 줄바꿈은 남긴다(새 줄·목록 다음 항목). 끝 공백은 뺀다 — 공백 하나로 끝난 토큰 상태가 모델을
// 흔든다(실측: "검토해 보시고 " → "긍정적인 피드백 부탁드립니다."). 대신 wordFinished 로 거른다.
return /\n[ \t]*$/u.test(raw) && writing.mode === 'next-sentence' ? `${body}\n` : body
}
/**
* 제안 요청용 (systemPrompt, text[, assistantPrefix]) 를 만든다.
*
* 시스템 프롬프트에 지시문, 사용자 메시지에는 **지금까지 쓴 텍스트와 맥락**만 넣는다.
* 접두는 "앞 문맥 · 직전 문장 · 지금 쓰는 문장" 으로 나눠 보여 주고, 문장을 마저 쓸지
* 다음 문장을 쓸지, 어떤 언어·말투인지를 명시한다 — 소형 모델은 이걸 스스로 잘 못 읽는다.
* 400자 창 밖의 글 첫머리와 이름·날짜·숫자는 따로 뽑아 보여 준다.
*/
export function buildSuggestionPrompt(input: SuggestionPromptInput): SuggestionPrompt {
const prefill = input.prefill === true
const candidates = prefill ? 1 : Math.max(1, Math.min(input.candidates ?? 3, 5))
const maxChars = Math.max(20, Math.min(input.maxChars ?? 160, 400))
const rawSource = input.documentText && input.documentText.trim().length > 0 ? input.documentText : input.prefix
const writing = analyzeWritingContext(rawSource.slice(-PROMPT_WINDOW_CHARS * 2), PROMPT_EARLIER_CHARS)
const documentContext = analyzeDocumentContext(rawSource, PROMPT_WINDOW_CHARS)
const sections: string[] = ['[지금까지 텍스트]', input.prefix]
if (input.phraseHints && input.phraseHints.length > 0) {
sections.push('', '[자주 쓰는 표현]')
for (const hint of input.phraseHints.slice(0, 5)) {
sections.push(`- ${hint}`)
}
}
const sections: string[] = []
if (input.appName || input.windowTitle) {
sections.push('', '[현재 앱]')
const app = [input.appName, input.windowTitle].filter(Boolean).join(' — ')
sections.push(app)
sections.push('[현재 앱]', app, '')
}
if (documentContext.opening) sections.push('[글의 첫머리]', documentContext.opening, '')
if (documentContext.facts.length > 0) sections.push('[글에 나온 사실]', documentContext.facts.join(', '), '')
const recent = (input.recentWrites ?? []).filter((item) => item.text.trim().length > 0).slice(-4)
if (recent.length > 0) {
sections.push('[이 창에서 조금 전에 쓴 글 — 오래된 것부터]')
for (const item of recent) {
const text = item.text.replace(/\s+/gu, ' ').trim()
sections.push(`- (${formatAge(item.ageMs)}) ${text.length > 240 ? `…${text.slice(-240)}` : text}`)
}
sections.push('')
}
if (writing.earlierText) sections.push('[앞 문맥]', writing.earlierText, '')
if (writing.lastSentence) sections.push('[직전 문장]', writing.lastSentence, '')
if (writing.currentSentence) sections.push('[지금 쓰는 문장 — 아직 끝나지 않음]', writing.currentSentence, '')
const suffix = input.suffix?.replace(/\s+/gu, ' ').trim()
if (suffix) sections.push('[커서 뒤에 이미 있는 텍스트 — 이것과 겹치지 않게]', suffix.slice(0, 160), '')
if (input.followUpHints && input.followUpHints.length > 0) {
sections.push('[사용자가 평소 직전 문장 같은 말 뒤에 이어 쓴 문장]')
for (const hint of input.followUpHints.slice(0, 3)) sections.push(`- ${hint}`)
sections.push('')
}
if (input.continuationHints && input.continuationHints.length > 0) {
sections.push('', '[과거에 사용자가 비슷한 문장 뒤에 실제로 이어 쓴 내용]')
for (const hint of input.continuationHints.slice(0, 3)) {
sections.push(`- ${hint}`)
}
sections.push('위 내용은 문체와 맥락 참고용입니다. 그대로 복사하지 말고 이어질 문장을 새로 쓰세요.')
sections.push('[사용자가 같은 표현 뒤에 실제로 이어 쓴 내용]')
for (const hint of input.continuationHints.slice(0, 3)) sections.push(`- ${hint}`)
sections.push('')
}
if (input.phraseHints && input.phraseHints.length > 0) {
sections.push('[관련해서 사용자가 쓴 문장]')
for (const hint of input.phraseHints.slice(0, 5)) sections.push(`- ${hint}`)
sections.push('')
}
if (input.avoidCandidates && input.avoidCandidates.length > 0) {
sections.push('', '[이미 제안한 문장 — 아래와 겹치지 않는 다른 문장을 쓰세요]')
for (const avoid of input.avoidCandidates.slice(0, 12)) {
sections.push(`- ${avoid}`)
}
sections.push('[이미 제안한 문장 — 아래와 겹치지 않는 다른 문장을 쓰세요]')
for (const avoid of input.avoidCandidates.slice(0, 12)) sections.push(`- ${avoid}`)
sections.push('')
}
sections.push('', `이어질 다음 문장 ${candidates}개를 한 줄씩 출력하세요.`)
const directives: string[] = []
directives.push(
writing.mode === 'complete-sentence'
? '[지금 쓰는 문장]의 나머지 부분만 쓰세요. 문장을 자연스럽게 끝맺으세요.'
: '[직전 문장] 다음에 이어질 새 문장 하나를 쓰세요.'
)
if (looksLikeSearchInput(input, rawSource)) {
directives.push('입력: 검색어입니다. 문장이 아니라 검색어 키워드 몇 개로만 짧게 이어 쓰세요.')
}
directives.push(`언어: ${LANGUAGE_LABEL[writing.language]}`)
if (writing.language === 'ko' && writing.register) directives.push(`말투: ${REGISTER_LABEL[writing.register]}`)
directives.push(prefill ? '당신의 차례에 적힌 사용자 글 바로 뒤부터 이어 쓰세요.' : `후보 ${candidates}개를 한 줄씩 출력하세요.`)
sections.push('[이어 쓰기 지시]', ...directives)
const systemPrompt = `${SUGGESTION_NO_THINK_PREFIX}\n${SUGGESTION_SYSTEM_PROMPT.replace(
'{{maxChars}}',
String(maxChars)
)}`
return { systemPrompt, text: sections.join('\n') }
const template = prefill ? SUGGESTION_CONTINUE_SYSTEM_PROMPT : SUGGESTION_SYSTEM_PROMPT
const body = template.replace('{{maxChars}}', String(maxChars))
return {
// 원형 템플릿(gemma4)은 생각 모드를 켜지 않으면 생각하지 않는다 — /no_think 는 지시형 경로에만.
systemPrompt: prefill ? body : `${SUGGESTION_NO_THINK_PREFIX}\n${body}`,
text: sections.join('\n'),
assistantPrefix: prefill ? buildAssistantPrefix(writing, rawSource) : null,
writing,
wordFinished: /[ \t]$/u.test(rawSource),
allowEmoji: containsEmoji(rawSource) || recent.some((item) => containsEmoji(item.text)),
factSource: [
rawSource,
input.windowTitle ?? '',
...recent.map((item) => item.text),
...(input.followUpHints ?? []),
...(input.continuationHints ?? []),
...(input.phraseHints ?? [])
].join('\n')
}
}
export { SUGGESTION_SYSTEM_PROMPT }
export { SUGGESTION_SYSTEM_PROMPT, SUGGESTION_CONTINUE_SYSTEM_PROMPT }
/**
* 입력 중 오타 검사 — 방금 친 문장에서 명백한 오타만 "틀린말 => 고친말" 줄로 받는다.
*
* 띄어쓰기·문체·단어 선택은 고치지 않는다. 호출자는 core `validateModelCorrections` 로
* 결과를 다시 거른다(모델 출력은 신뢰하지 않는다).
*/
const TYPO_CHECK_SYSTEM_PROMPT = `사용자가 입력창에 방금 친 문장에서 오타만 찾습니다.
규칙:
- 잘못 누른 글자, 빠지거나 겹친 글자, 자모가 뒤바뀐 글자, 틀린 맞춤법 철자처럼 명백한 오타만 고르세요.
- 띄어쓰기, 문장부호, 말투, 단어 선택, 어순은 고치지 마세요.
- 고유명사, 약어, 신조어, 외래어, 일부러 쓴 줄임말·구어체(ㅋㅋ, 넘, 젤 등)는 그대로 두세요.
- 확실하지 않으면 고치지 마세요.
- 오타마다 한 줄에 "틀린단어 => 고친단어" 형식으로 출력하세요. 단어는 문장에 나온 어절 그대로 쓰세요.
- 오타가 없으면 "없음" 한 단어만 출력하세요. 다른 설명은 쓰지 마세요.`
export function buildTypoCheckPrompt(input: { sentence: string; previous?: string | null }): {
systemPrompt: string
text: string
} {
const sections: string[] = []
const previous = input.previous?.replace(/\s+/gu, ' ').trim()
if (previous) sections.push('[앞 문맥]', previous.slice(-200), '')
sections.push('[검사할 문장]', input.sentence.replace(/\s+/gu, ' ').trim())
return {
systemPrompt: `${SUGGESTION_NO_THINK_PREFIX}\n${TYPO_CHECK_SYSTEM_PROMPT}`,
text: sections.join('\n')
}
}
/**
* 실시간 자막 문맥 다듬기 — 확정된 자막 한 줄을 앞 문맥에 맞게 고친다.