Commands: corrections inside a sentence, conditions are no order, Korean speech levels, missions on any map in any word order, never half done

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-21 23:50:17 +09:00
co-authored by Claude Opus 5.5
parent 334b5f5b2b
commit c31bee4d2f
18 changed files with 1298 additions and 53 deletions
+38 -22
View File
@@ -278,6 +278,9 @@ Short Korean commands are commands: "컵 가져다 줘" -> fetch cup, "컵 옮
(jump, dance, fly, climb stairs, open doors, lift heavy things) is none: say plainly that you can't. A person, a
chair, a table, a box or anything heavy you can't pick or carry: none, say so. With the action none never promise to do it ("I can!", "Okay, I'll hand it to you"): choose the
action, or say you can't, or ask what they mean.
- A condition or a later time is no order now ("when I say go, go to p1", "after the talk, come here", "if I
wave, follow me", "내가 가라고 하면 가", "나중에 와"): none, say you'll do it when they ask. In "go to p1, no, p2" /
"p1로 가, 아니 p2로" the last one counts. "Shake hands with me" is a handshake you can't do: none, offer a wave.
- unclear: you did not understand what the visitor said or wants: ask them to repeat.
- none: only talk.
For weather and search only write the action line; the answer is made after the lookup.
@@ -364,7 +367,8 @@ COLOURS = {"white": "white", "red": "red", "blue": "blue", "green": "green", "ye
_OBJ = "|".join(rf"(?<![가-힣]){w}(?![가-힣])|(?<![가-힣]){w}(?=[을를이가은는도만좀][^가-힣]|[을를이가은는도만좀]$)" if w in _KO_WORD
else re.escape(w) for w in sorted(OBJECTS, key=len, reverse=True))
_COL = "|".join(COLOURS)
STOP_TALK = re.compile(r"비상 ?정지|emergency stop|stop button|정지 ?버튼", re.I) # about the stop button, not "stop!"
STOP_TALK = re.compile(r"비상 ?정지|emergency stop|stop button|정지 ?버튼|\b(?:can'?t|cannot|couldn'?t|won'?t) stop\b|"
r"\bbus stop\b|\bstop (?:by|sign)\b|non-?stop", re.I) # about stopping, not "stop!" # about the stop button, not "stop!"
BEHIND_WORDS = (r"\blook(?:ing)? (?:over |to(?:wards?)? |at |in )?(?:the |your )?" # "look at the back side", "look
r"(?:behind|back ?side|back(?:wards?)?|rear|big side)\b" # at behind side", whisper's "big side"
r"(?! (?:at|on|up|in|of|to|and forth)\b)" # not "look back at me", "look at the back of"
@@ -464,14 +468,14 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
r"그만 ?(?:좀 ?)?(?:쳐다|바라)(?:봐|보세요)|"
r"(?:날|나를?|저를?|절)\s*(?:좀\s*)?(?:보지|쳐다보지) ?마|다른 ?(?:데|곳|쪽)(?:을|를)? ?(?:좀 )?봐"),
("stop", r"\b(stop|halt|freeze|don'?t move)\b|멈춰|정지|그만 ?가|거기 ?서(?=[\s!.~,]*$)|스톱|움직이지 ?마|^\s*(서[\s,!.]*){2,}$"),
("follow", r"\b(?:follow|come with|come along with|walk with|tag along with)\s+(?:me|us)\b(?!\s+(?:on|at)\b)|" # not "follow
("follow", r"\b(?:follow|following|come with|come along with|walk with|tag along with)\s+(?:me|us)\b(?!\s+(?:on|at)\b)|" # not "follow
r"\bcome along\b|(?<!말 )(?<!말을 )따라\s?(?:와|오세요|오십시오|올래)|(?<!로 )(?:같이|함께)\s?(?:가자|가요|갑시다|걸어)"), # me on instagram"
("fetch",rf"\b(fetch|bring|deliver|carry)\b.*\b({_OBJ}|it|that|this)s?\b|\b(take|get|grab)\b.*\b({_OBJ})s?\b.*\b(from|to)\b"
rf"|\b(go|drive) to\b.*\b(get|take|grab|pick up|fetch|bring)\b.*\b({_OBJ})s?\b"
rf"|\b(pick up|pick|take|grab|get)\b.*\b({_OBJ})s?\b.*\b(go|drive) to\b|({_OBJ}).*(집어서|들고).*가서"
r"|가져와|가져다|갖다|가지고 ?와|에서.*(옮겨|가져)" rf"|({_OBJ}).*(집고|들고|가지고).*(와|줘)"),
("come", r"\bcome (?:back )?(here|hear|to me|closer|over here|over)\b|\bcome\b.*\bme\b|이리 ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오|올래)|"
r"여기로 ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오)|가까이 ?(?:좀 ?)?(?:와|오세요)|"
("come", r"\bcome (?:back )?(here|hear|to me|closer|over here|over|this way)\b|\bcome\b.*\bme\b|이리 ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오|올래)|"
r"(?:여기로|이쪽으로) ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오)|가까이 ?(?:좀 ?)?(?:와|오세요)|"
r"나한테 ?(?:돌아 ?)?와"),
("go_home", r"\bgo (back )?(home|to (the |your )?(dock(?!2)|charger|charging))|\bgo charge|충전하러|집(?:에|으로) ?가|충전기로"),
("go_point", r"\b(?:go|drive|move|head|come|return|walk|roll|run|proceed|navigate|travel|hurry|make your way|get|take yourself)"
@@ -491,7 +495,8 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
r"\bwave (?:at|to|your|hello|hi|bye|goodbye|back|again|for)\b|\bgimme a wave\b|\b(?:why don'?t you|if you (?:could|can|would)|"
r"you (?:could|should|can|might)|could you|would you|can you|will you) (?:please |just )?wave\b(?!s)|\bgive (?:(?:them|him|her|us|me|everyone|the \w+) )?"
r"a (?:little |quick |big |friendly )?wave\b|\bwave\s?(?:해|좀)|\bshake (?:your |a |my )?hands?\b(?! with\b)|\bsay (?:hi|hello|bye) with your hand\b|손 ?(?:을 |좀 |도 )?흔들|손 ?인사"),
("turn", r"\bturn (a)?round\b|\bturn (left|right)\b|뒤로 ?돌|돌아 ?봐|왼쪽으로 ?돌|오른쪽으로 ?돌"),
("turn", r"\bturn (a)?round\b|(?:왼쪽|오른쪽)으로 ?(?:\d+(?:\.\d+)? ?도 ?)?도(?:세요|십시오)|\bturn (?:to (?:the |your )?)?(left|right)\b|뒤로 ?돌|돌아 ?봐|"
r"(?:왼쪽|오른쪽)으로 ?(?:\d+(?:\.\d+)? ?도 ?)?돌"),
("make_way", r"\b(can|could|would) you (please )?move( a bit| a little| please)?\s*[?.!]*$|\bmove (aside|out of the way|over)\b|"
r"\b(make way|get out of the way|give me some room)\b|비켜|자리 ?(좀 )?(비워|옮겨)|길 ?(좀 )?(비켜|터)"),
("go_point", r"\b(?:go|come|drive|head) back (p\d+)\b"), # "come back p9": a place, not 1 m back
@@ -529,6 +534,10 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
]
LATER = re.compile(r"^\s*(?:after|once|if|as soon as|before|unless|until)\b(?! (?:that|this|you (?:can|could|don'?t mind|would|"
r"please))\b)|\b(?:later|tomorrow|tonight|next time|in an hour)\b|[가-힣](?<![정화측반전표라장내외평단])면\s(?!안 ?돼)|\byou'?ll (?:find|see)\b|\bat the corner\b|"
r"\b(?:he|she|they|my \w+|his \w+|her \w+|our \w+|someone) (?:will|'ll|is going to|are going to)\b|"
r"(?:^|\s)(?:나중에|이따가?|내일)\s", re.I) # "after the talk ends, go to p1", "내가 가라고 하면": not now
STOP_ASK = re.compile(r"(?:(?:can|could|would|will) you (?:please |just )?stop(?: (?:now|please|moving|driving|here|there))?|"
r"멈출 수 있(?:어|어요|니|나요)|멈춰 줄래요?|멈춰 줄 수 있(?:어|어요))\W*$", re.I) # "can you stop?": stop
@@ -552,10 +561,8 @@ def intent(text, markers=()):
r"\b(can|could) you (pick( up)?|lift|hold|grab|take) (a|an|any)\b|" # "can you pick up a bottle?"
r"^\s*(what|when|which|at what|do you|does|is it|are you)\b|몇|언제|얼마|" # "at what level do you go back?"
rf"({_OBJ})(은|는)\s.*수 ?있|(루미가|로봇이)\s.*수 ?있|는 ?거 ?(돼|되나|가능)|" # "물컵은 가져다줄 수 있어요?"
r"어떻게|왜|혼자|스스로|\bby yourself\b|\bsomeone\b|줄 ?알아|할 ?줄|\bcome here often\b|"
r"^\s*(?:after|once|if|as soon as|before|unless|until)\b(?! (?:that|this|you (?:can|could|don'?t mind|would|please))\b)|"
r"\b(?:later|tomorrow|tonight|next time|in an hour)\b|(?:하|가|끝나|되|부르|말하)면\s(?!안 ?돼)|(?:^|\s)(?:나중에|이따가?|내일)\s",
CALLING.sub("", t)) # "Lumi, is it hard to ...?", "after the talk ends, go to p1", "내가 가라고 하면"
r"어떻게|왜|혼자|스스로|\bby yourself\b|\bsomeone\b|줄 ?알아|할 ?줄|\bcome here often\b",
CALLING.sub("", t)) or LATER.search(CALLING.sub("", t)) # "Lumi, is it hard to ...?"
visitor = re.search(r"^\W*(?:can|may|could|should|shall) (?:i|we)\b", CALLING.sub("", t)) # "can I come closer?"
for action, pat in INTENTS:
m = re.search(pat, t, re.I)
@@ -565,7 +572,7 @@ def intent(text, markers=()):
return None # "where's your emergency stop?", "how do I stop you?"
if action == "look_away":
return None if asks or "?" in t else ("look", "away") # "don't look at me", "쳐다보지 마"
if action != "quiet" and re.search(r"(?<!why )\b(don'?t|do not|never)\b|(하|펴|가|잡|놓|열)지 ?마", t) and action != "stop":
if action != "quiet" and re.search(r"(?<!why )\b(don'?t|do not|never)\b|[가-힣]지 ?마(?:세요|요|라)?(?![가-힣])", t) and action != "stop":
return None # "don't go to p1", "손 펴지 마": not an order
if asks and action in ("go_home", "go_point", "move", "make_way", "turn", "pick", "put", "move_object", "fetch", "come",
"arm", "grip_open", "grip_close", "wave", "look", "lift", "follow", "come_back"):
@@ -668,7 +675,7 @@ def _fix_kinds(t, markers):
"""The values in t a correction may replace: {kind: [match, ...]}: place, distance, angle, direction, object, colour."""
names = sorted((re.escape(m.lower()) for m in markers if len(m) > 1), key=len, reverse=True)
pats = {"place": rf"(?<![a-z0-9_])(?:p\d+|{'|'.join(names) or 'p0'})(?![a-z0-9_])",
"angle": r"\d+(?:\.\d+)?\s*(?:degrees?|도)", "distance": r"\d+(?:\.\d+)? m\b", "direction": _FIX_DIR,
"angle": r"\d+(?:\.\d+)?\s*(?:degrees?|도)", "distance": r"\d+(?:\.\d+)? m(?![a-z])", "direction": _FIX_DIR,
"time": r"\d+(?:\.\d+)?\s*(?:seconds?|secs?|minutes?|mins?|초|분)(?![a-z가-힣])",
"object": rf"(?<![a-z])(?:{_OBJ})s?(?![a-z])", "colour": rf"(?<![a-z])(?:{_COL})(?![a-z])"}
out = {}
@@ -694,8 +701,9 @@ def self_correct(text, markers=()):
"" when the command was taken back ("go to the stage, never mind", "스테이지로 가, 아니 됐어"); None when a
correction is there but can't be read for sure (Lumi asks again, nothing moves); the text itself otherwise."""
from assistant import steps
if re.search(r"\b(?:say|tell|announce)\b|말해|전해|[\"“”]", text, re.I):
return text # a message to say may hold any words
if re.search(r"\b(?:say|tell|announce)\b|말해|전해|[\"“”]", text, re.I) or \
re.search(r"\b(?:stop|halt|freeze|don'?t move)\b|멈춰|정지|그만|스톱|움직이지 ?마|거기 ?서", text, re.I):
return text # a message to say may hold any words; a stop always wins
t = wording.norm(text, markers)
end = re.search(r"[\s,.;!?]+(?:(?:oh|uh|um|아|음)\W+)?(?:never ?mind|forget (?:it|that|about it)|cancel (?:that|it)|"
r"(?:아니\s*)?(?:됐어요?|됐다|취소))\W*$", t)
@@ -704,10 +712,10 @@ def self_correct(text, markers=()):
for _ in range(3):
m = next((m for m in FIX.finditer(t) if m.start() > 0 and t[:m.start()].strip(" ,.;!?")), None)
if not m:
return t if _ else text
return _recase(t, text) if _ else text
left, right, said = t[:m.start()].strip(" ,.;!?"), t[m.end():].strip(" ,.;!?"), m.group(0)
if not _reads(left, markers) and not {"distance", "angle", "direction"} & set(_fix_kinds(left, markers)):
return t if _ else text # "I like apples, no, I love them": talk, not a command
return _recase(t, text) if _ else text # "I like apples, no, I love them": talk, not a command
if not right or FIX_CANCEL.match(right):
if right or _STRONG_NO.search(said):
return "" # taken back
@@ -743,12 +751,18 @@ def self_correct(text, markers=()):
fixed = fixed[:x.start()] + rk[kind][-1].group(0) + " " + fixed[x.start():]
said_again = all(w in fixed.split() for w in tail.split()) # "turn left, no, turn right": "turn"
new = next((c for c in ([] if said_again else [f"{fixed} {tail}"]) + [fixed] if _reads(c, markers)), None)
if new is None and _reads(first, markers):
new = instead()
if new is None and _reads(first, markers) and not set(rk) & set(_fix_kinds(clauses[-1], markers)):
new = instead() # another command ("go to the stage, no, come here")
if new is None:
return None
t = f"{new}, {rest[0]}" if rest else new
return t
return _recase(t, text)
def _recase(t, text):
"""Words written as the original had them ("james" -> "James"): names keep their capital in the read-back."""
said = {w.lower(): w for w in re.findall(r"[A-Za-z][a-z]*[A-Z]?[a-z]*", text) if not w.islower()}
return re.sub(r"[a-z]+", lambda m: said.get(m.group(0), m.group(0)), t)
# ---------- fetch tasks (docs/16 §4): strict parsing, nothing is guessed ----------
@@ -759,12 +773,12 @@ _PLACE_WORD = rf"(?:point|marker|포인트)\s*(\d+)|(?<![a-z])p\s?(\d+)(?!\d)|(\
_NOT_OBJ = r"(?:not|instead of) (?:the |a |an )?$" # "not the apple, the cup": the apple is not meant
FILLER_IN = re.compile(r"(?<![\w'])(?:u+h+m*|u+m+|e+r+m*|hmm+)(?![\w'])[,.]*\s*|(?<![가-힣])(?:음+|어+)(?![가-힣])[,.]*\s*")
FILLER_IN = re.compile(r"(?:,\s*)?(?<![\w'])(?:u+h+m*|u+m+|e+r+m*|hmm+)(?![\w'])[,.]*\s*|(?:,\s*)?(?<![가-힣])(?:음+|어+)(?![가-힣])[,.]*\s*")
def unfill(t):
"""'go to the um the stage' -> 'go to the stage': fillers inside the words and the word said twice around them."""
t = FILLER_IN.sub("", t)
t = re.sub(r" {2,}", " ", FILLER_IN.sub(" ", t)).strip()
return re.sub(r"\b(the|a|to) \1\b", r"\1", t)
@@ -1116,7 +1130,7 @@ PLACE_EN = re.compile(
r"(?:\s+(?:here|there|over there|somewhere|anywhere))?(?:\s+(?:on|onto|next to|beside|by|near|in front of)\s+.+)?"
rf"{_TAIL}|\b(?:put|set) (?:it |that |this )?down\b", re.I)
PLACE_KO = re.compile(r"(?<!내)(?<!그냥 )(?<!가만히 )(?<!내버려 )(?:놔|놓아|놓으|둬|두세요|올려 ?놔|올려 ?놓|내려 ?놔|내려 ?놓|내려 ?줘|내려 ?주세요|내려 ?둬)"
r"\s*(?:줘|주세요|요|줄래요?|주시겠어요|주실래요|주십시오|줄 수 있어요?|주실 수 있어요)?\s*[.!?~]*$")
r"(?:으십시오|으세요|으시겠어요)?\s*(?:줘|주세요|요|줄래요?|주시겠어요|주실래요|주십시오|줄 수 있어요?|주실 수 있어요)?\s*[.!?~]*$")
OPEN_HAND = re.compile(r"\bopen (?:your |the )?(?:hand|gripper|fingers)\b|\bopen it\b|\blet (?:it )?go\b|"
r"손을? ?(?:좀 )?(?:펴|벌려|열어)|손 ?open|hand open", re.I)
HAND_Q = re.compile(r"^\W*(?:what|how|why|when|where|which|who|do|does|did|is|are|was|were|have you|has)\b|"
@@ -1271,7 +1285,7 @@ IN_LANGUAGE = re.compile(r"^\s*(and |then |now |okay,? |and say it |say (it|that
r"^\s*(그거|그걸|그럼|다시|이번엔|이제)?\s*(한국어|영어|korean|english)\s?로(?!.*(대화|할 ?수|할 ?줄|돼요\?|되나))"
r"(요|는요|는|도)?\s*(다시\s*)?((말|말씀|얘기)?\s*해\s*(줘|주세요|줄래요?|줄 ?수 ?있어요?|봐요?)?)?"
r"\s*[!?.~]*\s*$", re.I)
WAVE_ASK = re.compile(r"\bwav(e|ing)\b|\bwith your hand\b|\bshake (?:your |my )?hands?\b|흔들|손 ?인사|인사.*손으로|손으로.*인사", re.I)
WAVE_ASK = re.compile(r"\bwav(e|ing)\b|\bwith your hand\b|\bshake (?:your |my )?hands?\b(?! with\b)|흔들|손 ?인사|인사.*손으로|손으로.*인사", re.I)
SING_ASK = re.compile(r"\bsing|\bsong|\bmusic\b|노래|한 ?곡|불러", re.I)
LOOK_MORE = re.compile(r"^\W*(?:and|now|then|and now)?\s*(up|down|left|right)\W*$|"
r"^\W*(?:이제|그럼|그리고)?\s*(위|아래|왼쪽|오른쪽)(?:도|로|으로|요|도요)?\W*$", re.I) # right after a look
@@ -1748,6 +1762,8 @@ class Brain:
if re.search(r"\b(bye|goodbye|(?<!can't )(?<!cant )(?<!cannot )(?<!not )(?<!to )see you|good night|i have to go|i'?m leaving)\b|안녕히|잘 ?가|잘 ?있어|"
r"다음에 봐|갈게요|가 ?볼게요|안녕\s*[.!]?$", text, re.I):
action = "end"
if action in MOTIONS and LATER.search(bare):
action, target = "none", "" # "when I say go, go to the stage": not now
rule = intent(text, markers) # clear wordings win over the small model's guess
if rule and not (rule[0] == "search" and action in ("go_to", "come", "look", "weather", "sing")):
action, target = rule
+3 -3
View File
@@ -33,7 +33,7 @@ VERB = re.compile(r"\b(?:move|go|come|drive|step|scoot|scooch|shift|inch|roll|ba
r"가|와|이동|움직|물러|빠져|후진|전진|비켜")
OTHER = re.compile(r"\b(?:look|head|turn|rotate|face|arm|hand|lift|raise|lower|it|this|that|them|those|these|here|there|"
r"home|me|us)\b|\bthe (?!left\b|right\b)|\bgo (?:right )?ahead\b|\bback to (?![\d.])|\bp\d+\b|고개|머리|팔|손|돌아|돌려|봐|쳐다|들어|올려|내려|"
r"여기|저기|이리|집|\S(?:을|를)(?=\s)") # the head, an object, a place: not a short drive
r"여기|저기|이리|집|\S(?:을|를)(?=\s)|도십시오|도세요|\d+(?:\.\d+)? ?도(?=\s|$)") # the head, an object, a place: not a short drive
SAYER = re.compile(r"\b(?:i|i'm|im|i'll|i've|we|we're|he|she|they|there|it's|it is|my|our|his|her|their|was|were|"
r"if|when)\b|(?:^|\s)(?:나|저|우리|저희)(?:는|도|가)\s") # "I live a few metres to the left"
_NATIVE = {"한": 1, "두": 2, "세": 3, "네": 4, "다섯": 5, "여섯": 6, "일곱": 7, "여덟": 8, "아홉": 9, "열": 10,
@@ -50,10 +50,10 @@ NUM_WORD = re.compile(r"\b(?:eleven|twelve|thirteen|fourteen|fifteen|sixteen|sev
FASTER = re.compile(r"\b(?:faster|quicker|speed (?:it )?up|pick up (?:the )?(?:pace|speed)|step on it|hurry(?: up)?|"
r"get a move on|more speed|full speed|go quick(?:ly)?|too slow(?:ly)?|so slow(?:ly)?|"
r"not fast enough|move it)\b|빨리|빠르게|속도\s*(?:를|좀)?\s*(?:좀\s*)?(?:높|올)\S*|느려|느리다|서둘러")
r"not fast enough|move it)\b|빨리|빠르게|(?:속도|speed)\s*(?:를|좀)?\s*(?:좀\s*)?(?:높|올)\S*|느려|느리다|서둘러")
SLOWER = re.compile(r"\b(?:slower|slow (?:it )?down|slow|ease (?:off|up)|not so fast|too fast|"
r"so fast|less speed|gently|more slowly|slowly)\b|"
r"천천히|느리게|속도\s*(?:를|좀)?\s*(?:좀\s*)?(?:줄|낮|늦)\S*|빨라|빠르다|살살")
r"천천히|느리게|(?:속도|speed)\s*(?:를|좀)?\s*(?:좀\s*)?(?:줄|낮|늦)\S*|빨라|빠르다|살살")
_FILLER = (r"please|pls|lumi|hey|hi|okay|ok|so|um+|uh+|well|now|then|just|can|could|would|will|you|you're|youre|"
r"are|is|going|moving|driving|go|drive|move|"
r"keep|going|get|it|the|a|an|bit|little|tiny|notch|touch|tad|lot|much|way|even|bit|slightly|somewhat|"
+12 -7
View File
@@ -113,7 +113,7 @@ CLOSE_BOX = 0.85 # a person is really closer than TOO_CLOSE on
HEAD_SIGN = 1.0 # +image angle -> +head yaw (checked: + = robot's left)
LOOK = {"left": (40, None), "right": (-40, None), "center": (0, 0), "up": (None, 20), "down": (None, -5)}
# ^ yaw/pitch in degrees for "look" commands: +yaw = left, +pitch = up (checked on the dashboard 2026-10-12)
WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|loomi|lumie|lumy|lummy|looney|lu-mi|rumi|roomie)\b"
WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|lumia|loomi|lumie|lumy|lummy|looney|lu-mi|rumi|roomie)\b"
r"|루미|누미", re.I)
WAKE_REPLY = {"en": "Yes? How can I help?", "ko": "네? 무엇을 도와드릴까요?"}
NAME_ONLY = re.compile(r"^\s*(hi |hey |hello )?(lumi|loomi|rumi|루미)[\s,.!?]*$", re.I)
@@ -1788,9 +1788,12 @@ class Lumi:
return True
self.warm_llm() # the LLM's prompt start cached while they speak
text, u = ears.listen(wait_s=4.0, on_start=lambda: log(" hearing speech"), abort=self.interrupted, full=True)
if text and self.own_echo(text) and (u is None or u.source == "clip" or len(text.split()) <= 2):
# Lumi heard itself: the clip mic, or the room's echo of the last word on the head array (muted while Lumi
# talks); a longer head-array sentence is the visitor ("okay go to P9" after a list with p9, 2026-10-21)
if text and self.own_echo(text) and (u is None or (u.during_speech if u.source == "clip"
else len(text.split()) <= 2)):
# Lumi heard itself: the clip mic while Lumi talked, or the room's echo of the last word on the head array
# (muted while Lumi talks); a longer head-array sentence is the visitor ("okay go to P9" after a list with
# p9, 2026-10-21). A clip-mic utterance begun after Lumi stopped is the visitor: "Lumi.", "Can you see
# me?" seconds after a greeting were dropped 20 times on 2026-10-21
log(f" ignored own voice: {text!r}")
text = None
if text and NOISE_WORDS.fullmatch(text.strip()): # a cough, a beep, "um": not worth "say it again"
@@ -2060,7 +2063,7 @@ class Lumi:
mouth.say("Sorry, I only understand English and Korean." if self.lang == "en" else "죄송해요, 영어와 한국어만 이해해요.")
self.keep_listening()
return
fixed = brain_mod.self_correct(text, self.markers) # "go to start, no, end", "컵 집어, 아니 병"
fixed = text if self.mission_running() else brain_mod.self_correct(text, self.markers) # "go to start, no, end"
if fixed != text:
log(f" corrected in the sentence: {fixed!r}")
if not fixed: # None: not read for sure, asked; "": taken back ("never mind")
@@ -2539,8 +2542,10 @@ class Lumi:
def stop_order(text, markers):
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button."""
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text))) # "can you stop?", "멈출 수 있어?": stop
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button;
"can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop."""
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text)) or
re.match(r"^\W*(?:stop|halt|freeze|멈춰|정지|스톱)\W*[,.!]", text, re.I))
return bool(FETCH_STOP.search(text) or asked) and (brain_mod.intent(text, markers) or ("",))[0] not in ("quiet", "look") \
and not brain_mod.STOP_TALK.search(text) and ("?" not in text or asked)
+10 -5
View File
@@ -55,14 +55,15 @@ def _norm(text, markers=()):
t = re.sub(r"(?<=[가-힣])고\s*나서(?=[\s,]|$)", "고", t) # "가고 나서" = "가고"
for honour, plain in _HON_KO: # "가셔서" = "가서", "받으시고" = "받고"
t = re.sub(rf"(?<![가-힣]){honour}(?=[\s,.!?]|$)", plain, t)
return re.sub(r"(?<![가-힣])(간|온|집은|잡은|든|받은|준|놓은|돈|기다린|들른|가신|오신|기다리신|받으신|집으신|잡으신|드신|주신|놓으신)"
return re.sub(r"(?<![가-힣])(간|온|집은|잡은|든|받은|준|놓은|돈|기다린|들른|가신|오신|기다리신|받으신|집으신|잡으신|드신|주신|놓으신|도신)"
r"\s*(?:다음에?|후에?|뒤에?)(?=[\s,]|$)",
lambda m: _AFTER_KO[m.group(1)], t).strip() # "p3에 간 다음에" = "p3에 가고"
_AFTER_KO = {"간": "가고", "온": "오고", "집은": "집고", "잡은": "잡고", "든": "들고", "받은": "받고", "준": "주고", "놓은": "놓고",
"돈": "돌고", "기다린": "기다리고", "들른": "들르고", "가신": "가고", "오신": "오고", "기다리신": "기다리고",
"받으신": "받고", "집으신": "집고", "잡으신": "잡고", "드신": "들고", "주신": "주고", "놓으신": "놓고"}
"받으신": "받고", "집으신": "집고", "잡으신": "잡고", "드신": "들고", "주신": "주고", "놓으신": "놓고",
"도신": "돌고"}
_HON_KO = [("가셔서", "가서"), ("가시고", "가고"), ("가셨다가", "갔다가"), ("오셔서", "와서"), ("오시고", "오고"),
("돌아오셔서", "돌아와서"), ("기다리셔서", "기다려서"), ("기다리시고", "기다리고"), ("기다리셨다가", "기다렸다가"),
("드시고", "들고"), ("드셔서", "들어서"), ("받으시고", "받고"),
@@ -91,7 +92,7 @@ def _place(word, markers):
def _places(t, markers):
"""'p3, p5 or p7' / 'p3' / 'here' -> list of names, or None when one of them is not a place on the map."""
t = re.sub(r"^either\s+", "", t.strip())
t = re.sub(r"^(?:either|(?:a )?random (?:one )?of|one of|any of)(?: the)?\s+", "", t.strip())
words = [w for w in re.split(r"\s*(?:,\s*(?:or|and)\b|,|\bor\b|\band\b|또는|(?<=[a-z\d])이나(?=\s)|(?<=[a-z\d])나(?=\s))\s*",
t) if w.strip()]
names = [_place(w, markers) for w in words]
@@ -115,7 +116,7 @@ def _go(c, markers):
if brain.COME_BACK.fullmatch(re.sub(r"(?<=[와가])(?:서|고)$", "", c)):
return {"do": "go", "to": "here"} # "come back", "go back where you were", "원래 자리로 돌아와"
m = re.fullmatch(r"(?:(?:go|drive|head|come|move|return|get|walk|roll|run|proceed|navigate|travel|hurry|make your way|"
r"take yourself)(?: back)?(?: over| on| ahead)?|(?:bring|take|carry) it(?: back)?)"
r"take yourself)(?: back)?(?: on)?(?: over| ahead)?|(?:bring|take|carry) it(?: back)?)"
r" to (?:the )?(?:(?:a )?random (?:one )?of |one of |any of )?(?:the )?(.+?)(?: point| marker)?", c)
if m:
to = _places(m.group(1), markers)
@@ -156,6 +157,7 @@ def _move(c):
rf"(?:(?:go|move|drive|step|walk|come|back up|head)\s+)?{_NUM} m\s+(?:to (?:the |your )?)?{_DIR}",
rf"(?:go|move|drive|step|walk|head)\s+{_NUM} m()",
rf"{_DIR_KO}\s*{_NUM} m\s*(?:가|가고|가서|이동|이동해|움직여|와|갔다가|갔다)(?:세요|줘)?",
rf"{_NUM} m\s*(?:만\s*)?{_DIR_KO}\s*(?:가|가고|가서|이동|이동해|움직여|와|갔다가)(?:세요|줘)?",
rf"(){_NUM} m\s*(?:더\s*)?(?:가|가고|가서|이동해|이동하고|이동해서|전진|전진해|전진하고)(?:세요|줘)?") # "1미터 가": forward
for p in pats:
m = re.fullmatch(p, c)
@@ -518,6 +520,9 @@ def _person(c, markers):
m = re.fullmatch(rf"(?:go|drive|head) (?:over )?to {_NAME} (?:at|in|by) (.+)", c)
if m and _is_name(m.group(1), markers) and (to := _places(m.group(2), markers)) and len(to) == 1:
return [{"do": "go", "to": to[0]}, {"do": "_for", "person": m.group(1)}] # the next give is for them
m = re.fullmatch(rf"let {_NAME} have (?:it|this|that|the (?:(?:{COL}) )?(?:{OBJ})s?)", c)
if m and _is_name(m.group(1), markers):
return [{"do": "give", "person": m.group(1), "where": False}] # "let Sarah have it"
m = re.fullmatch(rf"(?:bring|take|carry|fetch) (him|her|them|{_NAME}) (?:the |a |an |this |that )?(?:({COL}) )?({OBJ})s?", c)
if m and (m.group(1) in ("him", "her", "them") or _is_name(m.group(1), markers)):
obj, col = _thing(m.group(3), m.group(4)) # "bring her the cup": pick it, then to her (_NAME is group 2)
@@ -654,7 +659,7 @@ def _clause(c, markers, after=None):
def _clause_steps(c, markers, after=None):
c = re.sub(r"^(?:second(?:ly)?|third(?:ly)?|fourth|first(?:ly)?|step \d)[\s,]+", "", c.strip(" .!?")) # "second, go to ..."
c = re.sub(r"^(?:second(?:ly)?|third(?:ly)?|fourth|first(?:ly)?|last(?:ly)?|step \d)[\s,]+", "", c.strip(" .!?")) # "second, go to ..."
c = re.sub(rf"^(?:{_FILL}[\s,]+)+|(?:[\s,]+{_FILL})+$", "", c).strip(" .!?,")
if re.search(r"[가-힣]", c):
c = re.sub(r"\s+", " ", c)
+10 -1
View File
@@ -226,9 +226,18 @@ def map_names(t, names):
return re.sub(r"(\b(?:to|from|at|toward|towards) (?:the )?)([a-z][a-z0-9_]*(?: [a-z0-9]+)?)", slip, t)
ASR_SLIPS = [ # how whisper writes Korean commands (tests/asr_check.py, 2026-10-21) -> as said
(r"([a-z0-9])\.?\s+(으로|로)\s*(?=가|와|이동|돌아)", r"\1\2 "), # "P3. 로가줘", "final point. 로 가": one word
(r"(?<=로)\s*가죠(?![가-힣])", " 가 줘"), # "p3로 가 줘" written "p3로 가죠"
]
def norm(text, names=()):
"""Lower case, numbers first ("point five meters" is a distance), then marker names (names: the map's)."""
"""Lower case, whisper's slips (ASR_SLIPS), numbers first ("point five meters" is a distance), then marker names
(names: the map's)."""
t = " " + (text or "").lower().replace("’", "'") + " "
for slip, said in ASR_SLIPS:
t = re.sub(slip, said, t)
return re.sub(r"\s+", " ", map_names(markers(numbers(t)), names)).strip()