Improve Korean understanding at every speech level and long talks

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 07:36:03 +09:00
co-authored by Claude Opus 5.5
parent 284638a22d
commit 1411676269
13 changed files with 1006 additions and 71 deletions
+48 -11
View File
@@ -3236,11 +3236,25 @@ NOT_STOP = re.compile( # a stop word that orders no stop: negated, about someo
r"\bstop (?:for|at the|at a) (?:coffee|lunch|a (?:bit|while|break)|the \w+ (?:place|shop|store|cafe))|"
r"\b(?:when|if|once|whenever|after) [^,]{1,40},?\s*(?:you )?stop\b|"
r"그만(?:두|뒀|둘)|그만 ?(?:먹|마시|자|놀|울|웃|싸우|뛰)|"
r"(?<![가-힣])(?!루미|로봇|누미)(?:엄마|아빠|얘들아|[가-힣]{1,3}야|[가-힣]{1,3}아)\s+(?:좀\s+)?그만|"
r"(?<![가-힣])(?!루미|로봇|누미|아야|말이야|얘야)(?:엄마|아빠|얘들아|형|언니|누나|오빠|[가-힣]{1,3}야|[가-힣]{1,3}아)\s+(?:좀\s+|거기\s+)?(?:그만|멈춰|정지)|"
r"(?-i:\b(?!(?:Lumi|Loomi|Rumi|Robot|Hey|Hi|Okay|Ok|No|Please|Now|Wait|Hello|So|Oh|Yo)\b)[A-Z][a-z]+), stop \w+ing\b", re.I)
# also: another meaning, someone else told off ("엄마 그만 찍어", "Jake, stop touching the robot!"), a condition
_STOPW = r"(?:sto+p|halt|freeze|멈춰|멈춰요|정지|그만|스톱|스탑)"
STOP_UNSAID = re.compile( # a stop that is taken back, for later, said about the past, to someone else, or mocked
rf"{_STOPW}.*[,.…—–!]\s*(?:(?:oh|uh|um|hmm+|아|어|음|wait|no|actually)\W+)*(?:never ?mind|forget (?:it|that)|"
r"cancel(?: that| it)?|(?:아\s*)?(?:됐어|됐다|됐어요)(?: 마| 됐어)?|취소|아니다|(?:아\s*)?(?:그냥\s*)?하지 ?마(?:세요|요)?)\W*$|"
rf"[가-힣](?:면|나면|으면)\s+(?:\S+\s+){{0,3}}{_STOPW}|" # "사람 나오면 그때 멈춰", "음악 멈추면 멈춰요"
rf"\b{_STOPW}(?: \w+)? (?:when|once|after|until|as soon as|if) |\bwhen i give the signal\b|" # "stop when you get there"
rf"\b(?:don'?t|do not|doesn'?t|didn'?t|won'?t) (?:\w+ ){{0,2}}{_STOPW}\b|{_STOPW}\s*하지 ?마|" # "you don't have to stop"
rf"(?<!you )(?<!have )(?<!need )(?<!got )(?<!want )\bto {_STOPW}\b|\b(?:it|he|she) (?:doesn'?t|tried to|keeps?) |" # "waiting for it to freeze"
r"\b(?:heard|bet|like|guess) (?:that )?(?:you|it) (?:can|could)\b|\bi saw you\b|"
r"리가 있나|내가 사람이다|퍽이나|[가-힣]겠다\W*$|했던데|그랬잖아|했잖아|(?:멈췄|정지했|그만했)(?:던데|잖아|으면)|"
r"(?-i:\b(?!(?:Lumi|Loomi|Rumi|Robot|Hey|Hi|Okay|Ok|No|Please|Now|Wait|Hello|So|Oh|Yo|Stop)\b)[A-Z][a-z]+), (?:okay )?stop|"
r"\bstop it,? (?-i:(?!Lumi\b|Robot\b)[A-Z][a-z]+)\b", re.I)
STOP_PAD = re.compile(r"^(?:\W*(?:hey|hi|yo|oh|okay|ok|so|um+|uh+|listen|right|alright|all right|excuse me|mister robot|"
r"robot|lumi|loomi|루미 ?씨|루미 ?선생|루미야?|로봇아?|로봇 양반|어+|아+|야|저기요?)\b)+|"
r"(?:\W*\b(?:please|plz|pls|bro|now|right now|real quick|thanks|thank you|okay|ok|would you|will you|"
@@ -3263,6 +3277,8 @@ def stop_order(text, markers):
if NOT_STOP.search(text) and not re.fullmatch(r"\W*(?:(?:no|ok|okay|lumi|루미야?|hey)\W+)*(?:sto+pp?|stob|stopped|halt|freeze|멈춰|머+엄*춰|"
r"그만|정지|스톱|스탑|stop it|stop now)\W*", text, re.I):
return False
if STOP_UNSAID.search(text):
return False
bare = STOP_PAD.sub("", text.strip()).strip(" ,.!?~")
if bare and STOP_ONLY.fullmatch(bare):
return True # "hi Lumi, stop, okay?", "enough already", "Lumi, wait"
@@ -3279,9 +3295,18 @@ def own_command(text, last=""):
return bool(sing.asked(text, last) or sing.list_asked(text) or voice_words.read(text, last) or abilities.answer(text, "en", last))
HAND_STATE_Q = re.compile( # how the hand is now (A1): "is your hand open?", "hand open이야?", "손 펴져 있어?", "그리퍼 열려 있어요"
r"\b(?:is|are|r|was) (?:your|ur|the) (?:hand|gripper|claw|fingers?|arm)s? (?:still |now |already )?(?:open|opened|closed|shut|out|"
r"extended|empty|folded|in|up|down|stretched)\b|\b(?:hand|gripper|arm) (?:open|closed?|out)\s*(?:이야|이에요|인가요?|이니|상태|\?)|"
r"^\W*(?:(?:right|um|basically|next|so|okay)\W+)*did (?:you|u) drop (?:it|that|something|the \w+)\W*$|"
r"(?:손|그리퍼|집게|손가락|팔)(?:이|은|는|가)? ?(?:지금 |아직 |다 )?(?:open|close|펴져|펴진|열려|열린|닫혀|닫힌|접혀|접힌|뻗어져|오므려져|"
r"쥐어져)\s*(?:있|상태|이야|인가)", re.I)
def status_question(text):
""""What are you doing?", "where are you going?": answered from the task state ("들고 있는 거 줘" is a request)."""
return bool(STATUS_Q.search(text)) and not NOT_STATUS_NOW.search(text) and not EMPTY_HAND.search(text)
""""What are you doing?", "where are you going?", "is your hand open?": answered from the task state ("들고 있는 거
줘" is a request)."""
return bool(HAND_STATE_Q.search(text)) or bool(STATUS_Q.search(text)) and not NOT_STATUS_NOW.search(text) and not EMPTY_HAND.search(text)
def says_goodbye(text):
@@ -3322,16 +3347,18 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
by)); "end" (a goodbye); "sing"; "quick" (brain.intent's rule, one of QUICK_RULES, or the example bank's
reading: assistant/intent_bank.py); (None, None): the LLM reads
it. seen: seeing.answer or a stand-in; chain_ok: False on a mission or while a chain runs."""
from assistant import chain
from assistant import chain, intent_bank
if stop_order(text, markers):
return "stop", None
told = intent_bank.TAG.search(text) and (chain.PAST.search(text) or intent_bank.PAST_EN.search(text) or
intent_bank.past_ko(text)) # "you went to P5 earlier, right?": asked
text = brain_mod.strip_asides(text) # "hi Lumi, it's my birthday, put it down!": the command (A1)
if sing.picked(text, last): # after the list of songs: "the first one", "Fantastic Baby"
return "sing", None
arm_last = re.match(r"ACTION: (wave|arm (?:reach|fold))\b", last or "")
if arm_last and ARM_AGAIN.match(text or ""):
return "quick", tuple((arm_last.group(1).split() + [""])[:2]) # "again!", "한 번 더" right after a wave
hold = brain_mod.not_an_order(text) or not brain_mod.direct_order(text) or brain_mod.held_back(text) # only a direct
hold = told or brain_mod.not_an_order(text) or not brain_mod.direct_order(text) or brain_mod.held_back(text) # only a direct
# order to Lumi now acts (held_back: "don't ..., then ...", "yeah right, like you could ...", "..., forget it")
stuck = detour.recent() # right after a blocked drive: "try again", "go around it", "go back";
how = stuck and detour.read(text, markers, stuck["goal"]) # only a direct order (detour.read), else the LLM
@@ -3351,10 +3378,11 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
return "status", None
if (holding() if callable(holding) else holding) and brain_mod.held_put_back(text, markers):
return "quick", ("put", "back") # "it's my birthday, put that back where you found it!"
if hold: # a wave / arm rule may act on a question-form request ("악수 한번 할까요?",
song = sing.asked(text, last) # "Let it go 불러 줘": a song title, never the hand (A1)
if hold and not song: # a wave / arm rule may act on a question-form request ("악수 한번 할까요?",
arm_rule = brain_mod.intent(text, markers) # "would it be possible to wave at me?"); intent() itself refuses
if arm_rule and arm_rule[0] in ("wave", "arm"): # negations, later times, remarks, ability questions (A1)
return "quick", arm_rule
return arm_quick(arm_rule, holding)
if hold and not ((brain_mod.held_give(text, markers) or brain_mod.held_place(text, markers)) and
(holding() if callable(holding) else holding)): # "테이블에 놔 줄래? 영상 찍고 있어": the hand's
rule = brain_mod.intent(text, markers) # weather / search are no motion: "Weather outside?"
@@ -3364,7 +3392,7 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
cor = brain_mod.correction(text, b.history)
if cor:
return "correction", cor
if brain_mod.hand_request(text, False, b, markers) or brain_mod.hand_request(text, True, b, markers):
if not song and (brain_mod.hand_request(text, False, b, markers) or brain_mod.hand_request(text, True, b, markers)):
held = holding() if callable(holding) else holding
hand = brain_mod.hand_request(text, held, b, markers)
if hand:
@@ -3372,9 +3400,9 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
read = read_mission(text, markers)
if read:
return "mission", read
arm_rule = brain_mod.intent(text, markers)
arm_rule = not song and brain_mod.intent(text, markers)
if arm_rule and arm_rule[0] in ("wave", "arm"):
return "quick", arm_rule # "빠빠이 해 줘", "let's see you reach your arm out": the arm, not a goodbye
return arm_quick(arm_rule, holding) # "빠빠이 해 줘", "let's see you reach your arm out": the arm, not a goodbye
if talk_fate(text) == "end" and (b.history or not HI_ANNYEONG.search(text)): # "루미 안녕!" first: hello
return "end", None
if sing.asked(text, last):
@@ -3385,11 +3413,20 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
if not rule:
from assistant import intent_bank
rule = intent_bank.read(text, markers, holding) # the same request in other words, by meaning
if rule and rule[0] in ("wave", "arm") and brain_mod.ARM_TALK.search(text):
rule = None # "it'd be cool if you could take your hand back someday": talk (A1)
if rule:
return "quick", rule
return arm_quick(rule, holding)
return None, None
def arm_quick(rule, holding):
"""A rule's reading as route's ("quick", rule); an open hand while holding is refused (the thing would fall)."""
if tuple(rule[:2]) == ("arm", "open") and (holding() if callable(holding) else holding):
return "hand", (("refuse", brain_mod.REFUSE_OPEN), True)
return "quick", rule
QUICK_RULES = {"go_to", "come", "follow", "quiet", "weather", "search", "move", "turn", "arm", "pick", "put", "move_object",
"fetch", "look", "lift", "wave", "come_back", "waist"} # what quick_command does at once
ARM_AGAIN = re.compile(r"^\W*(?:(?:okay|ok|yes|yeah|lumi|please|robot|루미야?|응|네)\W+)*(?:again|one more time|once more|"