Something went wrong. Try again.
AI slop app to read Korean with a pop-up dictionary
Something went wrong. Try again.
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172import type { MorphToken } from '../types'
const partOfSpeechLabels: Record<string, string> = { NNG: 'Noun', NNP: 'Proper noun', NNB: 'Dependent noun', NR: 'Number', NP: 'Pronoun', VV: 'Verb', VA: 'Descriptive verb', VX: 'Helper verb', VCP: '“To be”', VCN: '“Not to be”', MAG: 'Adverb', MAJ: 'Connecting adverb', MM: 'Determiner', XR: 'Word root', SL: 'Foreign word',}
const particleLabels: Record<string, string> = { JKS: 'subject marker', JKC: 'complement marker', JKG: 'possessive marker', JKO: 'object marker', JKB: 'location / direction marker', JKV: 'address marker', JKQ: 'quotation marker', JX: 'topic / emphasis particle', JC: 'connecting particle',}
export function partOfSpeechLabel(pos: string): string { return partOfSpeechLabels[pos] ?? particleLabels[pos] ?? (/^E/.test(pos) ? 'Ending' : 'Word')}
export function morphemeLabel(token: MorphToken): string { if (partOfSpeechLabels[token.pos]) return `${partOfSpeechLabels[token.pos].toLowerCase()} stem` if (particleLabels[token.pos]) return particleLabels[token.pos] if (token.pos === 'XSV') { return token.text === '되' ? 'passive / becomes' : 'makes a verb' } if (token.pos === 'XSA') return 'makes a descriptive verb' if (token.pos === 'XSN') return 'noun suffix' if (token.pos === 'XPN') return 'noun prefix' if (token.pos === 'EP') { if (/^[았었였했]$/.test(token.text)) return 'past tense' if (token.text === '겠') return 'intention / supposition' if (token.text === '시') return 'honorific' return 'tense / honorific' } if (token.pos === 'EC') { if (/^[아어여]?서$/.test(token.text)) return 'because / then connector' if (token.text === '지만') return 'contrast connector' if (token.text === '고') return 'and / then connector' if (token.text === '면' || token.text === '으면') return 'if / when connector' if (token.text.endsWith('니까')) return 'reason connector' if (token.text === '게') return 'adverbial connector' return 'clause connector' } if (token.pos === 'EF') { if (token.text.includes('요')) return 'polite sentence ending' if (token.text === '다') return 'plain sentence ending' return 'sentence ending' } if (token.pos === 'ETM') return 'noun-modifying ending' if (token.pos === 'ETN') return 'noun-forming ending' return 'word element'}