Improve Korean understanding in casual, rude, formal and suggestion forms

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-11-02 02:52:49 +09:00
co-authored by Claude Opus 5.5
parent 19ba5fe58f
commit 5bfabd63b6
24 changed files with 973 additions and 32 deletions
+23 -7
View File
@@ -920,9 +920,10 @@ NOT_NAME = {"루미", "누미", "류미", "무미", "루비", "루니", "아니"
def to_someone_else(text):
""""Hey Jake, come see this", "Mom, look!", "민수야 이리 와 봐": said to another person nearby, not an order to Lumi."""
if ASIDE_EN.search(text) or re.match(r"^\W*(?:야|얘)[\s,!]+(?!.*(?:루미|로봇|lumi))", text, re.I) or \
if ASIDE_EN.search(text) or re.match(r"^\W*얘[\s,!]+(?!.*(?:루미|로봇|lumi))", text, re.I) or \
re.match(r"^\W*my (?:friend|dear|buddy|son|daughter|boy|girl|kid|baby|love|darling)\s*,", text, re.I):
return True # "야 그 사과 좀 집어 줘", "my friend, you follow me"
return True # "얘 그 사과 좀 집어 줘", "my friend, you follow me"
# (a bare 야 is the casual call to Lumi: "야, 이리 와")
for m in re.finditer(r"[,\s]([가-힣]{2})(아|야)(?=[\s,!~.]|$)", text): # "그거 내려놔, 지훈아 깨져"
c = m.group(1)[-1]
vowel_end = (ord(c) - 0xAC00) % 28 == 0
@@ -1053,11 +1054,23 @@ def not_an_order(text, asked=True):
return False # "I'm on your right": said so the head turns there
rest = instead_of(t) # "don't put your arm out, my baby will grab it"
now = NOW_CLAUSE.sub(" ", WAIT_UNTIL.sub(" ", t)) # "when you're ready", "while you do", "말씀하실 때": now
now = STEP_AFTER.sub(" 그리고 ", now) # "p3로 이동한 다음에 손 흔들어": Lumi's own step first
return bool(to_someone_else(t) or CANT_GO.search(t) or DRINK.search(t) or IDIOMS.search(t) or
CONDITION.search(now) or REMARK.search(now) or
TAKEN_BACK.search(t) or
rest != t and REMARK.search(rest) or asked and ASKED.search(t) or NEGATED.search(t) or ko_told(t) or
ABOUT_IT.search(t) or LATER_SAID.search(t) or ASIDE_NOW.search(t))
ABOUT_IT.search(t) or LATER_SAID.search(t) or ASIDE_NOW.search(t) or DOUBT.search(t))
DOUBT = re.compile(r"\b(?:can|could) (?:you|u) (?:even|really)\b|"
r"\b(?:he|she|they|my (?:son|daughter|kid|kids|friend|wife|husband|mom|dad|boss|brother|sister)) "
r"(?:wants?|wanted|would like|likes?|loves?|tried) to (?!have you\b)", re.I)
# "can you even turn left?": a doubt; "my son wants to fold your arm": what someone else wants to do, no order
STEP_AFTER = re.compile(r"(?:이동한|간|돈|돌아선|회전한|본|쳐다본|집은|잡은|든|흔든|내려놓은|놓은|온|돌아온|따라간|움직인|올린|내린|"
r"숙인|편|접은|내민|뻗은|연|닫은|가져온|챙긴) (?:다음에|후에)")
# Lumi's own step, then the next one ("오른쪽 본 다음에 손 흔들어"), not a condition like "회의 끝난 다음에"
NOW_CLAUSE = re.compile( # time words that mean now, with the order (T1, 2026-10-27): no later condition
@@ -1581,8 +1594,9 @@ def _intent(text, markers=()):
if driving.amount(t)[0] is None:
return None # "I'll come back later", "come back tomorrow": talk
continue # "come back 20 cm": a short drive
if action == "make_way" and driving.direction(driving.clean(t)) not in (None, "back"):
n, exact = driving.amount(t) # "왼쪽으로 20센티미터만 비켜 주게": that way, that far
if action == "make_way" and driving.direction(driving.clean(t)) not in (None, "back") or \
action == "make_way" and driving.direction(driving.clean(t)) == "back" and driving.amount(t)[0] is not None:
n, exact = driving.amount(t) # "왼쪽으로 20센티미터만 비켜 주게", "뒤로 50센티 비켜": that far
n = driving.DEFAULT_M if n is None else n
if n == "?" or not driving.MOVE_MIN_M <= n <= MOVE_MAX_M:
return None
@@ -1629,8 +1643,9 @@ def _intent(text, markers=()):
if action == "put":
return ("put", "back" if re.search(r"\bback\b|\breturn\b|\bwhere (?:it was|you)\b|\bits (?:spot|place)\b|제자리|다시|원래|원위치|있던|도로", t)
else "down")
if action == "pick" and re.search(r"\b(?:grab|get|fetch|pick up|take) me\b|\bgimme\b", t):
return ("fetch", text) # "go grab me a cup": brought to me, not only picked
if action == "pick" and re.search(r"\b(?:grab|get|fetch|pick up|take) me\b|\bgimme\b|"
r"\b(?:go |come )?(?:grab|get|fetch) (?:the |that |this |a |an )?\w+(?: \w+)? for me\b", t):
return ("fetch", text) # "go grab me a cup", "go get the cup for me": brought to me
if action in ("pick", "move_object") and far:
return ("fetch", text) # "get me an orange at gate one": a trip there, not a pick here
if action in ("pick", "move_object"):
@@ -2860,6 +2875,7 @@ UNSURE = re.compile(r"\b(not sure|don't know|do not know|don't have (any )?(info
QUESTION_START = re.compile(r"^\s*(where|what|how|why|when|which|who|do you|does|is|are|can i|could i)\b|어디 ?(있|에 있)|"
r"(어디|뭐|왜|언제|몇)[^ ]*\s*\?*\s*$", re.I) # a question about a place, not a command
ABILITY_Q = re.compile(r"(?<!줄 )(?<!주실 )(?<!줘 )(?<!받을 )수 ?있(?:어|나|니|을까|습니까)\S*\s*\?*\s*$|\bdo you know how\b|"
r"\b(?:can|could) (?:you|u) (?:even|really)\b|"
r"\bare you able\b|줄 ?(?:알아|아세요|알아요|아니|알지)\S*\s*\?+\s*$|"
r"보이(?:십니까|세요|시나요|나요|니|냐)\s*[?.!]*\s*$|보여요?\s*\?+\s*$", re.I) # asks whether Lumi can ("손 흔들 줄 알아?");
# "뒤가 보이십니까?", "등 좀 보이세요": about seeing / showing, no head turn