Blocked-way commands (try again / go around / back up / go back), any map names in every reader, seeing round 2, blind test sets r1 + r2 and their scorer
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+68
-24
@@ -61,9 +61,12 @@ Rules:
|
||||
- When asked what Cutshion is or about the company, give ONE short answer (what it makes in a few words, that it is
|
||||
in Seoul, the phone or email) and ask what they would like to know more about; details only when asked next.
|
||||
- Questions about Cutshion (its robots, prices, people, jobs, hours, delivery, warranty, the CEO) are never looked
|
||||
up on the internet: if the notes do not say it, say briefly and honestly that you don't know it, in varied
|
||||
words ("I'm not sure about that one.", "That I don't know, sorry.", "그건 저도 잘 몰라요.", "아쉽지만 그 정보는
|
||||
없어요."), not the same sentence every time.
|
||||
up on the internet: if the notes do not say it, say plainly that you don't have that fact ("I don't have exact
|
||||
information about that.", "그건 정확한 정보가 없어요.", "That I don't know, sorry.", "아쉽지만 그 정보는 없어요."),
|
||||
then at most one related fact you do know, with no number that could pass for the answer (the seed investment
|
||||
is not the company's value, the robots ordered are not the robots sold). Never a guessed number, not even when they ask again ("roughly?",
|
||||
"just guess", "대충이라도?", "찍어 봐"): you still don't have it. "How many people work there / at that company?"
|
||||
asks about the company's staff, never about the people you see now.
|
||||
- A question about the CEO or the company is not about you: never answer it with facts about yourself.
|
||||
- Never mention "the reference notes" or "the notes" to the visitor.
|
||||
- Facts about you: your name is Lumi. You understand speech with Whisper and answer with the language model Gemma 4,
|
||||
@@ -77,7 +80,15 @@ Rules:
|
||||
Spanish...): action unclear, do nothing they ask, say "Sorry, I only understand English and Korean." A question in
|
||||
English or Korean about a language ("can you speak Chinese?") is answered normally.
|
||||
- A short follow-up ("and normally?", "which ones?", "why?", "tell me more", "몇 개?", "어디어디요?") is about the topic
|
||||
of your previous answer: answer that. "Say it again" / "다시 한 번만요" means repeat your previous answer; "and in
|
||||
of your previous answer: answer that. "Why?", "how come?", "how do you know?", "when?", "where?", "how?",
|
||||
"what do you mean?", "왜요?", "어떻게 알아?", "언제?", "어디?", "무슨 뜻이야?" right after your answer ask about that
|
||||
answer, also when it said you can't or won't do something: give its reason or where you know it from (what you
|
||||
see with your cameras, what they told you, what Cutshion built and told you about yourself and the company; never
|
||||
"my notes"), and say plainly when you don't know the reason; for a "can't" answer the reason is in your words
|
||||
(Patrol switched off: you work standing in place; your arm switched off; the place is not on your map; busy with
|
||||
a task; holding something). "Really?", "are you sure?", "진짜?", "확실해요?" there ask you to confirm: "Yes, ..."
|
||||
with that same point in one sentence. Never change the topic, never ask them to say it again: it is never
|
||||
unclear. "Say it again" / "다시 한 번만요" means repeat your previous answer; "and in
|
||||
Korean?" / "영어로는요?" means your previous answer in that language. Never answer a follow-up with a list of what
|
||||
you can do.
|
||||
- Resolve a fragment from the turn before, as a person would: "and tomorrow?" / "그럼 내일은?" after the weather asks
|
||||
@@ -129,6 +140,9 @@ Rules:
|
||||
they name now: answer that.
|
||||
- Asked how to say something in Korean, write the Korean words in Hangul ("안녕히 가세요"), never in Latin letters.
|
||||
- Never invent numbers, prices or dates.
|
||||
- What you see is only what your earlier answers in this talk or "What you are doing now" say you see: a colour,
|
||||
a size, a count or a thing not said there you can't tell ("I can't tell its colour from here."); never guess it.
|
||||
A place or person not named in this talk ("where are they?" about staff) you don't know: say so.
|
||||
- Asked who makes your hardware or who built you: Cutshion Company developed you. "Who made that / it?" right
|
||||
after you named a part asks who makes that part (Gemma / 젬마: Google, Whisper / 위스퍼: OpenAI, the gripper:
|
||||
Zimmer); the arm
|
||||
@@ -250,6 +264,11 @@ You can also move. Decide if the visitor asks you to do something:
|
||||
- come: come to the visitor ("come here", "come to me", "come closer", "이리 와", "여기로 와").
|
||||
- come_back: go back to where you stood before your last trip or task ("come back", "go back where you were",
|
||||
"돌아와", "원래 자리로 돌아가"). "I'll come back later" / "come back tomorrow" / "she will come back" is talk (none).
|
||||
- detour <retry|around|backup|back>: ONLY when "What you are doing now" says your last drive was blocked. The
|
||||
visitor wants that drive tried again (retry: "the way is clear now", "you can go", "다시 가 봐"), by another way
|
||||
(around: "find a way", "there's room on the left", "다른 길로 가"), after backing up a little (backup), or wants you
|
||||
back where the trip started (back: "go back", "돌아와"). A question about it ("why did you stop?") is none; another
|
||||
place named is go_to.
|
||||
- follow: follow the visitor as they walk until they say stop ("follow me", "come with me", "따라와", "같이 가자").
|
||||
"Follow me on Instagram" or "I follow you" is talk (none).
|
||||
- look <left|right|center|up|down|me|away> [degrees|small]: turn your head ("look at me" -> me, "don't look at me"
|
||||
@@ -322,7 +341,7 @@ Okay, I'm going to point two.
|
||||
ACTION: come -
|
||||
Okay, I'm coming to you."""
|
||||
|
||||
ACTION_NAMES = {"go_to", "come", "come_back", "follow", "look", "lift", "wave", "stop", "end", "quiet", "sing", "weather", "search", "move", "turn",
|
||||
ACTION_NAMES = {"go_to", "come", "come_back", "detour", "follow", "look", "lift", "wave", "stop", "end", "quiet", "sing", "weather", "search", "move", "turn",
|
||||
"arm", "pick", "put", "move_object", "fetch", "give", "place", "receive", "unclear", "none"}
|
||||
LOOK_TARGETS = {"left", "right", "center", "up", "down", "me", "away"}
|
||||
SENTENCE_END = re.compile(r"(?<=[.!?。!?])\s+")
|
||||
@@ -509,15 +528,16 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
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)"
|
||||
r"(?: back)?(?: over| on| ahead)?(?: to| too| 2|to) (?:the )?(?:point |marker )?([a-z][a-z0-9_]*)\b|(\d+)\s*번\s*(?:으로|포인트)"
|
||||
r"|^\W*(?:(?:루미야?|lumi|hey lumi)\W*)?(?:[a-z][a-z0-9_]*\s*말고\s+)?(?:좀\s*)?(?:point\s+)?([a-z][a-z0-9_]*)\s*(?:앞|쪽|방향|지점|위치)?\s*"
|
||||
r"(?:으로|로|에|까지)?\s*(?:좀\s*)?(?:가|와|이동해|돌아가|돌아 ?와)" # "p3로 가 줘", "stage 가": all of it
|
||||
r"(?: back)?(?: over| on| ahead)?(?: to| too| 2|to) (?:the )?(?:point |marker )?([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*?)\b|(\d+)\s*번\s*(?:으로|포인트)"
|
||||
r"|^\W*(?:(?:루미야?|lumi|hey lumi)\W*)?(?:[a-z][a-z0-9_]*\s*말고\s+)?(?:좀\s*)?(?:point\s+)?([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*?)\s*(?:포인트\s*)?(?:앞|쪽|방향|지점|위치)?\s*"
|
||||
r"(?:으로|로|에|까지)?\s*(?:좀\s*)?(?:가|와|이동해|돌아가|돌아 ?와|go)" # "p3로 가 줘", "stage 가",
|
||||
# "booth_a로 go": all of it
|
||||
r"(?:\s*(?:줘요?|주세요|줄래요?|주실래요?|주시겠어요|주십시오|줄 수 있(?:어요?|니|나요)|봐요?|보세요|볼까요?|"
|
||||
r"주라|주시면 감사하겠습니다|줬으면 좋겠어요?|주면 좋겠어요?)|요|자|야 ?해요?|면 안 ?돼요?)?\s*[.!?]*$"
|
||||
r"|^\W*(?:(?:루미야?|lumi|hey lumi)\W*)?(?:point\s+)?([a-z][a-z0-9_]*)\s*(?:으로|로)\s*(?:좀\s*)?"
|
||||
r"|^\W*(?:(?:루미야?|lumi|hey lumi)\W*)?(?:point\s+)?([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*?)\s*(?:으로|로)\s*(?:좀\s*)?"
|
||||
r"(?:가십시오|가시겠어요|가시죠|가실래요)\s*[.!?]*$"
|
||||
r"|^\W*(?:(?:hey|hi|okay|ok|so|um+|uh+|alright|please|well|now|lumi|let'?s|lets)\W+)*(?:go|drive|head)\s+"
|
||||
r"([a-z][a-z0-9_]*)(?:\W+point)?\W*(?:(?:please|now|for me|thanks)\W*)*$"), # whisper drops the "to": "go
|
||||
r"([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*?)(?:\W+point)?\W*(?:(?:please|now|for me|thanks)\W*)*$"), # whisper drops the "to": "go
|
||||
# stage"; the owner: "let's go p5 (point)"
|
||||
("sing", r"\bsing\b|\ba song\b|노래"),
|
||||
("look", HEAD_WORDS), # head_target() reads the direction and amount
|
||||
@@ -533,7 +553,7 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
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
|
||||
("go_point", r"\b(?:go|come|drive|head) back ([a-z][a-z0-9_]*)\b"), # "come back p9 / booth_9": a place, not 1 m back
|
||||
("come_back", r"\bcome back\b|\breturn\b|\b(?:go|head|drive) back (?:to )?(?:where|your|the)\b|" # bare "go back" is
|
||||
r"돌아 ?(?:와|가|오|올|갈)"), # a short drive (as before); COME_BACK reads the whole sentence
|
||||
("move", r"\b(?!go (?:right )?ahead\b)(?:move|go|come|drive|step)\s+(?:a little\s+|a bit\s+)?(forward|ahead|back(?:wards?)?|left|right)\b"
|
||||
@@ -652,7 +672,8 @@ 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|no need to)\b|[가-힣]지 ?마(?:세요|요|라)?(?![가-힣])|"
|
||||
r"필요 ?(?:없|는 없)", 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", "spin", "pick", "put", "move_object", "fetch", "come",
|
||||
"arm", "grip_open", "grip_close", "wave", "look", "lift", "follow", "come_back"):
|
||||
@@ -670,7 +691,13 @@ def intent(text, markers=()):
|
||||
if action == "go_point":
|
||||
g = m.groups() + (None,) * 5
|
||||
word = g[0] or g[2] or g[3] or g[4] or f"p{g[1]}"
|
||||
name = next((mk for mk in markers if mk.lower() == word), None)
|
||||
if g[0] and re.match(r"\s+of\b", t[m.end(1):]):
|
||||
continue # "go to the end of the hall": a word, not the marker end
|
||||
if re.search(r"\b(?:the robot|lumi|it|you) (?:can|could|will|did|does|is able to)\b.*\?|\btold (?:the robot|lumi|you)\b"
|
||||
r"|\bearlier\b", t):
|
||||
return None # "the robot can drive to booth b by itself, right?", "she
|
||||
# told the robot 'go to dock 2' earlier": about it, no order
|
||||
name = wording.marker(word, markers)
|
||||
if name and (len(name) > 1 or named_place(text, name, markers)): # "a": not "go to a meeting room"
|
||||
return ("go_to", name)
|
||||
if re.fullmatch(r"p\d+", word):
|
||||
@@ -713,6 +740,8 @@ def intent(text, markers=()):
|
||||
if action == "make_way":
|
||||
return ("move", "back 1") # owner: a checked 1 m back-off (lumi.move_by)
|
||||
if action == "move":
|
||||
if driving.NEAR_THING.search(t):
|
||||
return None # "테이블 앞으로 가": to the table (a place), not forward
|
||||
g = [x for x in m.groups() if x]
|
||||
dirs = {"ahead": "forward", "backward": "back", "backwards": "back", "back up": "back", "backup": "back",
|
||||
"reverse": "back", "bake": "back", "big": "back", "후진": "back", "앞으로": "forward", "뒤로": "back",
|
||||
@@ -757,7 +786,7 @@ _FIX_DIR = r"\b(?:left|right|forward|ahead|back(?:wards?)?|up|down)\b|왼쪽|오
|
||||
|
||||
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)
|
||||
names = sorted((re.escape(wording.written(m)) 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(?![a-z])", "direction": _FIX_DIR,
|
||||
"time": r"\d+(?:\.\d+)?\s*(?:seconds?|secs?|minutes?|mins?|초|분)(?![a-z가-힣])",
|
||||
@@ -877,8 +906,9 @@ def _norm(text, markers=()):
|
||||
|
||||
def _place_re(markers):
|
||||
"""Place words; other marker names on the map ("final", "lobby") are matched as they are."""
|
||||
extra = [re.escape(m.lower()) for m in markers if not re.fullmatch(r"p\d+|home", m.lower()) and len(m) > 2]
|
||||
return _PLACE_WORD + (rf"|(?<![a-z])({'|'.join(extra)})(?![a-z])" if extra else "")
|
||||
extra = sorted((re.escape(wording.written(m)) for m in markers if not re.fullmatch(r"p\d+|home", m.lower())
|
||||
and (len(m) > 2 or re.search("[가-힣]", m))), key=len, reverse=True) # "입구", "exit_gate" before "exit"
|
||||
return _PLACE_WORD + (rf"|(?<![a-z0-9_가-힣])({'|'.join(extra)})(?![a-z0-9_])" if extra else "")
|
||||
|
||||
|
||||
def _resolve(m, markers):
|
||||
@@ -888,7 +918,7 @@ def _resolve(m, markers):
|
||||
if re.fullmatch(_HERE, word):
|
||||
return "here"
|
||||
name = f"p{n}" if n else ("home" if re.fullmatch(_HOME, word) else word)
|
||||
return next((mk for mk in markers if mk.lower() == name), None)
|
||||
return wording.marker(name, markers)
|
||||
|
||||
|
||||
def _as_place(name):
|
||||
@@ -942,7 +972,7 @@ def named_place(text, marker, markers):
|
||||
if len(marker) == 1:
|
||||
return bool(re.search(rf"\b(?:point|marker) {marker.lower()}(?![a-z])|\bto {marker.lower()}(?:[\s,.!?]*$|"
|
||||
rf"\s+(?:and|then)\b|,)", t))
|
||||
return bool(re.search(rf"(?<![a-z]){re.escape(marker.lower())}(?![a-z0-9])", t)) or \
|
||||
return bool(re.search(rf"(?<![a-z0-9_가-힣]){re.escape(wording.written(marker))}(?![a-z0-9])", t)) or \
|
||||
any(_resolve(m, markers) == marker for m in re.finditer(_place_re(markers), t))
|
||||
|
||||
|
||||
@@ -973,16 +1003,19 @@ def place_problem(text, markers):
|
||||
"""(en, ko) when the words send Lumi to a place this map does not have ("go to p12"), or to a word that is close
|
||||
to several marker names ("booth" with booth_1 and booth_2: which one?); None otherwise. Other unknown words
|
||||
("go to sleep", "go to the left") are not places for sure: the LLM answers them."""
|
||||
known = {m.lower() for m in markers}
|
||||
known = {wording.written(m) for m in markers}
|
||||
for m in _GO_WORD.finditer(_norm(text, markers)):
|
||||
word = m.group(1) or m.group(2)
|
||||
if word in known or word in ("here", "me", "home"):
|
||||
continue
|
||||
close = wording.close_names(word, markers) or [n for n in markers if n.lower().startswith(word + "_")]
|
||||
if len(close) > 1:
|
||||
close = wording.close_names(word, markers) or \
|
||||
[n for n in markers if len(word) > 2 and word not in wording.NOT_SLIPS and word in wording.written(n).split("_")]
|
||||
if len(close) > 1: # "booth" with booth_1 and booth_2
|
||||
names = [place_said(n) for n in close]
|
||||
return (f"Did you mean {', '.join(names[:-1])} or {names[-1]}?",
|
||||
f"{', '.join(names[:-1])} 아니면 {names[-1]} 중 어디 말씀이세요?")
|
||||
if close: # "stage" with only "Main Stage": asked, not guessed
|
||||
return f"Did you mean {place_said(close[0])}?", f"{place_said(close[0])} 말씀이세요?"
|
||||
if re.fullmatch(r"p\d+", word) and not close:
|
||||
return no_place_say(word, markers)
|
||||
return None
|
||||
@@ -1503,6 +1536,11 @@ SAME_ABOUT = re.compile(r"^\W*(?:and|so|what about|how about|and what about)\s+(
|
||||
KO_SAME_ABOUT = re.compile(r"^\W*(?:그럼\s*|그리고\s*)?(?:네\s*|너\s*|루미\s*)?(?!(?:너|루미|당신|저|나|그거|이거|그건|여기|거기)(?:은|는))([가-힣]{1,6}?)(?:은|는)요?\s*\?+\s*$")
|
||||
# the question before asked again about a part of Lumi ("팔은요?")
|
||||
FRAGMENT_CHARS = 160 # chars of the last answer's first sentence shown with a fragment
|
||||
ABOUT_ANSWER = re.compile(r"^\W*(?:(?:but|and|so|then|oh|wait|hmm|okay|그럼|근데|아니|아|어)\W+)*(?:why(?: not| is that| so)?|"
|
||||
r"how come|how (?:do|did|can) you (?:know|tell)(?: that| it)?|are you sure|really|for real|seriously|"
|
||||
r"what do you mean|says who|왜(?:요|죠)?|왜 안 ?(?:돼|되)\S*|진짜(?:요|야|로)?|정말(?:요|이야)?|"
|
||||
r"확실(?:해|한가|하)\S*|어떻게 알아\S*|그게 무슨 (?:뜻|말)\S*)\W*$", re.I)
|
||||
# asks about the answer just given: its reason, its source, or to confirm it
|
||||
LOOKUP_BEFORE_CHARS = 1500 # chars of the last lookup's results given again with a follow-up ("how old is she?")
|
||||
FOLLOW_UP_WORDS = 5 # "why did Samsung stock fall today?" is a new question, "tell me more about it" is not
|
||||
AND_ALSO = re.compile(r"^\s*(and|what about|how about|also|그럼|그리고)\b", re.I) # "and the yen?": a follow-up
|
||||
@@ -1724,6 +1762,9 @@ class Brain:
|
||||
if last and part: # "What about your cameras?" / "카메라는요?" after "can I wipe you?"
|
||||
return (f"(The visitor's question \"{self.history[-1][0]}\" asked again, now about {part.group(1)}: answer "
|
||||
f"that question for it, not other facts about it.)\n")
|
||||
if last and ABOUT_ANSWER.match(text): # "why?", "how do you know?", "진짜?" after a refusal too
|
||||
return (f"(This asks about your answer \"{last[:FRAGMENT_CHARS * 2]}\": its reason, how you know it, or "
|
||||
f"a confirmation of it.)\n")
|
||||
if not last or len(text.split()) > FRAGMENT_WORDS or not SHORT_Q.search(text) or is_backchannel(text) \
|
||||
or ABOUT_YOU.search(text) or OWN_TOPIC.search(text):
|
||||
return ""
|
||||
@@ -1954,13 +1995,15 @@ class Brain:
|
||||
action = "none" # "앞으로 10미터 가": it says the limit, it does not drive
|
||||
elif action in ("pick", "move_object"):
|
||||
target = " ".join(target.lower().split()[:3]) # "white cup", "tennis ball"
|
||||
elif action not in ("weather", "search", "fetch"): # a fetch is read by parse_fetch() later
|
||||
elif action not in ("weather", "search", "fetch", "go_to"): # a fetch is read by parse_fetch() later
|
||||
target = target.split()[0] if target.split() else ""
|
||||
if action not in ACTION_NAMES:
|
||||
action = "none"
|
||||
say = None
|
||||
if action == "go_to":
|
||||
said, target = target, next((mk for mk in markers if mk.lower() == target.lower()), None)
|
||||
said = target if any(wording._key(mk) == wording._key(target) for mk in markers) else \
|
||||
(target.split() or [""])[0] # "Coffee Corner"; "p3 (the meeting room)": its first word
|
||||
target = next((mk for mk in markers if wording._key(mk) == wording._key(said)), None)
|
||||
if not target and said.lower() not in ("", "none"):
|
||||
say = place_problem(f"go to {said}", markers) or no_place_say(said, markers, text) # "go_to kitchen"
|
||||
if target and not named_place(text, target, markers):
|
||||
@@ -1997,7 +2040,8 @@ class Brain:
|
||||
action = "none" # "follow me on instagram", "I like walking"
|
||||
if action == "wave" and not WAVE_ASK.search(text):
|
||||
action = "none" # "Hello Lumi!", "hello 해 봐": a greeting, not a wave
|
||||
if action not in ("go_to", "look", "lift", "weather", "search", "move", "turn", "arm", "fetch", "pick", "move_object"):
|
||||
if action not in ("go_to", "look", "lift", "weather", "search", "move", "turn", "arm", "fetch", "pick", "move_object",
|
||||
"detour"):
|
||||
target = ""
|
||||
if action in ("search", "weather") and SPOKEN_TARGET.match(target):
|
||||
target = "" # "search I'll look that up": the visitor's words are searched
|
||||
|
||||
@@ -0,0 +1,159 @@
|
||||
"""After a blocked drive: what the person asks Lumi to do about it, and where a way round could go.
|
||||
|
||||
"try again", "다시 해 봐" -> retry the same goal again
|
||||
"back up a little and try again", "뒤로 갔다가 다시 가" -> backup the checked straight move back, then the goal
|
||||
"go around it", "find a way", "다른 길로 가 봐" -> around a free point to the side first, then the goal
|
||||
"go back", "come back", "원래 자리로 돌아가" -> back back to where the trip started
|
||||
|
||||
The last blocked drive (its goal, the rest of the mission, where the trip started) is kept in STATE_FILE: the
|
||||
assistant writes it (a trip, a task or a mission whose drive got nowhere) and both the assistant and the API read it,
|
||||
since the dashboard's Command box goes through lumi.route as well. Only while it is fresh do these words mean a
|
||||
detour; otherwise they keep their usual meaning ("go back" = a short drive back, "try again" = the LLM decides).
|
||||
The base's API (manual v1.8.8) has no call to clear its costmap: a retry sends the same goal again and the base plans
|
||||
it from what its sensors see now."""
|
||||
import json
|
||||
import math
|
||||
import os
|
||||
import re
|
||||
import time
|
||||
from pathlib import Path
|
||||
|
||||
STATE_FILE = Path("/dev/shm/lumi_stuck.json")
|
||||
FRESH_S = 300.0 # s; a blocked drive older than this is no longer what "try again" / "go back" means
|
||||
BACKUP_M = 0.3 # m; "back up a little and try again": straight back this far first
|
||||
VIA_SIDE_M = (0.8, 1.2) # m; a way round: points this far to the left and the right of the line to the goal ...
|
||||
VIA_AHEAD_M = 0.5 # ... and this far along it from where Lumi stands
|
||||
VIA_CLEAR_M = 0.6 # m; such a point needs this much room to anything the lidar or the map shows (the base's
|
||||
# radius and the arm sticking out: an estimate, tune live)
|
||||
|
||||
SAY = {"retry": ("Okay, I'll try again.", "네, 다시 가 볼게요."),
|
||||
"backup": ("Okay, I'll back up a little and try again.", "네, 조금 뒤로 갔다가 다시 가 볼게요."),
|
||||
"around": ("Okay, I'll try another way.", "네, 다른 길로 가 볼게요."),
|
||||
"back": ("Okay, I'm going back.", "네, 원래 자리로 돌아갈게요.")}
|
||||
STILL = ("Sorry, I still can't get through. I can go back if you like.",
|
||||
"죄송해요, 아직도 지나갈 수가 없어요. 원하시면 원래 자리로 돌아갈게요.")
|
||||
NO_WAY_ROUND = ("Sorry, I can't see another way around it.", "죄송해요, 돌아갈 다른 길이 안 보여요.")
|
||||
NO_START = ("I don't know where I started. Where should I go?", "어디서 출발했는지 모르겠어요. 어디로 갈까요?")
|
||||
|
||||
# ---------- the words ----------
|
||||
_KEEP_TRYING = re.compile(r"\bdon'?t give up\b|\bdo not give up\b|포기하지 ?(?:마|말고)", re.I)
|
||||
_NOT = re.compile(r"\b(?:don'?t|do not|never(?! ?mind)|no need|stop trying|no more)\b|"
|
||||
r"하지 ?(?:마|말)|가지 ?(?:마|말)|그만|안 ?해도|필요 ?없", re.I)
|
||||
_ASKED = re.compile(r"\b(?:did|have|had) you\b|\bwhy\b|\bhow come\b|봤(?:어|니|나요|어요)?\s*\?|왜", re.I)
|
||||
_SPEECH = re.compile(r"\b(?:say|tell|repeat|sing|speak|explain|spell)\b|말해|말씀|얘기|이야기|들려|노래|불러", re.I)
|
||||
_BACK_UP = (r"\b(?:back (?:up|off|out)|reverse|(?:move|go|step|drive|come|get) back(?:wards?)?|backwards?)\b|"
|
||||
r"\bback(?= ?(?:좀|하))|뒤로|후진|물러|한 ?발")
|
||||
_AGAIN = (r"\bagain\b|\bretry\b|\bonce more\b|\bone more time\b|\b(?:try|go) (?:on|forward)\b|"
|
||||
r"\b(?:then|and) (?:go|try)\b(?! (?:another|a different|other|some other|a new))|다시|한 ?번 ?더|재시도|다가 ?가|하고 ?가|서 ?가")
|
||||
_BACKUP = re.compile(rf"(?:{_BACK_UP}).*(?:{_AGAIN})|(?:{_AGAIN}).*(?:\bback up|\breverse|후진|뒤로).*(?:\bfirst\b|먼저)",
|
||||
re.I)
|
||||
_AROUND = re.compile(
|
||||
r"\b(?:another|a different|different|other|some other|an other|alternative|alternate|new|a new|better) "
|
||||
r"(?:way|whey|wae|route|path|road)(?![a-z])|\b(?:go|drive|get|move|steer|head|navigate|walk|come) (?:a ?)?round\b|"
|
||||
r"\b(?:way|whey|wae) (?:a ?)?round\b|\bfind (?:a|the|your|some|another|an other) (?:way|whey|wae|path|route)\b|"
|
||||
r"\bdetour\b|\baround (?:해|하|가|돌)|\b(?:try|take|use|go by|go on) (?:the )?(?:left|right|other) side\b|"
|
||||
r"\bavoid (?:it|that|them|the)\b|\bwork your way\b|\bgo past (?:it|that|them)\b|\bsqueeze (?:past|through)\b|"
|
||||
r"\bre-?route|\brecalculate|\b(?:new|another|different|other|next) (?:aisle|passage|corridor|side)\b|"
|
||||
r"\blong way\b|\bchange (?:your|the) (?:route|path|way)|\b(?:pick|plan|take|choose) (?:a|another|a new|the) (?:route|path)|"
|
||||
r"\b(?:the )?route on the (?:left|right)|\b(?:look|search|hunt) for (?:a|another|some|the|any) (?:way|path|route)|"
|
||||
r"\bfigure out (?:a|some|another|the) way|\bwork out (?:a|some|how)|\bfind (?:some|your own) way|"
|
||||
r"\bsee if there'?s (?:another|a|any) (?:way|path|route)|\bway through\b|\bfind (?:a|another) ?길|"
|
||||
r"\b(?:room|space|a gap|gap) (?:on|to|by|over)|\bgap (?:by|over|there)|\b(?:left|right) of (?:it|the|that|them)\b|"
|
||||
r"\b(?:go|pass|squeeze|keep|fit|get) (?:\w+ )?(?:by|on|to|through on|through) the (?:left|right)|"
|
||||
r"\bkeep (?:to the )?(?:left|right)\b|\balong the wall|\b(?:left|right) side|"
|
||||
r"\b(?:get|slip|navigate|squeeze|weave|edge|go|move) (?:past|through|between)\b(?!\W*$)|\b(?:hallway|corridor|aisle|passage)\b|"
|
||||
r"사이로|빠져 ?나가|다른 ?데로|경로|통로|우회로|멀리 ?돌아|돌아가는 ?길|반대쪽|공간|틈|벽 ?쪽|(?:왼|오른)쪽 ?(?:으로|옆으로)? ?(?:지나|비켜|붙어)|"
|
||||
r"옆으로 ?지나|방법.{0,4}찾|길.{0,8}(?:찾|search)|(?:route|path|경로) ?바꿔|(?:way|path|route).{0,4}찾|"
|
||||
r"다른 ?(?:길|쪽|방향|경로|루트|way|route|path)|돌아서|둘러|우회|비켜서|피해서|피해 ?가|길(?:을)? ?찾|옆으로 ?(?:돌아|비켜|피해)", re.I)
|
||||
_BACK = re.compile(r"\b(?:go|come|head|drive|turn|get|move) back\b|\breturn\b|\bback to (?:the )?(?:start|beginning|where)|"
|
||||
r"\bwhere you (?:were|came from|started)\b|돌아 ?(?:와|가|오|올|갈|간)|되돌아|원래 ?(?:자리|곳|위치|데)|"
|
||||
r"\bback ?(?:해|하|가)|제자리|처음 ?(?:자리|위치|곳)|출발(?:한|했던)? ?(?:곳|자리|데|위치)", re.I)
|
||||
_AMOUNT = re.compile(r"\b(?:a (?:little|bit|tad)|slightly|a few|\d+|cm|centimet\w*|met(?:er|re)s?|steps?|inch\w*|feet|"
|
||||
r"foot)\b", re.I) # "go back a bit": the short drive back, as without a blocked drive
|
||||
_TO_PERSON = re.compile(r"\b(?:here|to me|me)\b|이리|여기|나한테|저한테|내게|내 ?쪽|이쪽", re.I)
|
||||
_RETURN_THING = re.compile(r"\breturn (?:the|a|an|it|this|that|my|your)\b", re.I)
|
||||
_RETRY = re.compile(
|
||||
r"\bagain\b|\bag(?:a|e|i|ai)n\b|\bretry\b|\bre-try\b|\btry a ?gain\b|\bgo (?:ahead|now)\b|\b(?:once more|one more time)\b|"
|
||||
r"\b(?:another|one more) (?:try|go|shot|attempt)\b|\bgive it (?:another|one more) (?:try|go|shot)\b|"
|
||||
r"\bkeep (?:going|trying)\b|\b(?:continue|carry on|go on|resume)\b|\btry (?:it )?(?:now|harder)\b|"
|
||||
r"\bdo it again|\blet'?s try|\btry ?ag(?:ai|ia)n|\bone more\b|"
|
||||
r"\b(?:you can|you may|feel free to) go\b|\boff you go\b|\bgo for it\b|\bproceed\b|\bmove along\b|"
|
||||
r"\bget going\b|\bmove on\b|\boff you (?:go|pop|trot)\b|\bsneak (?:by|past|through|along)\b|\bgood to go\b|^\W*(?:just |then |so )?go\W*$|"
|
||||
r"\b(?:clear|free|open|gone)\b.*\b(?:go|try|carry on|proceed)\b|\b(?:moved|cleared)\b.*\bgo\b|"
|
||||
r"\ball clear\b|\bcoast is clear|\b(?:way|path|road|it|that)(?:'s| is) (?:clear|free|open)|\byou'?re clear\b|"
|
||||
r"\bobstacle(?:'s| is) gone|\bnothing(?:'s| is) in (?:the|your) way|\b(?:fine|okay|ok|alright)\W+go\b|\bgo ?해도|\bcleared the way|"
|
||||
r"다시|한 ?번만? ?더|재시도|재도전|도전|트라이|계속 ?(?:가|해|진행)|또 ?(?:가|해)|가도 ?(?:돼|되|됩)|출발|가던 ?(?:길|데)|"
|
||||
r"진행|고고|ㄱㄱ|가 ?(?:봐|보세요|볼래|주세요|줘)|(?:^|[,.!]\s*)(?:(?:그럼|자|음|그냥|이제|루미야)\s*)*가(?:세요|요|라|자)?[\s.!~]*$|"
|
||||
r"(?:치웠|비웠|비켰|열렸|뚫렸|지나갔)|움직여|막힌 ?(?:거|게) ?없|장애물 ?(?:치웠|없)|지나갈 ?수 ?있어(?![?요]?\?)|괜찮아.{0,3}가|"
|
||||
r"\bclear\b.*가", re.I)
|
||||
_START = re.compile(r"\bwhere\b|\bstart|\bforget\b|원래|처음|출발|제자리|있던|잊어", re.I) # "come back where you started"
|
||||
_HOME = re.compile(r"\bhome\b|홈|\b(?:dock|charger|charging station)\b|집(?:으로|에)|충전|도크", re.I)
|
||||
|
||||
|
||||
def read(text, markers=(), goal=None):
|
||||
""""retry", "backup", "around" or "back" when the words ask that about a blocked drive, else None. A place other
|
||||
than the blocked goal named ("go back to p3", "go home") is a new trip; "come back here" comes to the person;
|
||||
a question about it ("why can't you go?"), a no ("don't try again") or talk ("say that again") is not a detour."""
|
||||
from assistant import brain
|
||||
t = _KEEP_TRYING.sub("keep trying", " ".join((text or "").lower().split()))
|
||||
t = re.split(r"말고", t)[-1] if "말고" in t else re.split(r"\b(?:instead of|rather than)\b", t)[0]
|
||||
if not t.strip(" .!?,~") or _NOT.search(t) or _ASKED.search(t) or _SPEECH.search(t):
|
||||
return None
|
||||
others = [m for m in markers if m != goal and (_HOME.search(t) if m == "home" else brain.named_place(t, m, markers))]
|
||||
if others:
|
||||
return None
|
||||
if _BACKUP.search(t):
|
||||
return "backup"
|
||||
if _AROUND.search(t):
|
||||
return "around"
|
||||
if _BACK.search(t) and goal in markers and not _START.search(t) and (_HOME.search(t) if goal == "home" else brain.named_place(t, goal, markers)):
|
||||
return "retry" # "go back to p3" with p3 the blocked goal: that drive again
|
||||
if _BACK.search(t):
|
||||
return None if _AMOUNT.search(t) or _TO_PERSON.search(t) or _RETURN_THING.search(t) else "back"
|
||||
if _RETRY.search(t):
|
||||
return "retry"
|
||||
return None
|
||||
|
||||
|
||||
# ---------- the last blocked drive ----------
|
||||
def remember(goal, rest, start, tries=0):
|
||||
"""Keep a blocked drive: `goal` (marker or [x, y, theta]), `rest` (the mission steps from that drive on), `start`
|
||||
(where the trip started, [x, y, theta] or None), `tries` (detours already tried for it)."""
|
||||
tmp = STATE_FILE.with_suffix(".tmp")
|
||||
tmp.write_text(json.dumps({"goal": goal, "rest": rest, "start": start, "tries": tries, "time": time.time()}))
|
||||
os.replace(tmp, STATE_FILE)
|
||||
|
||||
|
||||
def recent():
|
||||
"""The last blocked drive while it is fresh (FRESH_S), else None."""
|
||||
try:
|
||||
d = json.loads(STATE_FILE.read_text())
|
||||
except (FileNotFoundError, ValueError):
|
||||
return None
|
||||
return d if time.time() - d.get("time", 0) < FRESH_S else None
|
||||
|
||||
|
||||
def forget():
|
||||
"""A new trip, task or detour: the blocked drive is no longer what "try again" means."""
|
||||
try:
|
||||
STATE_FILE.unlink()
|
||||
except FileNotFoundError:
|
||||
pass
|
||||
|
||||
|
||||
# ---------- a way round ----------
|
||||
def via(pose, goal_xy, clearance):
|
||||
"""A map point (x, y, theta) beside the way to `goal_xy` (Lumi's heading when unknown): VIA_AHEAD_M along it and
|
||||
VIA_SIDE_M to the left or the right, the one with the most room (clearance(x, y) in m), facing the goal; None
|
||||
when none has VIA_CLEAR_M."""
|
||||
x, y, th = pose
|
||||
d = math.atan2(goal_xy[1] - y, goal_xy[0] - x) if goal_xy else th
|
||||
best = (VIA_CLEAR_M, None)
|
||||
for side in VIA_SIDE_M:
|
||||
for s in (side, -side):
|
||||
px = x + VIA_AHEAD_M * math.cos(d) - s * math.sin(d)
|
||||
py = y + VIA_AHEAD_M * math.sin(d) + s * math.cos(d)
|
||||
room = clearance(px, py)
|
||||
if room >= best[0]:
|
||||
best = (room, (px, py, math.atan2(goal_xy[1] - py, goal_xy[0] - px) if goal_xy else th))
|
||||
return best[1]
|
||||
@@ -31,9 +31,12 @@ DIRS = (("back", r"\bback(?:wards?)?\b|\bbackward\b|\breverse\b|^(?:let'?s )?(?:
|
||||
("right", r"(?<!all )\b(?:to the |to your )?right\b(?! now| away| here| there| back)|오른쪽|우측"))
|
||||
VERB = re.compile(r"\b(?:move|go|come|drive|step|scoot|scooch|shift|inch|roll|back (?:up|off)|reverse|get)\b|"
|
||||
r"가|와|이동|움직|물러|빠져|후진|전진|비켜")
|
||||
NEAR_THING = re.compile(r"(?:테이블|책상|탁자|의자|소파|문|벽|창문)\s*(?:앞|옆|뒤)") # "테이블 앞으로": to the table, not forward
|
||||
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)|도십시오|도세요|\d+(?:\.\d+)? ?도(?=\s|$)") # the head, an object, a place: not a short drive
|
||||
r"home|me|us)\b|\bthe (?!left\b|right\b)|\bgo (?:right )?ahead\b|\bback to (?![\d.])|\b[a-z]+\d+\b|\b[a-z]+(?:_[a-z0-9]+)+\b|고개|머리|팔|손|돌아|돌려|봐|쳐다|들어|올려|내려|"
|
||||
r"여기|저기|이리|집|\S(?:을|를)(?=\s)|도십시오|도세요|\d+(?:\.\d+)? ?도(?=\s|$)|" + NEAR_THING.pattern)
|
||||
# the head, an object, a place
|
||||
# (p3, dock2, booth_9: a marker as written): 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,
|
||||
|
||||
@@ -0,0 +1,689 @@
|
||||
"""Example bank: the fast lane between the keyword rules and the LLM (lumi.route).
|
||||
|
||||
Thousands of wordings per thing Lumi can do (English, Korean in 반말 / 해요체 / 하십시오체, mixed, Konglish, whisper
|
||||
slips) are matched by meaning with the embedding server (assistant/knowledge.embed, bge-m3). Close enough to one
|
||||
kind and far enough from every other kind (and from the "no" wordings: talk, questions, negations, conditions)
|
||||
-> the command runs at once; else the LLM reads it. The bank only routes: what a place, object, direction or amount
|
||||
is comes from the words themselves (the map's marker names, brain.OBJECTS, head_target ...), never from the bank.
|
||||
|
||||
Guards come first: negation, a condition or a later time, an ability question, words to someone else, closing words
|
||||
with two meanings, a question word. A wrong motion is the worst error, so motions need a high match and a margin.
|
||||
|
||||
.venv/bin/python assistant/intent_bank.py build # embed the bank -> data/intent_bank.npz
|
||||
.venv/bin/python assistant/intent_bank.py "say hi with your arm" # what the bank reads, with the closest wordings
|
||||
"""
|
||||
import hashlib
|
||||
import pathlib
|
||||
import random
|
||||
import re
|
||||
import sys
|
||||
|
||||
import numpy as np
|
||||
|
||||
ROOT = pathlib.Path(__file__).resolve().parents[1]
|
||||
CACHE = ROOT / "data" / "intent_bank.npz"
|
||||
SIM_MIN = 0.86 # the closest wording must be at least this similar (bge-m3 cosine) ...
|
||||
MARGIN = 0.04 # ... and this much closer than the closest wording of any other kind (the "no" kind too)
|
||||
AGREE_K = 2 # ... and the K closest wordings all of that kind
|
||||
MIN_CHARS = 4 # shorter words ("go", "가") are the rules' or the LLM's
|
||||
MAX_WORDS = 16 # a longer sentence is a story or several requests: the LLM reads it
|
||||
FILLS = 3 # place / object fills made of each template (the same every run)
|
||||
R = random.Random(11)
|
||||
|
||||
# ---------- guards: words the bank never reads ----------
|
||||
NEGATION = re.compile(r"\b(?:don'?t|do not|never|no need|not now|no more|stop \w+ing|quit \w+ing|without)\b|"
|
||||
r"[가-힣]지 ?마(?:세요|요|라|십시오)?(?![가-힣])|하지 ?말|말고|필요 ?없|안 ?(?:해|돼|가|와)(?:도)?\b|그만", re.I)
|
||||
LATER = re.compile(r"\b(?:when|whenever|if|unless|after|before|once|until|till|as soon as|later|tomorrow|tonight|"
|
||||
r"next time|in (?:a|an|\d+) (?:minute|hour|second)s?|in a while)\b|"
|
||||
r"[가-힣](?<![정화측반전표라장내외평단그러])면(?:\s|$)|(?:하|으|오|가|되|끝나|있으|오시)면|나중에|이따|내일|"
|
||||
r"다음에|있다가|(?:^|\s)(?:후|뒤|전)에(?![서가-힣])|때(?:에)?\s", re.I)
|
||||
ABILITY = re.compile(r"\b(?:are you able|able to|know how to|how (?:do|can|could|would) you|is it possible|can you even|"
|
||||
r"capable of|do you (?:know|have)|can robots?|could robots?)\b|"
|
||||
r"\bcan you (?:\w+ )?(?:things|anything|objects|stuff|people|by yourself)\b|\b(?:can|could) you \w+(?: up)? (?:a|an|any)\b.*\?|"
|
||||
r"\bshow me (?:you can|how)\b|보여 ?(?:줄|주실|주세요|줘)|할 ?줄|줄 ?알|(?<!줄 )(?<!주실 )(?<!주 )(?<!줄)(?<!주실)수 ?있(?:어|어요|니|나요|습니까|을까)\s*\??$|가능해|가능한가|가능하", re.I)
|
||||
QUESTION = re.compile(r"^\W*(?:(?:hey|so|um+|uh+|lumi|okay|ok)\W+)*(?:what|where|why|how|when|who|whose|which|is|are|was|"
|
||||
r"were|do(?=\s+(?:you|i|we|they|robots?)\b)|does|did|have|has|had|should|shall i|may i|can i|could i)\b(?! about\b)|"
|
||||
r"어디|뭐|무엇|왜|언제|누구|어떻게|몇|어느|무슨|어떤|얼마|봤(?:어|니|나|냐|어요|습니까)|본 ?적|"
|
||||
r"\bhave you (?:been|gone|ever)\b", re.I)
|
||||
OTHER_SENSE = re.compile(r"instagram|insta\b|\bsns\b|\baccount\b|\bsubscribe\b|인스타|계정|채널|구독|팔로우 ?해 ?주세요|"
|
||||
r"따라 ?(?:해|하|말|불러)|\brepeat after\b|\bcopy me\b|\bdo what i do\b|\b(?:lend|give) me a hand\b|"
|
||||
r"\bneed a hand\b|\bhand it to\b|\bfollow (?:what|how|the|this|that|your)\b|법 ?알려|방법|\bhow to\b", re.I) # follow an account, copy me, help me: no motion
|
||||
REPEAT = re.compile(r"^\W*(?:(?:\w+\W+){0,2})?(?:again|one more time|once more|do it again|same again|more)\W*$|"
|
||||
r"^\W*(?:[가-힣]+\s+)?(?:한 ?번(?:만)? 더|다시|또)\s*(?:해|해 ?줘|해 ?봐|해 ?주세요|하자)?\W*$", re.I)
|
||||
# "again", "한 번만 더 해 줘": what again is the history's (driving.read, the LLM)
|
||||
SEVERAL = re.compile(r"\b(?:and|then|after that|also|plus|while|no|not|wait|stay|sleep|sorry|i mean|actually|rather)\b|;|"
|
||||
r"(?!갖고|지고|고고)(?<!에)[가-힣](?:서|고)(?:\s|$)|하고|면서|다가|갔다|다녀|아니|기다|대기|(?:가|와) ?있어|계세요|"
|
||||
r"계십시오", re.I)
|
||||
# several requests or a stay ("go to p3 and wait", "가서 기다려", "p3에 가 있어"): steps.read's
|
||||
HAND_WORDS = re.compile(r"\byou(?:'re| are) holding\b|\b(?:in|from) my hand\b|\bhere'?s\b|\bhanding\b|\bi'?ll give\b|"
|
||||
r"\bhold this\b|\bfrom me\b|\bmy hand\b|내 손|제 손|손에 (?:줘|놔|주세요)|\bi'?m holding\b|\bi am holding\b|들고 있는|손에 있는|받아|드릴게|줄게|가져가세요", re.I) # the hand reader's (brain.hand_request)
|
||||
NAME_CALL = re.compile(r"^\W*(?:(?:ah|oh|hey|hi|okay|ok|so|um|uh|look|and)\W+)?([A-Z][a-z]+)\s*,") # "Jake, follow me": said to Jake
|
||||
NOT_A_NAME = {"lumi", "loomi", "rumi", "okay", "ok", "please", "hey", "hi", "hello", "so", "well", "now", "alright",
|
||||
"yes", "yeah", "no", "sorry", "um", "uh", "oh", "wait", "look", "then", "first", "also", "and", "but",
|
||||
"robot", "right", "fine", "good", "great", "sure", "next", "again", "quick", "listen", "excuse", "hmm"}
|
||||
SELF_TALK = re.compile(r"^\W*i'?m \w+ing\b|\b(?:myself|yesterday|last (?:time|week|night))\b|어제|지난번|었지|었어|"
|
||||
r"^\W*(?:i'?ll|i will|i'?m going|i am going|i went|i was|we'?ll|we went|we were|i have to|i need to go|"
|
||||
r"i want to go|my \w+ (?:will|is|went)|he |she |they )|"
|
||||
r"(?:^|\s)(?:나는|저는|내가|제가|우리는|저희는)\s|갈게|할게|할께|갈께|했어|했어요|갔어|왔어", re.I)
|
||||
|
||||
# ---------- the bank ----------
|
||||
# kinds: what lumi.route does with them (QUICK_RULES); "no" is every wording the bank must leave to the rest
|
||||
PLACE_EN = ["the stage", "booth A", "p3", "the lobby", "table front", "the coffee corner", "the exit", "point five",
|
||||
"booth two", "the entrance", "the start", "the reception desk"]
|
||||
PLACE_KO = ["스테이지", "부스 A", "p3", "로비", "커피 코너", "출구", "입구", "피쓰리", "2번", "안내 데스크", "회의실", "시작점"]
|
||||
OBJ_EN = ["cup", "red cup", "bottle", "apple", "banana", "white mug", "water bottle", "orange", "blue cup", "glass",
|
||||
"tumbler", "phone"]
|
||||
OBJ_KO = ["컵", "빨간 컵", "병", "사과", "바나나", "물병", "오렌지", "흰 컵", "텀블러", "머그컵", "파란 컵", "핸드폰"]
|
||||
|
||||
GO = [
|
||||
'scoot over to <place>', 'lead the way to <place>', 'your destination is <place>, go now', '<place>로 안내해 주세요', '<place>로 move 해', '<place>로 move', 'return to <place>', 'go back to <place>', 'off you go to <place>', '<place>로 가 주실 수 있어요?', '<place>로 이동 좀 해 줄 수 있어?', '<place>로 고고', 'can you take me to <place>',
|
||||
'i need you over at <place>', 'i need you at <place>', 'get yourself to <place>', 'can you make it to <place>', 'be at <place> please', 'go wait at the spot called <place>', 'drive yourself to <place>', 'head on over to <place>', 'please proceed to <place>', 'go to <place> right away', 'quickly go to <place>', 'go to the <place> area', '<place>로 이동하십시오', '<place>로 가 주세용', '<place>로 가 주라', '<place>로 가 볼까?', '<place>로 가 줄래요', '<place>까지 좀 가 줄래?', '<place>로 좀 이동해 줄래요?', '<place> 쪽으로 이동해 주세요', '<place>로 가시죠', '<place>로 가 보자', '<place>로 가 주실 수 있나요?', '<place>로 가 주시겠습니까?', '<place>로 이동 바랍니다', '<place>로 가 주면 좋겠어', '<place>에 좀 가 봐', '<place>으로 가', '<place> 가자', '<place>로 ㄱㄱ', '<place> 고', '<place>로 무빙', '<place>로 이동 ㄱ', 'go to <place> 해', '<place> 로 go go',
|
||||
# English
|
||||
"go to <place>", "go to <place> please", "please go to <place>", "head to <place>", "head over to <place>",
|
||||
"drive to <place>", "move to <place>", "go over to <place>", "make your way to <place>", "get to <place>",
|
||||
"take yourself to <place>", "roll over to <place>", "walk to <place>", "travel to <place>", "navigate to <place>",
|
||||
"can you go to <place>", "could you go to <place> please", "would you go to <place>", "will you go to <place>",
|
||||
"would you mind going to <place>", "mind going to <place>", "go to <place> for me", "go to <place> now",
|
||||
"go over to <place> now", "i want you to go to <place>", "i need you to go to <place>", "i'd like you to go to <place>",
|
||||
"can you head over to <place>", "your next stop is <place>",
|
||||
"next, <place>", "off to <place> you go", "let's go to <place>", "let's head to <place>", "lumi, <place>, go",
|
||||
"<place>, please", "<place>, go there", "go there, to <place>", "take me to <place>", "lead me to <place>",
|
||||
"show me the way to <place>", "guide me to <place>", "bring yourself over to <place>", "get over to <place>",
|
||||
"hurry to <place>", "go straight to <place>", "go directly to <place>", "drive over to <place> please",
|
||||
"head for <place>", "set off for <place>", "move over to <place>", "go stand by <place>", "park at <place>",
|
||||
"go park yourself at <place>", "please move to <place> now", "go to <place>, thanks", "go to <place> real quick",
|
||||
# whisper slips, non-native
|
||||
"goto <place>", "go too <place>", "go two <place>", "you go <place>", "go <place>", "going <place> please",
|
||||
"move <place>", "you go to <place> now", "robot go <place>", "please you go <place>",
|
||||
# Korean 반말
|
||||
"<place>로 가", "<place>로 가 줘", "<place>로 가 봐", "<place>로 이동해", "<place>로 이동해 줘", "<place>에 가",
|
||||
"<place>에 가 줘", "<place>까지 가", "<place>까지 가 줘", "<place> 쪽으로 가", "<place>로 가자", "<place>로 좀 가 줘",
|
||||
"<place>로 갈래?", "<place>로 가 줄래?", "<place>로 가 줄 수 있어?", "<place>로 얼른 가", "<place>로 빨리 가",
|
||||
"<place> 가", "<place> 가 줘", "<place>로 가라", "<place>로 출발",
|
||||
"<place>로 출발해", "<place>로 움직여", "<place> 앞으로 가", "<place>로 나 데려다 줘", "<place>까지 안내해 줘",
|
||||
# Korean 해요체
|
||||
"<place>로 가요", "<place>로 가 주세요", "<place>로 가 줘요", "<place>로 이동해요", "<place>로 이동해 주세요",
|
||||
"<place>에 가 주세요", "<place>까지 가 주세요", "<place>로 가 주실래요?", "<place>로 가 줄래요?",
|
||||
"<place>로 가 주실 수 있어요?", "<place>로 좀 가 주세요", "<place> 쪽으로 가 주세요", "<place>로 가 볼래요?",
|
||||
"<place>로 가 보세요", "<place>로 가세요", "<place>까지 안내해 주세요", "<place>로 데려다 주세요",
|
||||
"<place>로 가 주시면 좋겠어요", "<place>로 가 주시겠어요?", "<place>로 가 주시면 감사하겠습니다",
|
||||
# Korean 하십시오체
|
||||
"<place>로 가십시오", "<place>로 가 주십시오", "<place>로 이동하십시오", "<place>로 이동해 주십시오",
|
||||
"<place>까지 이동 바랍니다", "<place>로 이동 부탁드립니다", "<place>로 가 주시기 바랍니다",
|
||||
# mixed, Konglish
|
||||
"<place>로 go", "<place>로 go 해", "<place>로 go 해 줘", "go to <place> 해 줘", "<place> 가 please", "please <place>로 가",
|
||||
"<place>로 move 해 줘", "<place> 쪽으로 go", "lumi, <place>로 가", "루미야 go to <place>", "<place> 고고",
|
||||
"<place>로 고", "<place>로 무브", "<place>로 이동 please", "go <place>로",
|
||||
# Korean slips
|
||||
"<place>로 가조", "<place>로 가져", "<place>러 가", "<place>로 가쥬", "<place>로 이동해 져",
|
||||
]
|
||||
COME = [
|
||||
"come here", "come here please", "come to me", "come over here", "come closer", "come a bit closer", "get over here",
|
||||
"come this way", "over here please", "come over to me", "can you come here", "could you come over here",
|
||||
"would you come to me", "lumi, come here", "hey lumi, come over", "come on over here", "come towards me",
|
||||
"approach me", "move closer to me", "get closer to me", "drive over to me", "come to where i am", "come where i'm standing",
|
||||
"come near me", "come by me", "i need you over here", "i want you to come here", "please come here now",
|
||||
"come to my side", "come stand next to me", "roll over here", "come hither", "kum here", "come hear", "cum here pls",
|
||||
"you come here", "robot come", "come come", "come here quick", "hurry over here",
|
||||
"이리 와", "이리 와 봐", "이리 와 줘", "여기로 와", "여기로 와 줘", "나한테 와", "나한테 와 줘", "가까이 와", "가까이 와 봐",
|
||||
"좀 더 가까이 와", "이쪽으로 와", "이쪽으로 와 봐", "내 쪽으로 와", "내 옆으로 와", "여기 와", "와 봐",
|
||||
"이리 오세요", "이리 와 주세요", "여기로 와 주세요", "저한테 와 주세요", "저한테 와 주실래요?", "가까이 와 주세요",
|
||||
"이쪽으로 와 주세요", "제 옆으로 와 주세요", "여기로 좀 와 주시겠어요?", "이리로 오십시오", "이쪽으로 와 주십시오",
|
||||
"제게 와 주십시오", "come 여기로", "여기로 come", "이리 come", "루미야 come here", "come here 해 줘", "여기로 와 please",
|
||||
"이리 와조", "일루 와", "일로 와", "이루 와",
|
||||
]
|
||||
FOLLOW = [
|
||||
'나 쫓아와', '쫓아와', '쫓아와 줘', 'you follow', 'you follow me', "you're coming with me", 'come along with me now', 'go where i go', 'walk where i walk', 'stay right behind me', '따라오라고', '빨리 따라와',
|
||||
'walk beside me', 'walk next to me', 'stay by my side', 'come along', 'keep close to me', 'follow behind me', 'follow me over there', 'follow me this way', 'be my shadow', 'go with me', 'accompany me', 'escort me', '옆에서 같이 걸어', '저랑 같이 걸어요', '같이 가 줄래?', '나 따라와 봐', '저를 따라와 주시겠어요?', '따라 오세요', '따라오십시오', '저 좀 따라와 주세요', '나만 따라와', '함께 가요', 'follow 해 주세요',
|
||||
"follow me", "follow me please", "please follow me", "come with me", "come along with me", "walk with me",
|
||||
"tag along", "tag along with me", "stay with me", "keep up with me", "stick with me", "stay behind me",
|
||||
"go where i go", "come after me", "follow us", "come with us", "walk behind me", "track me", "follow my lead",
|
||||
"can you follow me", "could you follow me please", "would you follow me", "i want you to follow me",
|
||||
"let's walk together", "come on, follow me", "follow me around", "keep following me", "follow along",
|
||||
"lumi, follow me", "hey lumi, come with me", "follow mi", "fallow me", "follo me", "follow me plz", "you follow me",
|
||||
"robot follow", "me follow you go", "following me please",
|
||||
"따라와", "따라와 줘", "나 따라와", "나를 따라와", "날 따라와", "따라와 봐", "따라 와", "같이 가자", "나랑 같이 가",
|
||||
"나랑 가자", "뒤에서 따라와", "날 따라다녀", "나 따라다녀", "따라올래?", "같이 걸어가자",
|
||||
"따라오세요", "저를 따라오세요", "저 따라오세요", "따라와 주세요", "저랑 같이 가요", "저 따라와 주실래요?",
|
||||
"따라와 줄래요?", "같이 가 주세요", "저를 따라오십시오", "따라와 주십시오", "저와 함께 가시죠",
|
||||
"follow 해", "follow 해 줘", "follow me 해 줘", "나 follow 해", "루미야 follow me", "따라와 please", "팔로우 미",
|
||||
"팔로우 해 줘", "나 팔로우 해", "따라와조", "딸아와",
|
||||
]
|
||||
COME_BACK = [
|
||||
"come back", "come back here", "come back please", "return to where you were", "go back to where you were",
|
||||
"go back to your spot", "go back to your place", "go back to the start", "return to your starting point",
|
||||
"return to your original spot", "go back to where you started", "head back to where you were standing",
|
||||
"come back to your spot", "back to where you were", "go back where you came from", "return please",
|
||||
"can you come back", "could you go back to your old spot", "lumi, come back", "comeback", "come bak",
|
||||
"돌아와", "돌아와 줘", "다시 돌아와", "원래 자리로 돌아와", "원래 자리로 가", "원래 있던 곳으로 돌아가", "제자리로 돌아가",
|
||||
"아까 있던 자리로 가", "처음 자리로 돌아가", "돌아와 봐", "돌아오세요", "돌아와 주세요", "원래 자리로 돌아가 주세요",
|
||||
"제자리로 돌아가 주세요", "원래 위치로 돌아가십시오", "복귀해", "복귀해 주세요", "come back 해 줘", "원래 자리로 go back",
|
||||
"돌아 와", "도라와",
|
||||
]
|
||||
MOVE = [
|
||||
'move 1 meter ahead', 'drive 1 meter ahead slowly', 'go to the left 1 meter', 'drive 1 meter backwards', 'reverse 1 meter', 'roll to your left 1 meter', 'come back 1 meter', 'backwards 1 meter', 'go 1 meter to your right', 'just 1 meter forwards', 'move ahead 1 meter', 'move forward 1 meter', 'go to your right 1 meter', 'back yourself up 1 meter', 'go right by 1 meter', 'move backward 1 meter', 'roll ahead 1 meter', '앞으로 1 meter 가', '뒤로 1 meter 이동해', '왼쪽으로 1 meter 가 줘', '오른쪽으로 1 meter 이동해 주세요',
|
||||
"move forward", "move forward a bit", "go forward a little", "go ahead a bit", "drive forward", "roll forward",
|
||||
"step forward", "take a step forward", "inch forward", "scoot forward", "move ahead", "go straight a little",
|
||||
"move back", "move back a bit", "go back a little", "back up", "back up a bit", "back up a little please",
|
||||
"reverse a bit", "step back", "take a step back", "move backwards", "go backward", "scoot back", "give me some space, back up",
|
||||
"move left", "move to the left", "move to your left a bit", "slide to the left", "shift left a little", "step to the left",
|
||||
"go left a little", "scoot left", "move right", "move to the right", "move to your right a bit", "slide to the right",
|
||||
"shift right a little", "step to the right", "go right a little", "scoot right",
|
||||
"move forward one meter", "go back half a meter", "move left 50 centimeters", "move right 30 cm", "go forward 2 meters",
|
||||
"back up one meter", "move forward 1 m", "move back 0.5 m", "go 20 cm to the left", "go 1 meter to the right",
|
||||
"move forward two steps", "go back one step", "a little forward please", "a bit to the left please",
|
||||
"forward a little", "back a little", "left a bit", "right a bit", "come forward a bit", "move a little closer forward",
|
||||
"moov forward", "move forword", "go fowards", "bak up", "moove back", "move lef", "move rite",
|
||||
"앞으로 가", "앞으로 조금 가", "앞으로 가 봐", "앞으로 좀 가 줘", "앞으로 이동해", "앞으로 한 걸음", "앞으로 한 발짝 와",
|
||||
"조금 앞으로", "뒤로 가", "뒤로 조금 가", "뒤로 물러나", "뒤로 좀 빠져", "뒤로 이동해", "후진해", "후진 좀 해 줘", "뒤로 한 걸음",
|
||||
"조금 뒤로", "왼쪽으로 가", "왼쪽으로 조금 가", "왼쪽으로 이동해", "왼쪽으로 비켜", "왼쪽으로 한 걸음", "조금 왼쪽으로",
|
||||
"오른쪽으로 가", "오른쪽으로 조금 가", "오른쪽으로 이동해", "오른쪽으로 비켜", "오른쪽으로 한 걸음", "조금 오른쪽으로",
|
||||
"앞으로 1미터 가", "뒤로 50센티 가", "왼쪽으로 30센티 이동해", "오른쪽으로 1미터 가", "앞으로 2미터 이동해",
|
||||
"앞으로 가 주세요", "앞으로 조금만 가 주세요", "뒤로 가 주세요", "뒤로 조금 물러나 주세요", "왼쪽으로 가 주세요",
|
||||
"오른쪽으로 이동해 주세요", "앞으로 이동해 주십시오", "뒤로 이동해 주십시오", "왼쪽으로 이동하십시오", "오른쪽으로 이동하십시오",
|
||||
"앞으로 move", "뒤로 back", "left로 가", "right로 이동", "forward로 가", "back 해 줘", "앞으로 go", "뒤로 go",
|
||||
"앞으로 가조", "뒤로 가조", "압으로 가",
|
||||
]
|
||||
TURN = [
|
||||
'hang a left', 'hang a right', '오른쪽으로 꺾어', '왼쪽으로 꺾어', '좌회전 해', '우회전 해', '좌회전', '우회전', 'u턴 해 줘', 'turn right by 90 degrees', 'could you turn 90 degrees to your right', 'spin 90 degrees left', 'rotate 90 degrees to the right', '제자리에서 왼쪽으로 돌아', 'tern right', '턴 레프트', '턴 라이트', 'right로 돌아',
|
||||
'turn yourself to the left', 'turn your body to your left', 'turn your body right', 'rotate your body left', 'please turn yourself to the right', 'turn to face the other way', 'face the other way', 'spin 360 degrees', 'spin all the way around', 'do a full turn', 'turn 90 degrees right', 'rotate 45 degrees left', '좌측으로 회전해', '우측으로 회전해', '좌측으로 20도 회전해 줘', '우측으로 30도 돌아', '반대쪽으로 돌아', '반대로 돌아 서', '몸 돌려', '180도 돌아', '뒤로 돌아서', '왼쪽으로 몸 돌려 줘', '오른쪽으로 방향 바꿔', '방향 바꿔 왼쪽으로',
|
||||
"turn left", "turn right", "turn around", "turn to the left", "turn to the right", "turn your body left",
|
||||
"rotate left", "rotate right", "spin around", "turn left 90 degrees", "turn right 45 degrees", "turn 30 degrees left",
|
||||
"make a left turn", "make a right turn", "do a u-turn", "turn back around", "face the other way", "rotate to your right",
|
||||
"pivot left", "pivot right", "turn yourself around", "about face", "can you turn left", "please turn right",
|
||||
"turn lefft", "tern right", "turn arond", "turn rite",
|
||||
"왼쪽으로 돌아", "오른쪽으로 돌아", "뒤로 돌아", "왼쪽으로 회전해", "오른쪽으로 회전해", "한 바퀴 돌아", "뒤돌아",
|
||||
"왼쪽으로 90도 돌아", "오른쪽으로 45도 돌아", "왼쪽으로 돌아 줘", "오른쪽으로 몸 돌려", "몸을 왼쪽으로 돌려",
|
||||
"왼쪽으로 돌아 주세요", "오른쪽으로 돌아 주세요", "뒤로 돌아 주세요", "왼쪽으로 회전해 주십시오", "오른쪽으로 회전하십시오",
|
||||
"turn 왼쪽", "오른쪽으로 turn", "left로 돌아", "right로 돌아 줘", "왼쪽으로 turn 해", "유턴해", "유턴 해 줘",
|
||||
]
|
||||
LOOK = [
|
||||
'look rightwards', 'look leftwards', 'look upward', 'look downward', 'look at the ground', 'look at your feet', 'look me in the eye', 'watch me', '나 쳐다봐', '저 보세요', '땅 봐', '왼편 봐', '오른편 봐', 'face forward', 'eyes front', 'head back to center', 'reset your head', 'center your head', 'straighten your head', 'put your head back to the middle', '고개 원위치', '고개 가운데로', '고개 원래대로 해 줘', 'front 봐', '앞에 봐', 'look away', 'avert your eyes', 'turn your eyes away', '딴 데 봐', '다른 데 봐', '시선 좀 돌려 줘', 'turn to me', 'turn your head toward me', '고개 나한테 돌려', 'chin up', 'tilt your head up a bit', 'look higher', 'look a bit to the left', '레프트 봐', '라이트 봐', 'swivel your head left', 'turn the head left 60', 'look over to the right', 'look at mee', 'luk right', 'look upp',
|
||||
'glance right', 'glance left', 'eyes up', 'eyes down', 'eyes left', 'eyes right', 'look at the ceiling', 'look at the floor', 'look to your right please', 'look 30 degrees to the left', 'look 20 degrees right', 'turn your head 45 degrees left', 'look up at me', 'look down at the floor', 'look this way please', 'look at my face', '천장 봐', '바닥 봐', '하늘 봐', '땅 봐', '고개 down 해 줘', '고개 up', 'head up 해', '여기 look', '여기 좀 봐', '앞을 보십시오', '정면을 봐요', '왼쪽 좀 봐 줄래?', '오른쪽 쳐다봐', '날 쳐다봐', '저 좀 쳐다봐 주세요', '고개 숙여 주세요', '고개를 왼쪽으로 30도 돌려', '위쪽 봐', '아래쪽 봐', '카메라 봐', '이쪽 좀 봐 주세요',
|
||||
"look at me", "look at me please", "eyes on me", "look over here", "look this way", "face me", "look my way",
|
||||
"turn your head to me", "look at us", "can you look at me", "watch me", "look straight", "look ahead",
|
||||
"look forward", "look straight ahead", "look left", "look to the left", "look right", "look to the right",
|
||||
"look up", "look down", "look up a bit", "look down a little", "turn your head left", "turn your head right",
|
||||
"raise your head", "lower your head", "head up", "head down", "tilt your head up", "tilt your head down",
|
||||
"look behind you", "look back", "look over your shoulder", "look at my son", "look at my daughter",
|
||||
"look at my friend", "lok at me", "luck at me", "look write", "look lef", "eyes over here", "look here please",
|
||||
"나 봐", "날 봐", "나를 봐", "나 좀 봐", "날 좀 봐 줘", "여기 봐", "이쪽 봐", "이쪽을 봐", "정면 봐", "앞을 봐", "왼쪽 봐",
|
||||
"오른쪽 봐", "위 봐", "위를 봐", "아래 봐", "아래를 봐", "고개 들어", "고개 숙여", "고개 왼쪽으로 돌려", "고개 오른쪽으로 돌려",
|
||||
"고개 들어 봐", "뒤 봐", "뒤를 봐", "뒤돌아 봐", "우리 애 좀 봐 줘",
|
||||
"저 봐 주세요", "저를 봐 주세요", "저 좀 봐 주세요", "여기 봐 주세요", "이쪽 봐 주세요", "정면을 봐 주세요",
|
||||
"왼쪽을 봐 주세요", "오른쪽 봐 주세요", "고개 들어 주세요", "위를 봐 주세요", "저를 봐 주십시오", "정면을 보십시오",
|
||||
"look at 나", "나 look", "left 봐", "right 봐", "up 봐", "여기 look", "look 여기", "eyes on 나",
|
||||
]
|
||||
LIFT = [
|
||||
'shrink', 'squat down a bit', 'elevate yourself', 'drop your height', 'lower your height', 'raise your height', 'stretch up tall', 'go all the way down', 'keep going down', 'move up for a sec', 'move down', 'drop down an inch', 'raise up by 1 meter', 'go up 1 meter', 'come down 1 meter', '몸 좀 들어 올려 줄래?', '몸 위로', '높이 좀 낮춰 주실래요?', '조금 낮아져 줄래?', '높이 올려', '더 올려', '아래로 내려가 봐', '1 meter 높여 줘', '1 meter 내려가',
|
||||
'go up a bit', 'go up', 'go down', 'up a little', 'down a little', 'sink down', 'rise up', 'get up higher', 'a bit higher please', 'a bit lower please', 'lower down a little', 'raise up', 'move up', 'move down a bit', 'lift up a little', 'make yourself a bit higher', 'come up a bit', '커져 봐', '좀 더 커져 봐', '키 커져 봐', '작아져 봐', '올라가', '조금만 올라가 줄래요?', '내려가', '조금 내려가 줘', '높이 올려 줘요', '높게 올라가', '낮게 내려가', '위로 올라가 줘', '아래로 내려가 줘', '키 좀 키워 줘', '키 좀 줄여 줘', '몸 좀 높여 주세요', 'go up 해 봐', 'up 해 줘', 'down 해 줘',
|
||||
"raise yourself", "raise yourself up", "lift yourself up", "get taller", "make yourself taller", "stand up tall",
|
||||
"go higher", "lower yourself", "get shorter", "make yourself shorter", "go lower", "get a bit taller",
|
||||
"get a little lower", "raise your body", "lower your body", "lift your body up", "raise your torso",
|
||||
"lower your torso", "lift up", "stand taller", "rise up a bit", "come down a bit", "shrink down a little",
|
||||
"raise yourself 5 cm", "lower yourself 3 centimeters", "grow taller", "get smaller", "lift yourself",
|
||||
"키 높여", "키 좀 높여", "키 키워", "키 낮춰", "키 좀 낮춰", "몸 올려", "몸 내려", "몸 좀 올려 봐", "몸 좀 낮춰", "몸을 낮춰",
|
||||
"리프트 올려", "리프트 내려", "상체 올려", "상체 내려", "더 높게", "더 낮게", "키 좀 높여 주세요", "몸을 올려 주세요",
|
||||
"몸을 낮춰 주세요", "리프트 올려 주세요", "리프트를 내려 주십시오", "키를 높여 주십시오", "lift 올려 줘", "lift 내려",
|
||||
"키 up", "몸 down", "taller 해 줘", "몸 업", "리프트 업",
|
||||
]
|
||||
WAVE = [
|
||||
'mind giving us a wave', 'give a wave', 'give them a wave', 'wave for the camera', 'wave once more', 'wave again', 'one more wave', 'do your hand wave', 'do your wave', 'show me your wave', '팔 흔들어 봐', '팔 흔들어 줘', '한 번만 더 흔들어 줘', '다시 손 흔들어', '손 한 번 흔들어 봐', '손 흔들어 인사해', '인사 손 흔들어 줘', '바이바이 손 흔들어', '손 흔들어 주실래요?', '손 좀 흔들어 줄래?', 'wave 한 번 해 줘', '손 흔들기 해 줘',
|
||||
"wave", "wave at me", "wave to me", "wave your hand", "wave hello", "wave hi", "wave at us", "give us a wave",
|
||||
"give me a wave", "wave to the people", "wave to everyone", "wave to the guests", "say hi with your arm",
|
||||
"say hi with your hand", "say hello with your hand", "greet them with your hand", "wave your arm",
|
||||
"wave goodbye to them", "wave to the kids", "can you wave", "could you wave at us", "please wave",
|
||||
"do a wave", "show us your wave", "shake your hand at me", "lift your hand and wave", "wave your arm around",
|
||||
"greet me with a wave", "a little wave please", "wave wave", "wave plz", "weave at me", "wave et me", "way of hello",
|
||||
"손 흔들어", "손 흔들어 줘", "손 흔들어 봐", "손 좀 흔들어", "손 인사 해", "손 인사 해 줘", "손으로 인사해", "손으로 인사해 봐",
|
||||
"팔 흔들어", "팔 흔들어 봐", "우리한테 손 흔들어", "애들한테 손 흔들어 줘", "손 흔들면서 인사해", "흔들어 봐",
|
||||
"손 흔들어 주세요", "손 좀 흔들어 주세요", "손 인사 해 주세요", "손으로 인사해 주세요", "저희한테 손 흔들어 주세요",
|
||||
"손을 흔들어 주십시오", "손 인사를 해 주십시오", "wave 해", "wave 해 줘", "손 wave", "웨이브 해 줘", "손 흔들어 please",
|
||||
"hi 해 봐 손으로", "손 흔드러", "손 흔들어조",
|
||||
]
|
||||
ARM_REACH = [
|
||||
'reach your hand to me', 'hold out you hand', 'hold it out', '나한테 손 줘', '손 이리 줘 봐', 'hand 줘 봐', '손 줘 봐', 'reach out, thanks', 'reach your arm out', 'reech out to me',
|
||||
'arm out', 'arm out please', 'put your hand out', 'reach forward', 'extend your hand', 'stretch out', 'stretch your hand forward', '손 앞으로 내밀어', '손 좀 앞으로 내밀어 주세요', '팔 extend 해 줘', '팔 앞으로', '팔 앞으로 뻗어', '팔 펴 줘', '팔 쭉 펴 주세요', '팔 내밀어 줄래?', '손 뻗어', 'reach out 해 줘',
|
||||
"reach out", "reach out your arm", "stretch your arm", "stretch out your arm", "extend your arm", "hold out your arm",
|
||||
"hold out your hand", "put your arm out", "stick your arm out", "give me your hand", "offer me your hand",
|
||||
"reach towards me", "reach out to me", "arm out please", "straighten your arm", "lift your arm up", "raise your arm",
|
||||
"show me your arm", "reach your hand out", "can you reach out your arm",
|
||||
"팔 뻗어", "팔 뻗어 봐", "팔 좀 뻗어", "팔 내밀어", "팔 좀 내밀어 봐", "팔을 쭉 뻗어 줘", "손 내밀어", "손 좀 내밀어 봐",
|
||||
"팔 쭉 펴", "팔 들어", "팔 올려", "팔 뻗어 주세요", "팔을 내밀어 주세요", "손을 내밀어 주세요", "팔을 뻗어 주십시오",
|
||||
"arm 뻗어", "팔 reach", "팔 쭉", "팔 뻐더",
|
||||
]
|
||||
ARM_FOLD = [
|
||||
'pull your arm back in', 'pull your hand back in', 'take your hand back', 'arm back home', 'bring the arm home', '손 다시 넣어', '이제 접어', '접어', '팔 다시 넣어', 'fold you arm', '넣어',
|
||||
'fold arm', 'fold it', 'you can fold your arm now', 'arm in', 'arm away', 'retract your arm', 'bring your arm in', 'tuck it in', '팔 제자리로', '팔 원위치', '팔 다시 접어', '팔 넣어 줘', 'fold arm 해 줘', '팔 fold', '팔 거둬 줘', '팔 내려 줄래?',
|
||||
"fold your arm", "fold your arm up", "put your arm down", "put your arm away", "take your arm back", "tuck your arm in",
|
||||
"arm down", "bring your arm back", "lower your arm", "pull your arm in", "rest your arm", "arm back please",
|
||||
"put your arm back", "relax your arm", "drop your arm",
|
||||
"팔 접어", "팔 접어 줘", "팔 내려", "팔 좀 내려", "팔 거둬", "팔 넣어", "팔 원래대로", "팔 접어 주세요", "팔을 내려 주세요",
|
||||
"팔을 거둬 주세요", "팔을 접어 주십시오", "arm 접어", "팔 down", "팔 내려 please",
|
||||
]
|
||||
ARM_OPEN = [
|
||||
"open your hand", "open your fingers", "open the gripper", "open your gripper", "open up your hand", "spread your fingers",
|
||||
"unclench your hand", "open your claw", "hand open please",
|
||||
"손 펴", "손 펴 봐", "손 좀 펴 봐", "손 벌려", "손가락 펴", "그리퍼 열어", "손 열어", "손 펴 주세요", "손을 펴 주십시오",
|
||||
"그리퍼 열어 주세요", "hand 펴", "손 open", "gripper open 해",
|
||||
]
|
||||
ARM_CLOSE = [
|
||||
"close your hand", "close your fingers", "close the gripper", "make a fist", "clench your hand", "squeeze your fingers",
|
||||
"close your claw", "shut your hand", "hand closed please",
|
||||
"손 쥐어", "손 꽉 쥐어", "주먹 쥐어", "손 오므려", "그리퍼 닫아", "손 닫아", "손가락 오므려", "손 쥐어 주세요",
|
||||
"주먹 쥐어 주세요", "그리퍼 닫아 주십시오", "손 close", "gripper close 해", "주먹 쥐어 봐",
|
||||
]
|
||||
PICK = [
|
||||
'take hold of the <obj>', 'get hold of the <obj>', 'snatch the <obj>', 'snatch a <obj>', 'try picking up the <obj>', '<obj> pick 해 줘', '<obj> 픽 해 줘', '<obj> 픽업해 줘', '<obj> take 해 줘', '<obj> 좀 take 해', '<obj> 집으세요', '<obj> 한번 집어 봐요', '<obj> 쥐어 봐', '<obj> 들어 봐', 'grab 해 <obj>', '<obj> pick up 해', 'pick upp the <obj>',
|
||||
'would you mind grabbing the <obj>', 'mind grabbing the <obj>', 'grab me the <obj> off the table', 'pick the <obj> up off the table', 'take hold of that <obj>', 'can you grab that <obj>', 'lift up the <obj>', '<obj> pick up', '<obj> 좀 pick up', '<obj> 집어 줄래?', '<obj> 좀 집어 줄래요?', '<obj> 잡아 볼래?', '<obj> 들어 볼래?', '<obj> 하나 집어', '<obj> 좀 집으세요', '<obj>을 집어 주십시오', '<obj> 잡으세요',
|
||||
"pick up the <obj>", "take the <obj>", "grab the <obj>", "get the <obj>", "pick the <obj> up", "lift the <obj>",
|
||||
"take hold of the <obj>", "grab that <obj>", "snag that <obj>", "can you pick up the <obj>",
|
||||
"could you grab the <obj> please", "would you mind picking up the <obj>", "please take the <obj>",
|
||||
"pick up that <obj> on the table", "take the <obj> from the table", "grab the <obj> over there",
|
||||
"i want you to pick up the <obj>", "pick up the <obj> for me", "go ahead and grab the <obj>", "pic up the <obj>",
|
||||
"pick op the <obj>", "grap the <obj>", "take da <obj>",
|
||||
"<obj> 집어", "<obj> 집어 줘", "<obj> 좀 집어 봐", "<obj> 들어", "<obj> 들어 줘", "<obj> 잡아", "<obj> 잡아 줘", "<obj> 집어 올려",
|
||||
"<obj> 들어 올려", "<obj> 좀 잡아 봐", "저 <obj> 집어", "테이블 위에 <obj> 집어", "<obj> 집어 주세요", "<obj> 좀 들어 주세요",
|
||||
"<obj> 잡아 주세요", "<obj> 집어 주실래요?", "<obj> 들어 줄래요?", "<obj> 집어 주십시오", "<obj>을 들어 주십시오",
|
||||
"<obj> pick up 해 줘", "<obj> 좀 pick up 해", "pick up <obj>", "<obj> grab 해", "<obj> 픽업 해 줘", "<obj> 집어조",
|
||||
]
|
||||
PUT = [
|
||||
"put it down", "set it down", "put that down", "place it down", "put the cup down", "lay it down", "drop it here",
|
||||
"put it back", "put it back where it was", "return it to where it was", "put the cup back", "set it back down",
|
||||
"can you put it down", "please put it down now",
|
||||
"내려놔", "내려놔 줘", "내려 놓아", "그거 내려놔", "컵 내려놔", "제자리에 놔", "원래 자리에 놔", "다시 갖다 놔", "도로 놔",
|
||||
"내려놔 주세요", "내려 놓아 주세요", "제자리에 놔 주세요", "원래 자리에 놓아 주십시오", "put down 해", "내려놔 please",
|
||||
"put it back 해 줘",
|
||||
]
|
||||
FETCH = [
|
||||
"bring me the <obj>", "bring me a <obj>", "get me the <obj>", "get me a <obj>", "fetch the <obj>", "fetch me a <obj>",
|
||||
"bring the <obj> to me", "bring the <obj> here", "go get the <obj>", "go get me a <obj>", "can you bring me the <obj>",
|
||||
"could you get me a <obj> please", "i'd like a <obj>, bring it here", "would you fetch me the <obj>",
|
||||
"bring over the <obj>", "hand me the <obj>", "pass me the <obj>", "brin me the <obj>", "bring me da <obj>",
|
||||
"<obj> 가져와", "<obj> 가져다 줘", "<obj> 갖다 줘", "<obj> 좀 가져와 봐", "<obj> 가지고 와", "<obj> 좀 갖다 줄래?",
|
||||
"나한테 <obj> 가져다 줘", "<obj> 여기로 가져와", "<obj> 가져다 주세요", "<obj> 좀 갖다 주세요", "<obj> 가져와 주실래요?",
|
||||
"저한테 <obj> 가져다 주세요", "<obj>을 가져다 주십시오", "<obj> bring 해 줘", "<obj> 가져와 please", "bring <obj> 해 줘",
|
||||
"<obj> 가저와",
|
||||
]
|
||||
NO = [
|
||||
'인스타 팔로우 해 줘', 'follow us on instagram', 'follow our account', '따라 해 봐', '내 말 따라 해', 'repeat after me', 'copy me', 'do what i do', 'can you lend me a hand?', 'give me a hand with this', '한 번만 더 해 줘', 'do it again', 'again please', 'one more time', '다시 해 줘', '또 해 봐', '한 번 더', 'over here for a sec', 'wait over there', 'the other way', '왼쪽으로', '오른쪽으로', '앞으로', '뒤로',
|
||||
'can your arm move?', 'how long is your arm?', 'how far can you reach?', '악수하자', '악수할래?', 'can you turn your head?', 'is your head turning?', 'how high can you go?', 'how low can you go?', "what's on the ceiling?", 'is the floor clean?', 'where are you looking?', 'what are you looking at?', '어디 보고 있어?', '왜 나를 봐?', '왜 따라와?', '키가 몇이야?', '팔 길이가 얼마야?', '고개 아파?', '손 차가워?', '손 따뜻해?',
|
||||
# cut-off starts
|
||||
"let's", "can you", "could you", "please", "lumi, can you", "wait", "hmm", "so", "go", "move", "turn", "look",
|
||||
"루미야 저기", "저기요", "루미야", "혹시", "그럼", "잠깐만", "있잖아", "근데",
|
||||
# talk about places, trips and the map
|
||||
"i went to the stage yesterday", "the stage is over there", "where is the stage?", "what's at booth A?",
|
||||
"how far is the lobby?", "is the coffee corner open?", "the exit is on the left", "i'm going to the lobby",
|
||||
"my friend is at booth A", "have you been to the stage?", "do you know where the exit is?", "which booth is yours?",
|
||||
"how do i get to the stage?", "can i go to the lobby?", "is it far to the entrance?", "the lobby is crowded",
|
||||
"스테이지 어디야?", "로비가 어디예요?", "출구 어디 있어요?", "부스 A에 뭐 있어?", "커피 코너 열었어요?", "저 로비로 갈게요",
|
||||
"나 스테이지 갔다 왔어", "로비 멀어요?", "화장실 어디예요?", "입구가 어디죠?", "스테이지까지 얼마나 걸려?",
|
||||
"where are you going?", "where did you go?", "어디 가?", "어디 가는 거야?", "어디 갔다 왔어?",
|
||||
# ability, how
|
||||
"can you walk?", "can you move by yourself?", "can you pick things up?", "how do you pick up a cup?",
|
||||
"are you able to follow people?", "how fast can you move?", "can you climb stairs?", "do you have arms?",
|
||||
"how heavy can you lift?", "can you see me?", "how do you know where to go?", "can robots dance?",
|
||||
"물건 집을 수 있어?", "혼자 움직일 수 있어?", "어떻게 컵을 집어?", "사람 따라갈 수 있어요?", "계단 올라갈 수 있어?",
|
||||
"얼마나 빨리 움직여?", "팔 있어?", "몇 킬로까지 들 수 있어?", "어떻게 길을 찾아?", "손 흔들 줄 알아?",
|
||||
# negation, stop
|
||||
"don't go to the stage", "don't move", "don't follow me", "don't look at me", "stop following me", "no, stay here",
|
||||
"stay where you are", "don't wave", "don't pick that up", "leave the cup", "stay put", "you don't have to come",
|
||||
"가지 마", "움직이지 마", "따라오지 마", "쳐다보지 마", "손 흔들지 마", "그거 집지 마", "거기 그대로 있어", "가만히 있어",
|
||||
"오지 마세요", "안 와도 돼", "따라오지 마세요",
|
||||
# later, conditions
|
||||
"go to the stage when the guests arrive", "after the talk, wave to them", "if someone comes, follow them",
|
||||
"later you can go to the lobby", "wave when i say so", "come here after the meeting", "tomorrow go to booth A",
|
||||
"손님 오시면 손 흔들어", "나중에 스테이지로 가", "회의 끝나면 이리 와", "내가 부르면 와", "이따가 로비로 가",
|
||||
"사람 오면 따라가",
|
||||
# to someone else
|
||||
"mom, look at the robot", "kids, wave to the robot", "honey, come here", "jake, come see this", "민수야 이리 와",
|
||||
"엄마 이거 봐", "얘들아 로봇한테 손 흔들어", "지민아 따라와", "여보 이리 와 봐",
|
||||
# closings, back-channels
|
||||
"okay", "thanks", "thank you", "okay thanks", "i see", "got it", "alright", "sounds good", "cool", "nice",
|
||||
"that's all", "that's it", "never mind", "good job", "well done", "great", "perfect",
|
||||
"알겠어", "알겠어요", "고마워", "감사합니다", "오케이", "됐어", "됐어요", "그렇구나", "좋아", "잘했어", "수고했어", "괜찮아",
|
||||
# talk, opinions, about Lumi
|
||||
"you look cute", "your arm is cool", "i like your hand", "you move so smoothly", "you turned really fast",
|
||||
"that was a nice wave", "you're tall", "your head moves", "nice to meet you", "hello", "hi lumi", "good morning",
|
||||
"what's your name?", "who made you?", "how old are you?", "tell me about yourself", "tell me a joke",
|
||||
"what can you do?", "what are you doing?", "are you busy?", "how's your battery?", "are you tired?",
|
||||
"귀엽다", "팔 멋있다", "손 신기하다", "움직임 부드럽네", "키 크다", "반가워", "안녕", "안녕하세요", "이름이 뭐야?",
|
||||
"누가 만들었어?", "몇 살이야?", "자기소개 해 줘", "농담 해 줘", "뭐 할 수 있어?", "뭐 하고 있어?", "배터리 얼마나 남았어?",
|
||||
# company / event questions
|
||||
"what does cutshion do?", "who is the ceo of your company?", "where is your company?", "how many people work there?",
|
||||
"tell me about cutshion", "what products do you make?", "is this booth yours?", "when does the event end?",
|
||||
"쿳션은 뭐 하는 회사야?", "회사 어디 있어요?", "대표가 누구예요?", "직원 몇 명이에요?", "이 행사 언제 끝나요?",
|
||||
# visitor about themselves
|
||||
"i'll follow you", "let me follow you", "i'm going to wave", "i can lift that", "i picked up the cup",
|
||||
"i'm looking at you", "i turned left at the corner", "i'll come back later", "i'll bring you a cup",
|
||||
"제가 따라갈게요", "내가 손 흔들게", "제가 컵 들게요", "저 왼쪽으로 돌았어요", "나중에 다시 올게요", "내가 가져올게",
|
||||
"my son wants to see you wave", "he went to the lobby", "she looked at you", "they picked up the cups",
|
||||
# seeing questions
|
||||
"what am i holding?", "what colour is my shirt?", "how many people do you see?", "do you see the cup?",
|
||||
"is there a bottle on the table?", "what's in front of you?", "뭐 들고 있게?", "내 옷 무슨 색이야?", "컵 보여?",
|
||||
"앞에 뭐 있어?", "사람 몇 명 보여?",
|
||||
# things that sound like commands but are not
|
||||
"look it up", "look up the weather", "look for my keys", "turn off the lights", "turn the music down",
|
||||
"pick a number", "pick one for me", "take a picture", "take a guess", "take care", "take your time",
|
||||
"go ahead, tell me", "go on", "come on", "come on, really?", "follow the rules", "follow your heart",
|
||||
"bring it on", "put it on my tab", "wave of people", "the wave was big", "raise the volume", "lower the volume",
|
||||
"lift me up with a song", "turn up the music", "give me a hint", "give me a second", "hold on",
|
||||
"날씨 찾아 봐", "검색해 봐", "불 꺼", "볼륨 줄여", "사진 찍어", "아무거나 골라", "계속해", "말해 봐", "잠깐 기다려",
|
||||
]
|
||||
RECEIVE = [
|
||||
"take this", "take this from me", "hold this", "hold this <obj>", "take my <obj>", "here, take it", "here you go, take it",
|
||||
"i want to give you a <obj>", "i'm handing you the <obj>", "take the <obj> from my hand", "grab this from me",
|
||||
"can you hold this for me", "keep this for me", "take it from me", "catch this", "i have a <obj> for you",
|
||||
"이거 받아", "이거 받아 줘", "이거 들고 있어", "이 <obj> 받아 줘", "제 손에 있는 <obj> 가져가세요", "<obj> 드릴게요",
|
||||
"이거 좀 들어 줘", "이거 가져가", "이거 받아 주세요", "이것 좀 들고 계세요", "<obj> 받아 줄래요?", "이거 take 해",
|
||||
]
|
||||
GIVE = [
|
||||
"give it to me", "give me that", "hand it over", "pass it over here", "give it back", "give me what you're holding",
|
||||
"can i have it", "let me have it", "hand it to me please", "give that to me", "i'll take it now", "pass it to me",
|
||||
"이리 줘", "그거 줘", "그거 이리 주세요", "나 줘", "저 주세요", "줘 봐", "돌려줘", "그거 저한테 주세요", "건네줘",
|
||||
"이리 넘겨", "give me 해 줘", "나한테 줘",
|
||||
]
|
||||
NO += [
|
||||
"face <place>", "look at <place>", "look towards <place>", "point at <place>", "<place> 쪽을 봐", "<place> 봐",
|
||||
"go upstairs", "go downstairs", "위층으로 가", "아래층으로 가", "go to sleep", "go to bed", "go home now, i'm tired",
|
||||
"the <obj>", "<obj>", "the <obj> the <obj>", "a <obj>", "<obj> <obj>", "that <obj>", "my <obj>", "your <obj>",
|
||||
"<obj> 있어", "<obj>야", "그 <obj>", "내 <obj>", "<obj> 예쁘다", "<obj> 좋아해", "<obj> 맛있어", "i like the <obj>",
|
||||
"this <obj> is mine", "the <obj> is red", "i bought a <obj>", "i need a new <obj>", "<obj> 샀어", "이 <obj> 내 거야",
|
||||
"go for it", "go away", "get lost", "come on now", "come again?", "follow up later", "look who's here",
|
||||
"lift my mood", "turn it off", "wave goodbye to your old life", "move on", "let it go", "back off from that topic",
|
||||
"저리 가", "가 버려", "꺼져", "됐어 가", "알아서 해", "마음대로 해", "좀 쉬어", "가만있어 봐",
|
||||
]
|
||||
KINDS = {"go_to": GO, "come": COME, "follow": FOLLOW, "come_back": COME_BACK, "move": MOVE, "turn": TURN, "look": LOOK,
|
||||
"lift": LIFT, "wave": WAVE, "arm_reach": ARM_REACH, "arm_fold": ARM_FOLD, "arm_open": ARM_OPEN,
|
||||
"arm_close": ARM_CLOSE, "pick": PICK, "put": PUT, "fetch": FETCH, "receive": RECEIVE, "give": GIVE, "no": NO}
|
||||
ACTS = set(KINDS) - {"put", "receive", "give", "no"} # the kinds the bank acts on; the hand's (put down, take, hand
|
||||
# over) are brain.hand_request's or the LLM's
|
||||
|
||||
|
||||
def _fill(t, slot, en, ko):
|
||||
if slot not in t:
|
||||
return [t]
|
||||
pool = ko if re.search(r"[가-힣]", t.replace(slot, "")) else en
|
||||
return [t.replace(slot, f) for f in R.sample(pool, FILLS)]
|
||||
|
||||
|
||||
def examples():
|
||||
"""[(text, kind)]: the bank with its <place> / <obj> slots filled (FILLS each, a fixed seed)."""
|
||||
R.seed(11)
|
||||
out = []
|
||||
for kind, texts in KINDS.items():
|
||||
for t in texts:
|
||||
for a in _fill(t, "<place>", PLACE_EN, PLACE_KO):
|
||||
out += [(b, kind) for b in _fill(a, "<obj>", OBJ_EN, OBJ_KO)]
|
||||
return out
|
||||
|
||||
|
||||
_bank = None
|
||||
|
||||
|
||||
def _load():
|
||||
"""(vectors, kinds) of the bank: from data/intent_bank.npz when it holds these very wordings, else embedded now."""
|
||||
global _bank
|
||||
if _bank is None:
|
||||
from assistant import knowledge
|
||||
ex = examples()
|
||||
texts = [t for t, _ in ex]
|
||||
key = hashlib.sha1("\n".join(f"{t}\t{k}" for t, k in ex).encode()).hexdigest()
|
||||
if CACHE.exists():
|
||||
z = np.load(CACHE)
|
||||
if str(z["key"]) == key:
|
||||
_bank = (z["vecs"], z["kinds"])
|
||||
return _bank
|
||||
vecs = knowledge.embed(texts)
|
||||
kinds = np.array([k for _, k in ex])
|
||||
np.savez(CACHE, vecs=vecs, kinds=kinds, key=key)
|
||||
_bank = (vecs, kinds)
|
||||
return _bank
|
||||
|
||||
|
||||
POLITE = re.compile(r"\bif you don'?t mind\b|\b(?:it'?d|it would|that would|that'?d) be (?:great|nice|good|lovely|awesome|"
|
||||
r"cool|helpful) if you(?: could)?\b|^\W*go ahead and\b|\bfor a (?:sec|second|moment|bit)\b", re.I)
|
||||
LEAD = re.compile(r"^\W*(?:(?:excuse me|okay so|ok so|so|uh+|um+|yo|hi|hey|hello|alright|all right|okay|ok|well|listen|"
|
||||
r"buddy|lumi|robot|hey robot|루미야|루미씨|루미|저기요|저기|자|야|음|어|좋아|이제|그럼|근데|그런데|아|like)\b[\s,.!~]*)+", re.I)
|
||||
AMOUNT = [(re.compile(r"\b\d+(?:\.\d+)?\s*(?:degrees?|도)(?![a-z])|\b\d+(?:\.\d+)?도", re.I), "90 degrees"),
|
||||
(re.compile(r"\b\d+(?:\.\d+)?\s*(?:m|meters?|metres?|cm|centimet(?:er|re)s?|mm|millimet(?:er|re)s?|"
|
||||
r"미터|센티(?:미터)?|센치|밀리)(?![a-z])", re.I), "1 meter")] # embedded as one amount
|
||||
|
||||
|
||||
def plain(text):
|
||||
"""The words without polite frames ("if you don't mind", "it'd be great if you could") and calls before."""
|
||||
t = POLITE.sub(" ", text or "")
|
||||
t = LEAD.sub("", t).strip()
|
||||
return re.sub(r"\s{2,}", " ", t) or (text or "").strip()
|
||||
|
||||
|
||||
def guarded(text):
|
||||
"""Why the bank does not read these words, or None."""
|
||||
from assistant import brain
|
||||
t = text.strip()
|
||||
if len(t) < MIN_CHARS or len(t.split()) > MAX_WORDS:
|
||||
return "length"
|
||||
for name, rx in (("negation", NEGATION), ("later", LATER), ("ability", ABILITY), ("question", QUESTION),
|
||||
("self", SELF_TALK), ("several", SEVERAL), ("hand", HAND_WORDS), ("other sense", OTHER_SENSE),
|
||||
("repeat", REPEAT)):
|
||||
if rx.search(t):
|
||||
return name
|
||||
if brain.LATER.search(t):
|
||||
return "later"
|
||||
name = NAME_CALL.match(t)
|
||||
if brain.to_someone_else(t) or brain.to_someone_else(brain.CALLING.sub("", t)) or name and name.group(1).lower() not in NOT_A_NAME:
|
||||
return "someone else"
|
||||
if brain.is_closing(t) or brain.BACKCHANNEL.match(t):
|
||||
return "closing"
|
||||
return None
|
||||
|
||||
|
||||
def nearest(text, k=5):
|
||||
"""[(similarity, kind, wording)] of the k closest bank wordings (one embed call)."""
|
||||
from assistant import knowledge
|
||||
vecs, kinds = _load()
|
||||
q = knowledge.embed([text])[0]
|
||||
sims = vecs @ q
|
||||
top = np.argsort(-sims)[:k]
|
||||
texts = [t for t, _ in examples()] if k else []
|
||||
return [(float(sims[i]), str(kinds[i]), texts[i]) for i in top], sims, kinds
|
||||
|
||||
|
||||
TAIL = re.compile(r"(?:[\s,.!?~]+(?:please|thanks|thank you|for me|now|right now|real quick|if you can|lumi|okay|"
|
||||
r"고마워|고마워요|감사합니다|감사해요|부탁해|부탁해요|부탁합니다|루미야|제발))+[\s,.!?~]*$", re.I)
|
||||
CANON_PLACE = "p3" # a named marker is embedded as this one: the bank's wordings know it, any map's names work
|
||||
|
||||
|
||||
def core(text, markers=()):
|
||||
"""The words the bank compares: calls and fillers before ("hey Lumi, um"), politeness after ("please",
|
||||
"감사합니다") cut, and the one marker named written as CANON_PLACE ("go to the coffee corner" -> "go to p3")."""
|
||||
from assistant import brain
|
||||
t = TAIL.sub("", brain.CALLING.sub("", plain(text))).strip(" ,.!?~") or text
|
||||
named = [m for m in markers if brain.named_place(t, m, markers)]
|
||||
if len(named) == 1:
|
||||
low = brain._norm(t, markers)
|
||||
swapped = re.sub(rf"(?<![a-z0-9])(?:the )?{re.escape(named[0].lower())}(?![a-z0-9])", CANON_PLACE, low)
|
||||
if swapped != low:
|
||||
t = swapped
|
||||
for rx, canon in AMOUNT:
|
||||
t = rx.sub(canon, t)
|
||||
return t
|
||||
|
||||
|
||||
def kind_of(text, markers=()):
|
||||
"""The bank's kind for these words (a QUICK kind or "arm_*"), or None when it is not sure or it is "no"."""
|
||||
from assistant import knowledge
|
||||
vecs, kinds = _load()
|
||||
try:
|
||||
q = knowledge.embed([core(text, markers)])[0]
|
||||
except OSError as e: # no embedding server: the LLM decides
|
||||
print(f"intent bank: {e}")
|
||||
return None
|
||||
sims = vecs @ q
|
||||
order = np.argsort(-sims)[:AGREE_K]
|
||||
best = kinds[order[0]]
|
||||
if best not in ACTS or sims[order[0]] < SIM_MIN or any(kinds[i] != best for i in order):
|
||||
return None
|
||||
if sims[order[0]] - sims[kinds != best].max() < MARGIN:
|
||||
return None
|
||||
return str(best)
|
||||
|
||||
|
||||
# ---------- slots: what the words themselves say ----------
|
||||
DIR = {"forward": r"\b(?:forward|forwards|forword|ahead|straight)\b|앞으로|앞쪽|^\s*앞|forward로",
|
||||
"back": r"\b(?:back|backward|backwards|reverse|bak)\b|뒤로|후진|뒤쪽|물러",
|
||||
"left": r"\bleft|\blef\b|왼쪽|왼편|좌측", "right": r"\bright\b|\brite\b|오른쪽|오른편|우측"}
|
||||
|
||||
|
||||
CARRY = (r"\b(?:bring(?! yourself)|fetch|deliver|carry)\b|\bget me\b|\b(?:to|for) me\b(?=.*\b(?:bring|get|fetch|hand|pass)\b)|"
|
||||
r"가져|갖다|가지고 ?와|가져다") # words that bring a thing to someone
|
||||
COME_VERB = (r"\bcome\b|\bcum\b|\bkum\b|\bget over\b|\bapproach|\bcloser\b|\bhither\b|\bnear me\b|"
|
||||
r"\bget closer\b|\broll over\b|\bdrive over\b|\bmy side\b|\bnext to me\b|\bto me\b|와|오세요|오십시오|오시|올래")
|
||||
LIFT_BODY = (r"\b(?:yourself|your (?:body|torso|upper body)|taller|shorter|smaller|tall|lift|rise|grow|"
|
||||
r"shrink|come down|go up|go down|move up|move down|raise up|lower down|come up|sink down|elevate|squat|height|"
|
||||
r"stretch up|drop down|going down|going up)\b|위로|아래로|낮아|높아|"
|
||||
r"키|몸|리프트|상체|높게|낮게|높이|커져|작아져|올라|내려가|업\b|다운")
|
||||
|
||||
|
||||
MOVE_VERB = (r"\b(?:move|go|step|back up|backup|scoot|slide|shift|drive|roll|reverse|inch|come|forward|backward|ahead|"
|
||||
r"moov|moove|bak)|가|이동|물러|비켜|후진|와|빠져|걸음|발짝|move|back|go") # a bare "왼쪽으로" may be a look
|
||||
|
||||
|
||||
LOOK_DIR = {"left": r"\bleft|왼|레프트", "right": r"\bright|\brite\b|오른|라이트",
|
||||
"up": r"\bup|\bupward|\bceiling|\bsky\b|\bhigher\b|천장|하늘|(?<!원)위", "down": r"\bdown|\bfloor|\bground|\bfeet\b|바닥|땅|아래|밑"}
|
||||
LOOK_ME = (r"\b(?:at|on|to|toward|towards) (?:me|us|나)\b|\bthis way\b|\bover here\b|\bmy way\b|\bhere\b|\bwatch me\b|"
|
||||
r"\bme in the eye|\bmy face\b|나한테|저한테|쳐다봐|(?:^|\s)(?:여기|이쪽|저|나|날)(?:를|을)?\s*(?:좀\s*)?(?:봐|보세요|look)")
|
||||
|
||||
|
||||
def _dirs(t):
|
||||
return [d for d, rx in DIR.items() if re.search(rx, t)]
|
||||
|
||||
|
||||
def _slot(kind, text, markers, holding):
|
||||
"""The (action, target) lumi.quick_command takes, or None when the words don't say it plainly."""
|
||||
from assistant import brain, driving
|
||||
t = brain._norm(text, markers)
|
||||
if kind == "go_to":
|
||||
if brain._mentions(text, markers).get("object") or re.search(r"\bfrom\b|에서|에 있는|\bface\b|\blook|\bpoint|봐|"
|
||||
+ CARRY + r"|\btake (?:it|this|that|them)\b", t):
|
||||
return None # "get the bottle from booth two": a fetch, the rules' / LLM's
|
||||
named = [m for m in markers if brain.named_place(text, m, markers)]
|
||||
return ("go_to", named[0]) if len(named) == 1 else None
|
||||
if kind == "come" and (re.search(CARRY + r"|따라", t) or not re.search(COME_VERB, t)):
|
||||
return None # "나한테 가져와", "이리 줘": not a trip to the person
|
||||
if kind == "come" and re.search(r"\bwith (?:me|us)\b|함께|같이", t):
|
||||
return ("follow", "") # "just come with me": walk along
|
||||
if kind == "come_back" and (re.search(r"\bpose\b|\barm\b|\bhead\b|팔|고개", t) or
|
||||
any(brain.named_place(text, m, markers) for m in markers)):
|
||||
return None # "go back to your dock", "go back to your look pose": not here
|
||||
if kind == "come_back" and re.search(r"\bhere\b|\bto me\b|이리|여기|나한테|저한테", t):
|
||||
return ("come", "") # "come back here": to the person, not to the old spot
|
||||
if kind == "follow" and re.search(r"\bfollow (?:you|him|her|them|it|that)\b", t):
|
||||
return None # "follow you": not "follow me"
|
||||
if kind == "wave" and (holding() if callable(holding) else holding):
|
||||
return None # a wave with a cup in the hand: the LLM says why not
|
||||
if kind in ("come", "follow", "come_back", "wave"):
|
||||
return (kind, "")
|
||||
if kind == "move":
|
||||
if re.search(r"\bturn|\brotat|\bspin|\bpivot|\bswivel|\bface\b|돌|회전|도세요|도십시오|(?:^|\s)돌?아(?:\s|$)", t) or \
|
||||
not re.search(MOVE_VERB, t):
|
||||
return None # "turn left a bit", "왼쪽으로 도세요": a turn, not a drive
|
||||
if re.search(r"\b(?:some|more than|less than|few|several|couple)\b|\b(?:to|too) (?:meters?|metres?|m)\b", t):
|
||||
return None # "move back some", "forward to meters": how far? asked
|
||||
d = _dirs(t)
|
||||
n = driving.amount(t)[0]
|
||||
if re.search(r"\b(?:quarter|third|fourth)\b", t) or n is None and re.search(r"\b(?:half|meters?|metres?|cm|centimet\w*|inch\w*|feet|foot|yards?)\b|미터|"
|
||||
r"센티|\d", t):
|
||||
return None # an amount the words say but driving.amount does not read
|
||||
n = driving.DEFAULT_M if n is None else n
|
||||
if len(d) != 1 or n == "?" or not driving.MOVE_MIN_M <= n <= brain.MOVE_MAX_M:
|
||||
return None
|
||||
return ("move", f"{d[0]} {n:g}")
|
||||
if kind == "turn":
|
||||
if re.search(r"\blook|봐|\bhead\b|고개|\beyes\b", t):
|
||||
return None # "look the other way": the head, not the base
|
||||
if re.search(r"\bspin\b|\ball the way (?:a)?round\b|\b360\b|한 ?바퀴", t) and \
|
||||
not re.search(r"\bface\b|\bother (?:side|way)\b|\d+\s*(?:degrees?|도)", t.replace("360", "")):
|
||||
return ("turn", ("right" if re.search(r"\bright\b|오른쪽", t) else "left") + " 360")
|
||||
if re.search(r"\baround\b|\bu-?turn\b|유턴|뒤로 돌|뒤돌|\bother way\b|\babout face\b|한 바퀴", t):
|
||||
return None if re.search(r"\bleft|\bright\b|왼|오른", t) else ("turn", "around 180")
|
||||
d = [x for x in _dirs(t) if x in ("left", "right")]
|
||||
if len(d) != 1:
|
||||
return None
|
||||
deg = re.search(r"(\d+)\s*(?:degrees?|도)", t)
|
||||
if not deg and re.search(r"\bdegrees?\b|[가-힣]\s*도(?:만)?\s", t + " ") and not re.search(r"(?:^|\s)(?:한|좀)\s", t):
|
||||
return None # "삼십 도": a number the words don't give as digits
|
||||
return ("turn", f"{d[0]} {deg.group(1) if deg else 90}")
|
||||
if kind == "look":
|
||||
if re.search(r"\byour back\b|\bback to me\b|등 ?돌", t):
|
||||
return None # "turn your back to me": the base turns away
|
||||
target = "center" if re.search(r"원위치|원래대로|\breset\b", t) else brain.head_target(t)
|
||||
if target is None:
|
||||
dirs = [d for d, rx in LOOK_DIR.items() if re.search(rx, t)]
|
||||
if re.search(r"\baway\b|\bavert|딴 ?데|다른 ?데|시선", t):
|
||||
target = "away"
|
||||
elif re.search(r"\b(?:front|forward|center|centre|middle|reset|straighten)\b|원위치|원래대로|가운데|정면|앞에", t):
|
||||
target = "center"
|
||||
elif len(dirs) == 1:
|
||||
target = dirs[0] + (" small" if brain.SMALL.search(t) else "")
|
||||
elif not dirs and re.search(LOOK_ME, t):
|
||||
target = "me"
|
||||
return ("look", target) if target else None
|
||||
if kind == "lift":
|
||||
if not re.search(LIFT_BODY, t):
|
||||
return None # "go upstairs": no word about Lumi's own height
|
||||
down = re.search(r"\b(?:down|lower|shorter|smaller|sink)\b|낮|줄여|작게|작아|내려|아래|다운", t)
|
||||
up = re.search(r"\b(?:up|higher|taller|raise|rise|grow|elevate|stretch)\b|높(?:여|게|아|혀)|키워|올려|커|올라|업", t)
|
||||
if bool(down) == bool(up):
|
||||
return None # no direction, or both: asked
|
||||
target = brain.lift_target(t).split(" ", 1)
|
||||
return ("lift", " ".join(["down" if down else "up"] + target[1:]))
|
||||
if kind.startswith("arm_"):
|
||||
pose = kind[4:]
|
||||
if pose in ("open", "close"):
|
||||
held = holding() if callable(holding) else holding
|
||||
if held:
|
||||
return None # an open hand drops what it holds: brain.hand_request's
|
||||
return ("arm", pose)
|
||||
if kind in ("pick", "fetch"):
|
||||
got = brain._mentions(text, markers)
|
||||
if not got.get("object") or re.search(r"\b(?:put|place|set|drop|leave|this|from|go get|hold (?:this|my|it|on)|my)\b|놔|놓|내려|에서", t) or \
|
||||
(holding() if callable(holding) else holding):
|
||||
return None # "put the banana on the table", "hold this apple": the hand's
|
||||
if re.search(r"\b(?:give|hand|pass)\b|건네", t) or \
|
||||
re.search(r"줘|주세요|주실|줄래", t) and not re.search(r"집|잡|들어|쥐|픽|pick|grab|take", t):
|
||||
return None # "컵 좀 줘": bring it to me, a mission (pick, then give)
|
||||
if kind == "fetch":
|
||||
return ("fetch", text) if re.search(CARRY, t) else None # "get the cup for me": pick or fetch? the LLM
|
||||
if re.search(CARRY, t):
|
||||
return None
|
||||
return ("pick", f"{got['colour']} {got['object']}" if got.get("colour") else got["object"])
|
||||
if kind == "put":
|
||||
if not (holding() if callable(holding) else holding):
|
||||
return None # nothing held: lumi says the hand is empty (rules / LLM)
|
||||
if brain.place_on(t) or re.search(r"\b(?:on|onto|in|into) (?:the|a|my)\b|위에|에다", t):
|
||||
return None # "put it on the table": a place, the hand reader's
|
||||
return ("put", "back" if re.search(r"\bback\b|제자리|원래|다시|도로", t) else "down")
|
||||
return None
|
||||
|
||||
|
||||
def read(text, markers=(), holding=False):
|
||||
"""(action, target) as brain.intent gives it, when the bank is sure; else None (the LLM reads it)."""
|
||||
text = plain(text)
|
||||
if guarded(text):
|
||||
return None
|
||||
kind = kind_of(text, markers)
|
||||
return _slot(kind, text, markers, holding) if kind else None
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
if sys.argv[1:] == ["build"]:
|
||||
CACHE.unlink(missing_ok=True)
|
||||
n = len(_load()[1])
|
||||
print(f"{n} wordings -> {CACHE}")
|
||||
else:
|
||||
from tests.conversation_check import markers as _markers
|
||||
for said in sys.argv[1:]:
|
||||
print(said, "| guard:", guarded(said), "| kind:", kind_of(said), "| read:", read(said, _markers()))
|
||||
for s, k, w in nearest(said)[0]:
|
||||
print(f" {s:.3f} {k:10} {w}")
|
||||
+110
-14
@@ -10,7 +10,7 @@ Behaviour
|
||||
- Every person the camera sees gets a track (an ID followed from frame to frame).
|
||||
- A new person who stays in the greeting zone is greeted once: Lumi turns its head to them and says hello
|
||||
(a greeting never moves the arm). A second person who arrives is greeted the same way, then the talk goes on.
|
||||
- While a greeted person stays but says nothing, after PROMPT_S of silence it asks "How can I help you?" (at most MAX_PROMPTS times).
|
||||
- While a greeted person stays but says nothing, Lumi says nothing more (MAX_PROMPTS 0): it never speaks by itself.
|
||||
- When the person disappears from the camera (LOST_S), listening and speaking stop at once.
|
||||
Someone who comes back later is a new visit and is greeted again.
|
||||
- Voice commands (English / Korean): go to <marker>, go home, look left/right/up/down/center, wave, stop. The arm
|
||||
@@ -73,6 +73,7 @@ from robot import agv
|
||||
from robot import arm
|
||||
from assistant import brain as brain_mod
|
||||
from assistant import driving
|
||||
from assistant import detour
|
||||
from assistant import abilities
|
||||
from assistant import battery
|
||||
from assistant import voice_words
|
||||
@@ -105,7 +106,8 @@ FACE_WAIT_S = 1.0 # s after HOLD_S Lumi waits for those faces a
|
||||
# 2026-10-21: 6 of 8 returns had 3 good faces within 1.7 s, the other two after 5 s
|
||||
LOST_S = 2.0 # s not seen -> the person is gone (detections can miss a few frames)
|
||||
PROMPT_S = 12.0 # s of silence before "How can I help you?"
|
||||
MAX_PROMPTS = 2
|
||||
MAX_PROMPTS = 0 # Lumi never speaks into a silence by itself: the greeting asked already (owner,
|
||||
# 2026-10-22: "How can I help you?" twice to someone standing silent)
|
||||
TOO_CLOSE = 0.45 # m, a running wave is stopped
|
||||
MATCH_DEG = 12.0 # a detection belongs to the track with the closest angle within this ...
|
||||
MATCH_DEG_PER_M = 10.0 # ... where each m of distance difference counts as this many deg: two people at
|
||||
@@ -222,10 +224,12 @@ FOREIGN_SCRIPT = re.compile(r"[\u0400-\u04ff\u4e00-\u9fff\u3040-\u30ff]") # Cy
|
||||
UNSURE_LOOKUP = False # look up what the model says it is not sure of: on for gemma4:e4b, which said "not sure"
|
||||
# instead of choosing search; gemma4:26b chooses search itself, and its "not sure" answers
|
||||
# (2026-10-19 checks: 11 of 11) were about Lumi, Cutshion or the venue, never a lookup
|
||||
NOT_KNOWN = {"en": ["I'm sorry, I don't have that information. A staff member can help you.",
|
||||
NOT_KNOWN = {"en": ["I don't have exact information about that. A staff member can tell you.",
|
||||
"I'm sorry, I don't have that information. A staff member can help you.",
|
||||
"That one I don't know, sorry. A staff member here can tell you.",
|
||||
"I'm not sure about that. Please ask a staff member."],
|
||||
"ko": ["죄송해요, 그 정보는 없어요. 직원분께 여쭤봐 주세요.",
|
||||
"ko": ["그건 정확한 정보가 없어요. 직원분께 여쭤봐 주세요.",
|
||||
"죄송해요, 그 정보는 없어요. 직원분께 여쭤봐 주세요.",
|
||||
"그건 저도 잘 몰라요. 직원분께 물어봐 주시겠어요?",
|
||||
"아쉽지만 그건 제가 알 수 없어요. 직원분이 알려 드릴 거예요."]} # said when a lookup is refused
|
||||
|
||||
@@ -353,7 +357,8 @@ def safe(fn, *args, default=None):
|
||||
return default
|
||||
|
||||
|
||||
NOISE_WORDS = re.compile(r"\W*(?:u+m+|h?m+|uh+|ah+|oh+|boom|beep|ding|bang|pop|knock|음+|어+|아+)\W*", re.I) # whisper for room sounds
|
||||
NOISE_WORDS = re.compile(r"\W*(?:u+m+|h?m+|uh+|ah+|oh+|ahem|a?choo|cough|boom|beep|ding|bang|pop|knock|음+|어+|아+|크?흠+|큼+|"
|
||||
r"콜록\S*|에?[취츄]|엣취)\W*", re.I) # whisper for room sounds
|
||||
_doa_fit = threading.Lock() # one sound-direction refit at a time
|
||||
|
||||
class Track:
|
||||
@@ -850,6 +855,9 @@ class Lumi:
|
||||
elif action == "come_back":
|
||||
if self.modes.drive:
|
||||
self.come_back()
|
||||
elif action == "detour": # the model read it from now_doing's block
|
||||
if target in detour.SAY:
|
||||
self.detour(target, speak=False)
|
||||
elif action == "arm":
|
||||
self.arm_pose(target)
|
||||
elif action in ("pick", "put", "move_object"):
|
||||
@@ -939,7 +947,7 @@ class Lumi:
|
||||
now. True if handled here."""
|
||||
from tasks import fetch
|
||||
hist = self.brain.history
|
||||
t = brain_mod._norm(text)
|
||||
t = brain_mod._norm(text, self.markers) # "come back booth 9" is a place, not 9 of something back
|
||||
got = driving.read(t, driving.last_command(hist), driving.talking(hist))
|
||||
if not got or got[0] not in ("speed", "look") and (self.mission_running() or got == driving.read(t, None, True)
|
||||
and got[0] == "move"):
|
||||
@@ -1383,6 +1391,12 @@ class Lumi:
|
||||
name = "my charging dock" if to == "home" or self.patrol.mode == "going_home" else \
|
||||
to if isinstance(to, str) else "the point I was sent to"
|
||||
en, ko = f"I'm driving to {name}.", "충전소로 가는 중이에요." if "dock" in name else f"{name} 위치로 가는 중이에요."
|
||||
elif detour.recent(): # the LLM reads "find a way" / "you can go now" from this
|
||||
goal = detour.recent()["goal"]
|
||||
name = brain_mod.place_said(goal) if isinstance(goal, str) else "the point I was sent to"
|
||||
en, ko = (f"My last drive, to {name}, was blocked: something was in the way and I stopped. I can try again, "
|
||||
f"try another way, or go back.",
|
||||
f"{name}(으)로 가다가 길이 막혀서 멈췄어요. 다시 가거나, 다른 길로 가거나, 돌아갈 수 있어요.")
|
||||
elif held:
|
||||
en, ko = f"I'm holding {held} and waiting for what to do with it.", "물건을 들고 다음 지시를 기다리고 있어요."
|
||||
else:
|
||||
@@ -1808,6 +1822,7 @@ class Lumi:
|
||||
if remember:
|
||||
from tasks import fetch
|
||||
fetch._task["trip_from"] = safe(agv.pose) or fetch._task["trip_from"]
|
||||
detour.forget() # a new trip: "try again" no longer means a blocked one
|
||||
if self.patrol:
|
||||
self.patrol.pause()
|
||||
self.patrol = Patrol(list(target) if isinstance(target, list) else [target], once=True, pause_s=pause_s)
|
||||
@@ -1909,6 +1924,10 @@ class Lumi:
|
||||
if not ears.understood(BARGE_IN_LOGPROB): # unclear while Lumi talks = mostly Lumi's own voice
|
||||
log(f" ignored while talking (unclear): {text!r}")
|
||||
return False
|
||||
if seeing.recheck(text): # "Really?", "진짜?", "Now?" right after a seeing answer
|
||||
log(f" interrupted by a check of what I see: {text!r}")
|
||||
self.pending_text = text
|
||||
return True
|
||||
if brain_mod.is_backchannel(text) and "?" not in text and not THANKS.search(text) and \
|
||||
(brain_mod.UNDERSTOOD.search(text) or not brain_mod.is_closing(text)):
|
||||
log(f" back-channel while talking: {text!r} - go on") # "uh huh", "I see", "그렇구나": listening
|
||||
@@ -1985,8 +2004,10 @@ class Lumi:
|
||||
log(f" ignored a sound: {text!r}")
|
||||
text = None
|
||||
if not text and self.closing_pending and time.time() - self.closing_pending > CLOSING_WAIT_S:
|
||||
log(" silence after a closing word - conversation over")
|
||||
self.end_conversation("okay")
|
||||
from tasks import follow # following: "okay" was to the follow, no goodbye
|
||||
here = (self.current is not None or self.vision is None or self.vision.anyone_near()) and not follow.running()
|
||||
log(f" silence after a closing word - conversation over{'' if here else ', nobody here or following: no goodbye'}")
|
||||
self.end_conversation("okay", quiet=not here)
|
||||
return False
|
||||
if not text or self.interrupted():
|
||||
if not self.interrupted():
|
||||
@@ -2020,8 +2041,55 @@ class Lumi:
|
||||
if why:
|
||||
mouth.say(why[0] if self.lang == "en" else why[1])
|
||||
return
|
||||
name = "my charging dock" if target == "home" else target
|
||||
mouth.say(f"Sorry, I can't find a way to {name}. Something may be blocking the path.")
|
||||
if self.patrol.once: # kept for "try again", "go around it", "go back" (detour)
|
||||
from tasks import fetch
|
||||
to = target if isinstance(target, str) else list(target)
|
||||
detour.remember(to, [{"do": "go", "to": to}], fetch._task["trip_from"] and list(fetch._task["trip_from"]))
|
||||
if self.lang == "en":
|
||||
name = "my charging dock" if target == "home" else brain_mod.place_said(target) \
|
||||
if isinstance(target, str) else "there"
|
||||
mouth.say(f"Sorry, I can't find a way to {name}. Something may be blocking the path.")
|
||||
else:
|
||||
name = "충전소로" if target == "home" else f"{brain_mod.place_said(target)}(으)로" \
|
||||
if isinstance(target, str) else "그곳으로"
|
||||
mouth.say(f"죄송해요, {name} 가는 길을 못 찾겠어요. 뭔가 길을 막고 있는 것 같아요.")
|
||||
|
||||
def detour(self, how, speak=True):
|
||||
""""try again" / "back up and try again" / "go around it" / "go back" after a blocked drive (assistant/detour.py):
|
||||
said in one line, then driven by the task runner (tasks/fetch.detour: the arm in look, STOP and pause work as
|
||||
on a mission). speak False: the LLM has said its own words. True when handled."""
|
||||
from tasks import fetch
|
||||
stuck = detour.recent()
|
||||
if stuck is None:
|
||||
return False
|
||||
if self.base_off("go_to"):
|
||||
return True
|
||||
en = self.lang == "en"
|
||||
if not self.modes.drive:
|
||||
mouth.say("Sorry, driving is switched off." if en else "죄송해요, 지금은 이동할 수 없어요.")
|
||||
return True
|
||||
if how == "back":
|
||||
if not stuck.get("start"):
|
||||
self.fetch_say(*detour.NO_START)
|
||||
self.keep_listening()
|
||||
return True
|
||||
steps, tries = [{"do": "go", "to": stuck["start"]}], 0
|
||||
else:
|
||||
steps, tries = stuck["rest"], stuck.get("tries", 0) + 1
|
||||
if self.patrol:
|
||||
self.patrol.pause()
|
||||
self.patrol.mode = "done"
|
||||
self.stay()
|
||||
log(f" detour {how}: {steps}")
|
||||
try:
|
||||
fetch.detour(steps, how, say=self.fetch_say, tries=tries)
|
||||
except fetch.FetchError as e:
|
||||
self.fetch_say(e.args[0], e.args[1] if len(e.args) > 1 else "죄송해요, 지금은 할 수 없어요.")
|
||||
return True
|
||||
if speak:
|
||||
self.brain.history.append((self.heard, f"ACTION: detour {how}"))
|
||||
self.fetch_say(*detour.SAY[how])
|
||||
return True
|
||||
|
||||
def followed_speaks(self, u):
|
||||
"""While following: does the voice come from the person followed (the sound direction against their angle
|
||||
@@ -2295,6 +2363,14 @@ class Lumi:
|
||||
return True
|
||||
|
||||
def answer(self, text, part=False):
|
||||
"""_answer, and what was said by code in that turn (a refusal, a fixed reply, a place not on the map) kept in
|
||||
the talk like the model's answers: "why?" / "really?" / "왜요?" next goes on from it."""
|
||||
h, n, t0 = self.brain.history, len(self.brain.history), time.time()
|
||||
self._answer(text, part)
|
||||
if h is self.brain.history and len(h) == n: # nothing kept by the turn, and the talk did not end
|
||||
keep_said(self.brain, text, mouth.recent_speech(time.time() - t0))
|
||||
|
||||
def _answer(self, text, part=False):
|
||||
"""Stream the LLM reply: act on the action line, speak sentence by sentence.
|
||||
Clear commands (go home, go to p1, come here, be quiet...) are done at once without the LLM.
|
||||
part: one part of a sentence of several (chain_run); otherwise a chain still running ends here."""
|
||||
@@ -2352,6 +2428,8 @@ class Lumi:
|
||||
if kind == "stop":
|
||||
self.stop_all() # "stop", "stop, where are you going?": stop first, always
|
||||
return
|
||||
if kind == "detour" and self.detour(data): # after a blocked drive: "try again", "다른 길로 가 봐"
|
||||
return
|
||||
if kind == "chain" and self.chain_request(text, data): # "look at me and wave", "go to p5 and tell me the weather"
|
||||
return
|
||||
if kind == "seeing": # "do you see a cup?", "what am I holding?"
|
||||
@@ -2898,14 +2976,20 @@ NOT_A_STEP = re.compile(r"^\W*(?:(?:please|and|then|also)\s+)*(?:dance|jump|fly|
|
||||
|
||||
def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
|
||||
"""Which way a command goes, the same for voice (Lumi.answer), the dashboard's Command box (/tasks/parse) and
|
||||
tests/command_check: (kind, data). Kinds in this order: "stop"; "chain" (data: chain.plan); "seeing" (data: what
|
||||
tests/command_check: (kind, data). Kinds in this order: "stop"; "detour" (data: assistant/detour.read's
|
||||
"retry" / "backup" / "around" / "back", only right after a blocked drive); "chain" (data: chain.plan); "seeing" (data: what
|
||||
seen(text) answered); "status"; "correction" (brain.correction); "hand" ((kind, what), brain.hand_request with
|
||||
the hand as it is: holding is a bool or a function asked only here); "mission" (read_mission's (steps, unread,
|
||||
by)); "end" (a goodbye); "sing"; "quick" (brain.intent's rule, one of QUICK_RULES); (None, None): the LLM reads
|
||||
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
|
||||
if stop_order(text, markers):
|
||||
return "stop", None
|
||||
stuck = detour.recent() # right after a blocked drive: "try again", "go around it", "go back"
|
||||
how = stuck and detour.read(text, markers, stuck["goal"])
|
||||
if how:
|
||||
return "detour", how
|
||||
plan = chain_ok and chain.plan(text, markers, NOT_A_STEP)
|
||||
if plan:
|
||||
return "chain", plan
|
||||
@@ -2932,6 +3016,11 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
|
||||
rule = brain_mod.intent(text, markers)
|
||||
if rule and rule[0] in QUICK_RULES:
|
||||
return "quick", rule
|
||||
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:
|
||||
return "quick", rule
|
||||
return None, None
|
||||
|
||||
|
||||
@@ -2975,6 +3064,13 @@ SAID_BYE = re.compile(r"\b(?:bye|goodbye|see you|take care|have a (?:good|nice|g
|
||||
re.I) # Lumi's own words take leave
|
||||
|
||||
|
||||
def keep_said(brain, text, said):
|
||||
"""A line Lumi said by code for `text` goes into the talk (the model sees it as its own answer), unless the turn
|
||||
is in it already."""
|
||||
if said and text and not (brain.history and brain.history[-1][0] == text):
|
||||
brain.history.append((text, f"ACTION: none -\n{said}"))
|
||||
|
||||
|
||||
def kept_goodbye(said):
|
||||
"""The model ended the talk on a closing word ("okay", "thanks"): only when its words said goodbye; "You're
|
||||
welcome." alone keeps the talk open (silence then ends it)."""
|
||||
@@ -3027,8 +3123,8 @@ def consent_place(text, brain, markers):
|
||||
offer = (re.split(r"(?<=[.!])\s+", answer.strip()) or [""])[-1] # Lumi's own "shall I go to p3?"
|
||||
last = asked if any(brain_mod.named_place(asked, m, markers) for m in markers) else (offer if "?" in offer else "")
|
||||
named = {m for m in markers if brain_mod.named_place(last, m, markers)}
|
||||
if named == {"home", "dock2"}:
|
||||
return None
|
||||
if "home" in named and len(named) > 1 and all(re.search(r"dock|charg|도크|충전", m, re.I) for m in named - {"home"}):
|
||||
return None # "dock 2": the dock and dock2 both heard, not guessed
|
||||
return named.pop() if len(named) == 1 else None
|
||||
|
||||
|
||||
|
||||
+218
-62
@@ -21,7 +21,7 @@ import time
|
||||
from assistant import brain
|
||||
from vision import objects, pose, scene
|
||||
|
||||
NEAR_SAY = 4 # at most this many kinds of things named in "what do you see"
|
||||
NEAR_SAY = 6 # at most this many kinds of things named in "what do you see"
|
||||
DESCRIBE_SCORE = 0.3 # weaker boxes (depth-checked cups) count for "do you see a cup", not in the list
|
||||
THREAD_S = 60.0 # s; this long after a seeing answer the conversation model gets a new look too
|
||||
CLAIM_WORDS = 14 # words; a correction is short: "no, it's my right hand", "아니야 흰색이야"
|
||||
@@ -29,13 +29,13 @@ BIG = {"dining table", "chair", "couch", "bed", "refrigerator", "sink", "oven",
|
||||
|
||||
COLOURS = {"white": "white", "red": "red", "blue": "blue", "green": "green", "yellow": "yellow", "black": "black",
|
||||
"orange": "orange", "grey": "grey", "gray": "grey", "purple": "purple", "pink": "pink",
|
||||
"brown": "brown",
|
||||
"brown": "brown", "light blue": "light blue", "sky blue": "light blue", "pale blue": "light blue",
|
||||
"흰": "white", "하얀": "white", "빨간": "red", "파란": "blue", "초록": "green", "노란": "yellow", "검은": "black",
|
||||
"까만": "black", "주황": "orange", "회색": "grey", "보라": "purple", "분홍": "pink", "핑크": "pink",
|
||||
"하양": "white", "빨강": "red", "파랑": "blue", "노랑": "yellow", "검정": "black", "까망": "black", "갈색": "brown",
|
||||
"하양": "white", "빨강": "red", "파랑": "blue", "노랑": "yellow", "검정": "black", "까망": "black", "갈색": "brown", "하늘": "light blue",
|
||||
"브라운": "brown"} # "brown" is only said by people: the camera names browns orange
|
||||
COLOUR_KO = {"white": "흰색", "red": "빨간색", "blue": "파란색", "green": "초록색", "yellow": "노란색", "black": "검은색",
|
||||
"orange": "주황색", "grey": "회색", "purple": "보라색", "pink": "분홍색", "brown": "갈색"}
|
||||
"orange": "주황색", "grey": "회색", "purple": "보라색", "pink": "분홍색", "brown": "갈색", "light blue": "하늘색"}
|
||||
SYNONYMS = {"mug": "cup", "glass": "cup", "tumbler": "cup", "coffee": "cup", "phone": "cell phone", "mobile": "cell phone",
|
||||
"smartphone": "cell phone", "plant": "potted plant", "flower": "potted plant", "table": "dining table",
|
||||
"desk": "dining table", "monitor": "tv", "screen": "tv", "television": "tv", "computer": "laptop",
|
||||
@@ -46,7 +46,7 @@ KO = {"person": "사람", "bicycle": "자전거", "car": "자동차", "motorcycl
|
||||
"train": "기차", "truck": "트럭", "boat": "보트", "traffic light": "신호등", "fire hydrant": "소화전",
|
||||
"stop sign": "정지 표지판", "parking meter": "주차 미터기", "bench": "벤치", "bird": "새", "cat": "고양이", "dog": "개",
|
||||
"horse": "말", "sheep": "양", "cow": "소", "elephant": "코끼리", "bear": "곰", "zebra": "얼룩말", "giraffe": "기린",
|
||||
"backpack": "배낭", "umbrella": "우산", "handbag": "가방", "tie": "넥타이", "suitcase": "여행 가방",
|
||||
"backpack": "백팩", "umbrella": "우산", "handbag": "가방", "tie": "넥타이", "suitcase": "여행 가방",
|
||||
"frisbee": "원반", "skis": "스키", "snowboard": "스노보드", "sports ball": "공", "kite": "연", "baseball bat": "야구 방망이",
|
||||
"baseball glove": "야구 글러브", "skateboard": "스케이트보드", "surfboard": "서핑보드", "tennis racket": "테니스 라켓",
|
||||
"bottle": "병", "wine glass": "와인잔", "cup": "컵", "fork": "포크", "knife": "칼", "spoon": "숟가락", "bowl": "그릇",
|
||||
@@ -59,57 +59,107 @@ KO = {"person": "사람", "bicycle": "자전거", "car": "자동차", "motorcycl
|
||||
"toothbrush": "칫솔"}
|
||||
KO_WORDS = {**{v: k for k, v in KO.items()}, "폰": "cell phone", "핸드폰": "cell phone", "전화": "cell phone",
|
||||
"잔": "cup", "머그": "cup", "식물": "potted plant", "꽃": "potted plant", "책상": "dining table",
|
||||
"식탁": "dining table", "컴퓨터": "laptop", "티비": "tv", "가방": "handbag"}
|
||||
"식탁": "dining table", "배낭": "backpack", "컴퓨터": "laptop", "티비": "tv", "가방": "handbag", "물병": "bottle",
|
||||
"탁자": "dining table"}
|
||||
|
||||
class _Any:
|
||||
"""Several patterns asked as one: .search gives the first match (each has its own col / obj groups)."""
|
||||
def __init__(self, *rxs):
|
||||
self.rxs = rxs
|
||||
|
||||
def search(self, t):
|
||||
return next((m for rx in self.rxs if (m := rx.search(t))), None)
|
||||
|
||||
|
||||
_EN_NAMES = sorted(set(objects.COCO) | set(SYNONYMS), key=len, reverse=True)
|
||||
_THING_EN = r"(?:(?P<col>" + "|".join(c for c in COLOURS if c.isascii()) + r")\s+)?(?P<obj>" + \
|
||||
"|".join(re.escape(n) for n in _EN_NAMES) + r")(?:e?s)?\b"
|
||||
_THING_KO = r"(?:(?P<col>" + "|".join(c for c in COLOURS if not c.isascii()) + r")\w*\s*)?(?P<obj>" + \
|
||||
"|".join(sorted(KO_WORDS, key=len, reverse=True)) + r")"
|
||||
_THING_EN = r"(?:(?P<col>" + "|".join(c for c in COLOURS if c.isascii()) + r")\s+)?(?<![a-z])(?P<obj>" + \
|
||||
"|".join(re.escape(n) for n in _EN_NAMES) + r")(?:e?s)?(?![a-z])"
|
||||
_THING_KO = r"(?:(?P<col>" + "|".join(c for c in COLOURS if not c.isascii()) + r")\w*\s*)?(?<![가-힣])(?<!몇 )(?P<obj>" + \
|
||||
"|".join(sorted(KO_WORDS, key=len, reverse=True)) + r")(?=[\s?.,!~]|$|[은는이가을를도의에랑와과요야]|까지|하고)"
|
||||
# a whole word: not 연 (kite) in 연구소, 개 (dog) in "몇 개"
|
||||
|
||||
SEE_ME = re.compile(r"\b(do|can) you see me\b|\bam i (visible|in (your )?view)\b|(나|저)(를|)? ?보여|(나|저) ?보이", re.I)
|
||||
SEE_THING = re.compile(r"(?<!what )\b(?:do|can|could) you (?:still )?(?:see|spot|notice)\b.*?\b(?:a|an|the|any|some|my)?\s*" + _THING_EN, re.I)
|
||||
THERE_IS = re.compile(r"\b(?:is|are) there (?:still )?(?:a|an|any|some)\s+" + _THING_EN +
|
||||
r"(?! (?:open|close|nearby|near here|around here))", re.I)
|
||||
STILL_THERE = re.compile(r"\bis (?:the|my|that|your|this) " + _THING_EN + r" still (?:there|here|on|in)\b", re.I)
|
||||
SEE_THING_KO = re.compile(_THING_KO + r"(?:이|가|은|는|을|를|도)?\s*(?:(?:(?:아직도?|지금도?|still)\s*)?(?:보여|보이)|아직도?\s*있)")
|
||||
# "사과 아직 보여요?", "컵이 아직 있습니까?"
|
||||
HOW_FAR = re.compile(r"\bhow far\b|\bhow (?:near|close)\b|\bwhat(?:'s| is) the distance\b|얼마나 ?(?:멀|떨어|가까)|거리가?|(?:거기|그거|저거|걔)까지\s*얼마나",
|
||||
SEE_THING_KO = re.compile(_THING_KO + r"(?:이|가|은|는|을|를|도)?\s*(?:(?:(?:아직도?|지금도?|still)\s*)?(?:보여|보이)|아직도?\s*있|"
|
||||
r"(?:(?:저기|여기|거기|앞에)\s*)?있(?:어|나|니|습|잖|는데)|"
|
||||
r"(?:\s*(?:치웠|갖다\s*놨|올려\s*놨|놨|뒀)\S*\W+(?:\S+\s+)?(?:아직\s*|이제\s*)?(?:보여|보이|있)))")
|
||||
# "사과 아직 보여요?", "컵이 아직 있습니까?", "바나나가 있어요?", "컵 치웠어요. 아직 보여요?"
|
||||
SEE_MORE = _Any(re.compile(r"(?:^\W*(?:\w+\W+)?any|\bthere(?:'s| is))\s+(?:(?:a|an|some)\s+)?" + _THING_EN + r"(?:\s+(?:around|here|in front|right there))", re.I),
|
||||
re.compile(r"\bi (?:can )?see (?:a|an|the)\s+" + _THING_EN, re.I),
|
||||
re.compile(r"\bis (?:a|an|the) " + _THING_EN + r" (?:somewhere )?(?:near|around|here)", re.I),
|
||||
re.compile(r"\b(?:can|could) you find\s+(?:a|an|the|any|my)\s+" + _THING_EN + r"\s+(?:here|around)", re.I),
|
||||
re.compile(r"\b(?:looking for|brought|put|took|moved|got|have)\s+(?:a|an|the|my|this|that)\s+" + _THING_EN +
|
||||
r"\b.*\b(?:see (?:it|one|them)|still there|is it there)\b", re.I),
|
||||
re.compile(r"(?<![a-z])" + _THING_EN + r"\s*(?:이|가|는|도)?\s*(?:(?:아직|still)\s*)?(?:보여|보이|있어|있나|있니|있잖|있는데|"
|
||||
r"see\s*(?:돼|되|가능))", re.I))
|
||||
# "any apple around here?", "I brought a cup. see it?", "bottle 보여?", "여기 banana 있나?"
|
||||
WHERE_THING = _Any(re.compile(r"\bwhere(?:'s| is| are| did you see| exactly is)\s+(?:exactly\s+)?(?:the|my|a|an)\s+" + _THING_EN, re.I),
|
||||
re.compile(r"\bwhich side(?: is)? (?:the|my) " + _THING_EN, re.I),
|
||||
re.compile(r"\bis (?:the|my) " + _THING_EN + r" (?:on|to) (?:your|the|my) (?:left|right)\b", re.I),
|
||||
re.compile(r"(?<![a-z])" + _THING_EN + r"\s*(?:은|는|이|가)?\s*(?:left|right|왼쪽|오른쪽)(?:야|이야|에)", re.I),
|
||||
re.compile(_THING_KO + r"\s*(?:는|은|이|가)?\s*(?:어디|위치|어느\s*(?:쪽|side)|왼쪽이야|오른쪽이야)"),
|
||||
re.compile(r"(?<![a-z])" + _THING_EN + r"\s*(?:은|는)?\s*(?:어디|위치|어느\s*(?:쪽|side))", re.I))
|
||||
# "where exactly is the banana?", "노트북은 왼쪽이야 오른쪽이야?", "laptop 어느 side에 있어?"
|
||||
HOW_FAR = re.compile(r"\bhow far\b|\bhow (?:near|close)\b|\bwhat(?:'s| is) the distance\b|\bhow many (?:meters|metres)\b|"
|
||||
r"\bam i close\b|\bdistance\s*(?:얼마|몇)|\bdistance (?:to|from)\b|몇\s*(?:미터|meter|m\b)|떨어져\s*있|"
|
||||
r"우리\s*사이|얼마나 ?(?:멀|떨어|가까)|거리가?|(?:거기|그거|저거|걔)까지\s*얼마나",
|
||||
re.I)
|
||||
HOW_FAR_THING = re.compile(r"\b(?:how far|how (?:near|close)).*?\b(?:the|that|this|a|an)\s+" + _THING_EN, re.I)
|
||||
HOW_FAR_THING = re.compile(r"\b(?:how far|how (?:near|close)|how many (?:meters|metres)|distance (?:to|from)).*?\b(?:the|that|this|a|an)\s+" + _THING_EN, re.I)
|
||||
FAR_THING = _Any(HOW_FAR_THING, re.compile(r"(?<![a-z])" + _THING_EN + r"\s*(?:까지|이랑|랑)?\s*(?:distance|거리)", re.I),
|
||||
re.compile(_THING_KO + r"\S*\s*(?:까지|이랑|랑|와|하고)?\s*(?:의\s*)?(?:거리|얼마나\s*(?:멀|떨어)|몇\s*(?:미터|meter))"))
|
||||
WHAT_SEE = re.compile(r"\bwhat (?:do|can) you see\b|\bwhat(?:'s| is| are)? (?:there )?in front of you\b|"
|
||||
r"\bwhat(?:'s| is) (?:(?:still|now) )?(?:on|at) the (?:table|desk|테이블)|\bwhat(?:'s| is) (?:around|near) you\b|"
|
||||
r"\bdescribe what you see\b|\bwhat are you (?:looking at|seeing)\b|\btell me what you see\b|"
|
||||
r"뭐가 ?보여|무엇이 ?보여|뭐 ?보여|뭐가 ?보이|앞에 ?(?:뭐|무엇)|(?:테이블|table) ?(?:위에|에|위) ?(?:뭐|무엇)|"
|
||||
r"\bwhat (?:things|stuff|objects)? ?(?:is |are )?(?:there |lying |sitting )?on the (?:table|desk)\b|"
|
||||
r"\bwhat(?:'s| is) (?:lying|sitting|there) on the (?:table|desk)\b|\banything on the (?:table|desk)\b|"
|
||||
r"\btell me what you (?:can )?see\b|\bwhat (?:things|objects|stuff) (?:are|is) (?:there )?in front of you\b|"
|
||||
r"뭐가 ?보여|무엇이 ?보여|뭐 ?보여|뭐가 ?보이|뭐 ?보이|앞에 ?(?:뭐|무엇)|"
|
||||
r"(?:테이블|탁자|책상|table) ?(?:위에|에|위)? ?(?:things\s*)?(?:뭐|무엇|있는 ?거)|"
|
||||
r"뭘 ?보고 ?있", re.I)
|
||||
BEHIND = re.compile(r"\bwhat(?:'s| is) behind you\b|^(?!.*\b(?:look|turn|check)\b).*\bbehind you\b.*\?|" # not "can you look
|
||||
r"뒤에 ?(?:뭐|무엇|누가|누구)", re.I) # behind you?" (a head turn)
|
||||
HOW_MANY = re.compile(r"\bhow many (?:people|persons|visitors|humans)\b|\bhow many of us\b|몇 ?(?:명|사람)|"
|
||||
HOW_MANY = re.compile(r"\bhow many (?:people|persons|visitors|humans|folks|guys)\b|\bhow many of us\b|몇 ?(?:명|사람)|"
|
||||
r"몇\s*분\s*(?:이\s*)?계|\bcount (?:the )?(?:people|persons|heads|us)\b|사람\s*(?:count|how many)|"
|
||||
r"\bare we (?:\w+ )?(?:or|two|three|four)\b.*\bhow many\b|"
|
||||
r"^\W*(?:(?:and|so|okay)\W+)?(?:(?:지금|이제|now)\s*(?:은|는)?\s*how many|how many(?: do you see| are there)? now)\W*$",
|
||||
re.I) # "How many now?"
|
||||
NOT_IN_VIEW = re.compile(r"\b(?:work|works|working|employ\w*|staff|company|companies|campy|firm|cutshion|country|city|"
|
||||
r"live|lives|living|world|team|office|branch|developers?|engineers?|built|made)\b|"
|
||||
r"직원|회사|쿳션|일하|일해|근무|나라|국가|도시|살아|사는|인구|팀|지사|만든|만들|개발자|엔지니어",
|
||||
r"live|lives|living|world|team|office|branch|developers?|engineers?|built|made|came|visited|talked|met)\b|"
|
||||
r"직원|회사|쿳션|일하|일해|근무|나라|국가|도시|살아|사는|인구|팀|지사|만든|만들|개발자|엔지니어|왔었|다녀갔|만났|얘기했|이야기했",
|
||||
re.I) # "how many people work at Cutshion?": the company, not the cameras
|
||||
HOLDING = re.compile(r"\bwhat(?:'s| is| am| do)? (?:i|is in my hands?|in my hands?)\b.*?\b(?:holding|carrying|have)\b|"
|
||||
r"\bwhat(?:'s| is)(?: it| this| that)? in my hands?\b|\bwhat(?:'s| is) my hands?\?|\bwhat (?:do )?i have in my hands?\b|\bam i holding\b|"
|
||||
r"\bis there (?:something|anything) in my hand\b|\bwhat is this\b(?=.*\bhand\b)|\bwhat am i hold in\b|\banything in my hands?\b|"
|
||||
r"(?:내가|제가|나|저)\s*(?:뭐|뭘|무엇을?)\s*(?:들고|잡고|쥐고|holding)|(?:내|제)\s*(?:손|hand)에\s*(?:뭐|뭔|무엇|든|있)|"
|
||||
r"\bwhat\b.{0,25}\b(?:i'?m|i am) (?:holding|carrying)\b|\bwhat(?:'ve| have| do) i (?:got|have)\b(?! to)|"
|
||||
r"\bwhat(?:'s| is) this(?: thing)?\W*$|\bwhat i(?:'ve| have) got\b|hold\s*했\S*\W+.*뭐|"
|
||||
r"(?<!루미 )(?<!네 )손에\s*(?:뭐|뭘|든|있는).{0,15}(?:보여|보이|알아|맞혀|\bwhat is it\b)|" # Lumi's hand: status
|
||||
r"(?:my\s*hand|(?:내|제)\s*손)\s*에?\s*(?:든|있는|뭐|뭔|무엇)|(?:내|제)\s*손\b.*(?:뭐|뭘)\s*들고\s*있|\bi(?:'ve| have) got something\b.*\bwhat\b|"
|
||||
r"(?:내가|제가)\s*(?:hold|들고|잡고|쥐고)\s*(?:하고\s*)?있는\s*(?:거|게|것)|손에\s*(?:something|뭔가|무언가)|"
|
||||
r"^\W*(?:\S+\W+){0,3}(?:이거|이건|이게)\s*(?:뭐|뭔|무엇|what)|"
|
||||
r"(?:내가|제가|나|저)\s*(?:지금\s*)?(?:뭐|뭘|무엇을?)\s*(?:들고|잡고|쥐고|holding)|(?:내|제)\s*(?:손|hand)에\s*(?:뭐|뭔|무엇|든|있)|"
|
||||
r"(?:내가|제가)\s*(?:든|들고\s*있는|쥐고\s*있는)\s*(?:거|게|것)", re.I) # "제가 들고 있는 거 뭐예요?"
|
||||
# "뭐 들고 있어?" without "내가" asks about Lumi's own hand (lumi.status_question)
|
||||
WHICH_HAND = re.compile(r"\b(?:which|what) hand(?![a-z])|\bleft or right\b|어느\s*(?:쪽\s*)?(?:손|hand)|손\s*어느\s*쪽|"
|
||||
WHICH_HAND = re.compile(r"\b(?:which|what) hand(?![a-z])|무슨\s*손|오른손\S*\s*(?:아니면\s*)?왼손\S*\s*\?|\bleft or (?:my |the )?right\b|\bwhich of my hands\b|어느\s*(?:쪽\s*)?(?:손|hand)|손\s*어느\s*쪽|"
|
||||
r"왼손\S*\s*(?:아니면\s*)?오른손\S*\s*\?|left\S*\s*right\S*\s*\?", re.I) # held first, else raised
|
||||
_UPPER = r"short|t-? ?shirts?|te[ea] ?shirts?|shirts?|tops?|jackets?|sweaters?|sweatshirts?|hoodies?|jumpers?|blouses?|coats?"
|
||||
_LOWER = r"pants|trousers?|jeans?|genes|skirts?|shorts|slacks|leggings|bottoms" # "genes", "jean": heard for jeans
|
||||
_FEET = r"shoes?|sneakers?|trainers|boots?|sandals?|slippers?|socks?|feet|foot"
|
||||
_UPPER_KO = r"티셔츠|셔츠|셔쯔|상의|윗옷|겉옷|재킷|자켓|후드티|맨투맨|니트|스웨터|코트"
|
||||
_UPPER_KO = r"티셔츠|셔츠|셔쯔|상의|윗옷|윗도리|겉옷|재킷|자켓|후드티|맨투맨|니트|스웨터|코트"
|
||||
_LOWER_KO = r"청 ?바지|청바진|반바지|바지|하의|치마|스커트"
|
||||
_FEET_KO = r"운동화|신발|구두"
|
||||
_ITEM = rf"(?:{_UPPER}|{_LOWER}|{_FEET}|clothes|clothing|outfit)"
|
||||
_ITEM_KO = rf"(?:{_UPPER_KO}|{_LOWER_KO}|{_FEET_KO}|옷)"
|
||||
PARTS = (("upper", rf"\b(?:{_UPPER})\b|{_UPPER_KO}"), ("lower", rf"\b(?:{_LOWER})\b|{_LOWER_KO}|아래(?:쪽)?|밑"),
|
||||
PARTS = (("upper", rf"\b(?:{_UPPER}|upper half)\b|{_UPPER_KO}"),
|
||||
("lower", rf"\b(?:{_LOWER}|bottom half|lower half)\b|{_LOWER_KO}|아래(?:쪽)?|밑"),
|
||||
("feet", rf"\b(?:{_FEET})\b|{_FEET_KO}|신었|신고 있|신은"))
|
||||
SHIRT = re.compile(rf"\bcolou?rs?\b.{{0,30}}?\b(?:my|the|his|her|their)\s+(?:\w+\s+)?{_ITEM}\b|{_ITEM}\W+what colou?r|\bmy\s+(?:\w+\s+)?{_ITEM}(?:'s)?\s+colou?r|"
|
||||
SHIRT = re.compile(rf"\bcolou?rs?\b.{{0,30}}?\b(?:my|the|his|her|their|this)\s+(?:[\w']+\s+)?{_ITEM}\b|"
|
||||
rf"\bcolou?r\s*(?:내|제)\s*(?:{_ITEM_KO})|"
|
||||
rf"\bcolou?r(?:'s| is)? (?:the |my )?(?:bottom|top|lower|upper) half\b|"
|
||||
rf"\b(?:{_UPPER}|{_LOWER})\b\s*(?:은|는|이|가)?\s*(?:(?:무슨|어떤|뭔)\s*)?(?:색|컬러|colou?r)|"
|
||||
rf"\bput on (?:a |an )?(?:\w+ )?{_ITEM}\b.{{0,25}}\bcolou?r|{_ITEM}\W+what colou?r|\bmy\s+(?:\w+\s+)?{_ITEM}(?:'s)?\s+colou?r|"
|
||||
rf"\b(?:is|are) my\s+(?:\w+\s+)?{_ITEM}\s+(?:" + "|".join(c for c in COLOURS if c.isascii()) + r")\b|"
|
||||
r"\bwhat\b.{0,25}?\b(?:am i|i'?m|do i|did i)\s+(?:wear(?:ing)?|have on|got on)\b|"
|
||||
r"\bwhat(?:'s| is| are)? (?:she|he|they|my friend|the (?:other|second) (?:person|guy|man|woman)|"
|
||||
@@ -120,7 +170,7 @@ SHIRT = re.compile(rf"\bcolou?rs?\b.{{0,30}}?\b(?:my|the|his|her|their)\s+(?:\w+
|
||||
r"\bwhat(?:'s| is| are)? on my (?:feet|foot)\b|\bdescribe my (?:clothes|clothing|outfit)\b|"
|
||||
rf"{_ITEM_KO}\s*(?:은|는|이|가|의)?\s*(?:무슨|어떤|뭔|무엇|뭐)?\s*(?:색|컬러|colou?r)|무슨\s*색\s*{_ITEM_KO}|"
|
||||
r"(?:뭐|뭘|무엇을?|무슨|어떤)\s*(?:\w+\s*)?(?:입었|입고|입은|신었|신고|신은)|"
|
||||
r"(?:입었|벗었|바꿨|갈아입)\S*\W+.{0,12}(?:무슨\s*색|colou?r|컬러)|\b(?:" + _UPPER + "|" + _LOWER + r")\s*(?:색|컬러)", re.I) # 2026-10-21 live:
|
||||
r"(?:입었|벗었|바꿨|갈아입|change)\S*\W+.{0,12}(?:무슨\s*색|colou?r|컬러)|\b(?:" + _UPPER + "|" + _LOWER + r")\s*(?:색|컬러)", re.I) # 2026-10-21 live:
|
||||
# "What is the color of my t-shirt?", "What is it? Color my jeans." went to the LLM
|
||||
OTHER = re.compile(r"\b(?:friend|colleague|partner|she|he|his|her|their)\b|\bthe (?:other|second) (?:person|guy|man|woman|one)\b|"
|
||||
r"\b(?:person|man|woman|guy|lady) (?:next to|beside|behind|with) me\b|친구|동료|옆\s*(?:에\s*)?(?:있는\s*)?(?:사람|분)|"
|
||||
@@ -129,19 +179,30 @@ FRIEND = re.compile(r"\b(?:do|can) you (?:still )?see (?:my (?:friend|colleague)
|
||||
r"\bis (?:my (?:friend|colleague)|the other (?:person|guy|man|woman)) still (?:here|there|in view)\b|"
|
||||
r"(?:친구|동료|그\s*사람|다른\s*(?:사람|분)|옆\s*사람)\S*\s*(?:아직도?\s*|still\s*)?(?:보여|보이|있어|있나|있습)", re.I)
|
||||
DOING = re.compile(r"\bwhat am i doing\b|\bwhat(?:'m| am) i up to\b|(?:내가|제가|나|저)\s*(?:지금\s*)?(?:뭐|뭘|무엇을?)\s*하고\s*있", re.I)
|
||||
RAISED = re.compile(r"\b(?:is|are) my (?:hand|hands|arm|arms) (?:raised|up)\b|\bam i raising (?:my )?(?:hand|arm)\b|"
|
||||
RAISED = re.compile(r"\bwhich (?:hand|arm) (?:do i have|have i got) (?:up|raised)\b|\b(?:is|are) my (?:hand|hands|arm|arms) (?:raised|up)\b|\bam i raising (?:my )?(?:hand|arm)\b|"
|
||||
r"\bdid i raise my hand\b|\bwhich hand (?:did i raise|is (?:up|raised)|am i (?:raising|holding up|lifting))\b|"
|
||||
r"(?:내가|제가)?\s*손\s*(?:을\s*)?들었", re.I)
|
||||
r"\bwhich (?:hand|arm) is (?:up|raised)\b|\b(?:see|tell) (?:if|whether) (?:i'?m|i am) raising\b|"
|
||||
r"\b(?:see|is) my (?:hand|arm)s? (?:up|raised)\b|\bhands? up or (?:not|down)\b|\bmy (?:hand|arm) is (?:up|raised)\b|"
|
||||
r"\bi'?m raising (?:my |a )?(?:hand|arm)\b|\bi am raising\b|\b(?:is )?one of my hands (?:is )?up\b|"
|
||||
r"(?:손|hand)\s*(?:을\s*)?(?:들었|들고\s*있|올라가|올렸|올리고\s*있|up\s*했|raise)|어떤\s*손이\s*(?:올라|들)", re.I)
|
||||
POINTING = re.compile(r"\bwhat am i pointing (?:at|to)\b|\bwhere am i pointing\b|(?:내가|제가)?\s*(?:뭘|어디를?)\s*가리키", re.I)
|
||||
WEARING = re.compile(r"\b(?:am i|do i have|i'?m) (?:wearing |got )?(?:a |an |any )?(glasses|sunglasses|hat|cap|mask|"
|
||||
r"watch|earrings|necklace|scarf|tie|beard|moustache|mustache)\b|"
|
||||
r"(안경|선글라스|모자|마스크|시계|목걸이|귀걸이|넥타이|수염)\s*(?:을|를)?\s*(?:썼|쓰고|꼈|끼고|했|하고|있|찼|차고|기르)",
|
||||
re.I)
|
||||
|
||||
FAR_ME = re.compile(r"\bhow far (?:am i|are you from me|away am i)\b|(?:나|저)(?:랑|와|하고|는|한테서)?\s*얼마나", re.I)
|
||||
FAR_ME = re.compile(r"\bhow far (?:am i|are you from me|away am i)\b|(?:나|저)(?:랑|와|하고|는|한테서)?\s*얼마나|"
|
||||
r"\bam i close\b|\bdistance between us\b|\bhow many (?:meters|metres) (?:away )?am i\b|"
|
||||
r"(?:나|저)(?:랑|와|하고)\s*(?:의\s*)?(?:거리|distance)|우리\s*사이|"
|
||||
r"(?:나|저|제가|내가)(?:랑|와|하고|는)?\s*(?:몇\s*(?:미터|meter)|.{0,8}떨어져\s*있)", re.I)
|
||||
IT = re.compile(r"\b(?:it|that|this|they|them)\b|그거|그게|그건|저거|저게|저건|걔|거기", re.I)
|
||||
ORDER = re.compile(r"\b(?:take|bring|pick|grab|get|put|place|give|fetch|carry|go|come|move|turn|look)\b|(?<!\bmy )(?<!\byour )\bhands?\b(?! (?:raised|up|down)\b)(?=\s+(?:me|it|this|that|the|her|him|them|over)\b)|"
|
||||
r"가져|집어|잡아|놓아|놔|줘|갖다|가 ?줘|와 ?줘|돌아", re.I)
|
||||
r"가져|집어|잡아|놓아|놔|주고|(?<!말해 )(?<!알려 )(?<!말해)(?<!알려)줘|갖다(?!\s*놨)|가 ?줘|와 ?줘|돌아", re.I)
|
||||
DONE = re.compile(r"\bi(?:'ve| have)? (?:just )?(?:put|brought|moved|took|got)\b", re.I) # "I just put a cup there": done
|
||||
HEAD = re.compile(r"\blook\b|\beyes on me\b|\bhead\b|(?:왼쪽|오른쪽|정면|이쪽|저쪽|위|아래|나|저|side|쪽)\s*(?:좀\s*)?(?:봐|look)|"
|
||||
r"고개|\blook\s*해", re.I) # a head turn between keeps the question: "look up", "and now?"
|
||||
PRAISE = re.compile(r"^\W*(?:\w+\W+){0,3}?(?:nice|neat|cool|wow|great|amazing|impressive|smart|awesome|good eyes|"
|
||||
r"잘\s*보|똑똑|신기|대박|멋지|멋있|좋네)[^?]*$", re.I) # "nice, you have good eyes": the thread goes on
|
||||
FAR_BARE = re.compile(r"^\W*(?:(?:and|so|then)\W+)?how (?:far|near|close)(?: away)?\W*$|"
|
||||
r"^\W*(?:그럼\s*)?(?:얼마나\s*(?:멀|떨어|가까)\S*|거리는요?)\W*$", re.I) # "how far?" right after a see answer
|
||||
FOLLOW_EN = re.compile(r"^\W*(?:(?:and|so|then|ok(?:ay)?|well|but|no|sorry|oh|also|actually|wait|uh+|um+|er)\W+)*"
|
||||
@@ -152,7 +213,9 @@ FOLLOW_KO = re.compile(r"^\W*(?:(?:그럼|그러면|그리고|근데|아니요|
|
||||
BYE = re.compile(r"\b(?:bye|goodbye|see you|see ya|later)\b|안녕|잘 ?(?:가|있어)", re.I) # ends the thread
|
||||
ABOUT_LUMI = re.compile(r"(?:루미|너|니가|네가|당신)(?:는|은|가|도)?\s|^\W*넌|\bare you\b|\byou(?:'re| are) wearing\b", re.I)
|
||||
ONE = re.compile(r"(?P<col>" + "|".join(COLOURS) + r")\w*\s*(?:ones?|거|것|걸)?", re.I) # "the blue one", "파란 거"
|
||||
SEE_KINDS = ("see", "there", "still", "see_ko", "far", "it")
|
||||
UP_ASKED = re.compile(r"\bup\b|\braised?\b|\braising\b|올라|올렸|손\s*(?:을\s*)?들(?:고|었)", re.I)
|
||||
HELD_ASKED = re.compile(r"\bhold|\bhave it\b|\bin my\b|\bit\b|들고|쥐고|잡고|있(?:어|습|나|니)|들었게", re.I)
|
||||
SEE_KINDS = ("see", "there", "still", "see_ko", "see_more", "where", "far", "it")
|
||||
TAIL = re.compile(r"(?:[\s,]+(?:too|then|also|exactly|again|please|what colou?rs?(?: (?:are|is) (?:they|it))?))+\W*$|"
|
||||
r"(?:도|은|는)?\s*(?:정확히\s*)?(?:무슨\s*)?(?:색깔?|컬러|colou?r)\s*(?:은|는|이야|이에요|이에요)?\W*$|"
|
||||
r"도\s*(?:보여|보이|있어|있나)\S*\W*$|(?:은|는)?\s*(?:어때|어떻|어떤가)\S*\W*$",
|
||||
@@ -168,7 +231,7 @@ IT_SIZE = re.compile(r"\b(?:is it|is that|how) (?:big|large|small|tall|high|wide
|
||||
IT_COUNT = re.compile(r"^\W*(?:how many(?: \w+)?|any (?:others|more)|몇\s*개\S*)\W*$", re.I)
|
||||
_LEAD = r"^\W*(?:(?:and|so|but|okay|ok|well|then|hmm+|uh+|um+|oh|no|wait)\W+)*"
|
||||
AGAIN = re.compile(_LEAD + r"(?:(?:what|how) about |(?:where(?:'s| is)? (?:it|that|they)|which hand(?: is it)?|"
|
||||
r"what(?:'s| is)? (?:it|that)|is it|right|just) )?(?:now|know)\b(?:,? lumi)?"
|
||||
r"what(?:'s| is)? (?:it|that)|is it|right|just|look|check) )?(?:now|know)\b(?:,? lumi)?"
|
||||
r"(?:\W+anything (?:new|else|different))?\W*$|\bone more time\b|" # "and now?" ("and know?")
|
||||
r"\b(?:look|check|see)\b.{0,15}\b(?:again|one more time)\b|\btake another look\b|"
|
||||
r"\blook (?:closer|carefully|properly)\b|^\W*again\W*$|"
|
||||
@@ -177,9 +240,13 @@ AGAIN = re.compile(_LEAD + r"(?:(?:what|how) about |(?:where(?:'s| is)? (?:it|th
|
||||
r"\bis (?:it|that|this) (?:really|right|true|correct|so)\b|\breally\b.{0,25}\?|"
|
||||
r"^\W*(?:(?:그럼|근데|아니)\s*)?(?:(?:진짜|정말)\S{0,2}\s*)?(?:진짜|정말|확실|맞아|맞나|맞습니까|틀림없)\S{0,4}\s*\?|"
|
||||
r"^\W*(?:진짜|정말)\S{0,3}\W*$|지금은|이제는|\bnow\s*(?:은|는)|^\W*(?:그럼\s*)?(?:지금|이제)\s*\??\W*$|"
|
||||
r"(?:지금|이제)\S{0,2}\s*(?:어때|어떻|어떤가)|^\W*(?:지금|이제|now)\s+(?:손에\s*)?(?:뭐|뭘|무엇을?)\s*(?:들고|쥐고|있)|"
|
||||
r"다시\s*(?:한\s*번\s*|한번\s*)?(?:봐|보|확인|check|체크)|자세히\s*(?:다시\s*)?봐|잘\s*봐|또\s*봐", re.I)
|
||||
r"(?:지금|이제)\S{0,2}\s*(?:어때|어떻|어떤가)|(?:지금|이제|now)\S{0,2}\s+(?:손에\s*)?(?:뭐|뭘|무엇을?)\s*(?:들고|쥐고|있)|"
|
||||
r"\bdouble[- ]?check\b|^\W*(?:(?:and|okay|ok|so)\W+)*(?:what about |how about )?this time\W*$|"
|
||||
r"\bwhat now\b|^\W*now what\b|\bsure about (?:that|it)\b|\bis that (?:right|so|true|correct)\b|"
|
||||
r"이번엔|이번에는|^\W*그래요?\s*\?|\bagain\s*(?:봐|보)|sure\s*해|really\s*맞|"
|
||||
r"다시\s*(?:한\s*번\s*|한번\s*)?(?:봐|보|확인|check|체크|look)|자세히\s*(?:다시\s*)?봐|잘\s*봐|또\s*봐", re.I)
|
||||
# a new look at the same question: "are you sure?", "다시 한번 확인해 줄래요?"
|
||||
LOOK_SAID = re.compile(r"\blook\b(?=\s*(?:[,.!]|$))", re.I) # "Lumi, look, what am I holding?": not a head turn
|
||||
PUT_ON = re.compile(r"\bi(?:'ve| have)? (?:just )?(?:put on|took off|taken off)\b", re.I) # clothes, not an order
|
||||
LIKED = re.compile(r"\bfavou?rite\b|\b(?:like|love)\b|좋아하", re.I) # "is white your favourite colour?": not a check
|
||||
NOT_A_HAND = re.compile(r"\b(?:that'?s|that is|you'?re|you are|all|is that|is it) right\b|\bright (?:now|away|here|there)\b",
|
||||
@@ -187,7 +254,7 @@ NOT_A_HAND = re.compile(r"\b(?:that'?s|that is|you'?re|you are|all|is that|is it
|
||||
HAND_SAID = re.compile(r"(?P<n>\bnot (?:in )?(?:the |my |your )?|\bisn'?t (?:in )?(?:the |my |your )?)?\b(?P<s>left|right)\b"
|
||||
r"(?=\s*(?:hand|one|side)(?![a-z])|\W*$)|(?P<k>왼|오른)\s*(?:손|쪽|편)\S{0,3}(?P<kn>\s*아니)?", re.I)
|
||||
COLOUR_SAID = re.compile(r"(?P<n>\bnot (?:\w+ ){0,2}|n't (?:\w+ ){0,2})?\b(?P<c>" + "|".join(c for c in COLOURS if c.isascii()) +
|
||||
r")\b|(?P<k>" + "|".join(c for c in COLOURS if not c.isascii()) + r")\w*(?P<kn>\s*아니)?", re.I)
|
||||
r")(?![a-z])|(?P<k>" + "|".join(c for c in COLOURS if not c.isascii()) + r")\w*(?P<kn>\s*아니)?", re.I)
|
||||
_last = {"thing": None, # the thing seen last: "how far is it?"
|
||||
"name": None, # the kind of thing asked about last: "and the blue one?"
|
||||
"kind": None, # the kind of the question just answered: "what about my jeans?" after the shirt
|
||||
@@ -222,6 +289,18 @@ def _follow_up(t, last):
|
||||
return None, t
|
||||
|
||||
|
||||
BAGS = ("handbag", "backpack", "suitcase") # "가방", "bag": any of these
|
||||
|
||||
|
||||
def _sees(name, colour, frames):
|
||||
"""scene.sees, with "bag" standing for every kind of bag the detector names."""
|
||||
for n in (BAGS if name == "handbag" else (name,)):
|
||||
hits = scene.sees(n, colour, frames)
|
||||
if hits:
|
||||
return hits
|
||||
return []
|
||||
|
||||
|
||||
def _name(word):
|
||||
w = word.lower()
|
||||
return SYNONYMS.get(w) or KO_WORDS.get(w) or (w if w in objects.COCO else None)
|
||||
@@ -254,8 +333,17 @@ def _a(name, colour=None):
|
||||
def _m(d, lang):
|
||||
if d is None:
|
||||
return ""
|
||||
return (f" about {d:.1f} metres away" if d >= 1 else f" about {round(d * 100, -1):.0f} centimetres away") \
|
||||
if lang == "en" else (f" {d:.1f}미터쯤 떨어진" if d >= 1 else f" {round(d * 100, -1):.0f}센티미터쯤 떨어진")
|
||||
return (f" about {_metres(d)} away" if d >= 1 else f" about {round(d * 100, -1):.0f} centimetres away") \
|
||||
if lang == "en" else (f" {_d(d)}미터쯤 떨어진" if d >= 1 else f" {round(d * 100, -1):.0f}센티미터쯤 떨어진")
|
||||
|
||||
|
||||
def _d(d):
|
||||
"""2.0 -> "2", 1.46 -> "1.5": metres as said aloud."""
|
||||
return f"{d:.1f}".removesuffix(".0")
|
||||
|
||||
|
||||
def _metres(d):
|
||||
return f"{_d(d)} metre" + ("" if _d(d) == "1" else "s")
|
||||
|
||||
|
||||
def _where_ko(w):
|
||||
@@ -266,6 +354,8 @@ def _say(en, ko, lang):
|
||||
return en if lang == "en" else ko
|
||||
|
||||
|
||||
EMPTY_HANDS = ("I don't see anything I can recognise in your hands{}. Small things like a watch, a ring or a pen "
|
||||
"I can't make out.", "{}손에 제가 알아볼 수 있는 건 없어요. 시계, 반지, 펜 같은 작은 건 제 카메라로는 알아보기 어려워요.")
|
||||
NO_CAMERA = ("My cameras aren't giving me a picture right now, so I can't tell.", "지금은 카메라 화면이 없어서 잘 모르겠어요.")
|
||||
|
||||
|
||||
@@ -275,7 +365,7 @@ def _seen_answer(name, colour, frames, lang):
|
||||
n = len(scene.people(frames))
|
||||
return _say(f"Yes, I see {_n(n)} {'person' if n == 1 else 'people'}." if n else "No, I don't see anyone right now.",
|
||||
f"네, 사람 {n}명이 보여요." if n else "아니요, 지금은 아무도 안 보여요.", lang)
|
||||
hits = scene.sees(name, colour, frames)
|
||||
hits = _sees(name, colour, frames)
|
||||
if hits:
|
||||
t = hits[0]
|
||||
_last["thing"] = t
|
||||
@@ -287,7 +377,7 @@ def _seen_answer(name, colour, frames, lang):
|
||||
en += f" I see {more} more."
|
||||
ko += f" {more}개 더 보여요."
|
||||
return _say(en, ko, lang)
|
||||
other = scene.sees(name, None, frames) if colour else []
|
||||
other = _sees(name, None, frames) if colour else []
|
||||
if other:
|
||||
t = other[0]
|
||||
_last["thing"] = t
|
||||
@@ -330,7 +420,7 @@ def _it_answer(t, frames, lang):
|
||||
th = _last["thing"]
|
||||
name = th["name"]
|
||||
if IT_COUNT.search(t):
|
||||
n = len(scene.sees(name, None, frames))
|
||||
n = len(_sees(name, None, frames))
|
||||
return _say(f"I see {_n(n)} {name}{'' if n == 1 else 's'}.", f"{_ko_name(name)} {n}개가 보여요.", lang)
|
||||
if IT_COLOUR.search(t):
|
||||
c = th["colour"]
|
||||
@@ -356,10 +446,15 @@ def _held_answer(frames, lang):
|
||||
f"{hand[1]}손에 {COLOUR_KO[o['colour']] + ' ' if o['colour'] in COLOUR_KO else ''}"
|
||||
f"{_j(_ko_name(o['name']), '을', '를')} 들고 계세요.", lang)
|
||||
if scene.person_holds(None, frames) is False:
|
||||
return _say("I don't see anything I can recognise in your hands.", "손에 제가 알아볼 수 있는 건 없어요.", lang)
|
||||
return _empty_hands(lang)
|
||||
return _say("I can't see your hands well enough to tell.", "손이 잘 안 보여서 모르겠어요.", lang)
|
||||
|
||||
|
||||
def _empty_hands(lang, now=False):
|
||||
"""Nothing the detector knows in the hands: said plainly, with what it can't see (a watch has no class)."""
|
||||
return _say(EMPTY_HANDS[0].format(" now" if now else ""), EMPTY_HANDS[1].format("지금은 " if now else ""), lang)
|
||||
|
||||
|
||||
NOUN = {"upper": ("top", "상의"), "lower": ("trousers", "바지"), "feet": ("shoes", "신발")}
|
||||
|
||||
|
||||
@@ -419,10 +514,14 @@ def _doing_answer(p, frames, lang):
|
||||
return _say(", ".join(en) + ".", " ".join(ko).rstrip("고").rstrip("시") + "세요.", lang)
|
||||
|
||||
|
||||
KINDS = (("wearing", WEARING), ("holding", HOLDING), ("shirt", SHIRT), ("raised", RAISED), ("hand", WHICH_HAND),
|
||||
UP_ASKED = re.compile(r"\bup\b|\braised?\b|\braising\b|올라|올렸|손\s*(?:을\s*)?들(?:고|었)", re.I)
|
||||
HELD_ASKED = re.compile(r"\bhold|\bhave it\b|\bin my\b|\bit\b|들고|쥐고|잡고|있(?:어|습|나|니)|들었게", re.I)
|
||||
|
||||
|
||||
KINDS = (("wearing", WEARING), ("holding", HOLDING), ("shirt", SHIRT), ("raised", RAISED), ("where", WHERE_THING), ("hand", WHICH_HAND),
|
||||
("pointing", POINTING), ("doing", DOING), ("friend", FRIEND), ("see_me", SEE_ME), ("how_many", HOW_MANY), ("behind", BEHIND),
|
||||
("far", HOW_FAR), ("see", SEE_THING), ("there", THERE_IS), ("still", STILL_THERE), ("see_ko", SEE_THING_KO),
|
||||
("what_see", WHAT_SEE))
|
||||
("see_more", SEE_MORE), ("what_see", WHAT_SEE))
|
||||
|
||||
|
||||
def answer(text, lang="en", frames=None, slow_line=None):
|
||||
@@ -439,8 +538,10 @@ def answer(text, lang="en", frames=None, slow_line=None):
|
||||
return got
|
||||
if brain.is_backchannel(t) and not BYE.search(t): # "nice!" between keeps the thread: "and my jeans?"
|
||||
return None
|
||||
if last and own is None and (HEAD.search(t) or PRAISE.search(t)):
|
||||
return None # "look up" / "nice!" between: "and now?" still asks again
|
||||
_last["kind"] = None # a follow-up goes only with the turn right before
|
||||
if ORDER.search(t) and not PUT_ON.search(t):
|
||||
if ORDER.search(DONE.sub(" ", LOOK_SAID.sub(" ", t))) and not PUT_ON.search(t):
|
||||
return None # "find the red cup and bring it": a fetch, not a question
|
||||
kind = own
|
||||
if kind == "shirt" and ABOUT_LUMI.search(t):
|
||||
@@ -450,9 +551,10 @@ def answer(text, lang="en", frames=None, slow_line=None):
|
||||
kind = "it" # "where is it?", "무슨 색이야?" about the thing just seen
|
||||
if kind is None and last:
|
||||
kind, t = _follow_up(t, last)
|
||||
if kind is None or kind == "how_many" and NOT_IN_VIEW.search(t):
|
||||
return None
|
||||
if kind == "far" and not (HOW_FAR_THING.search(t) or SEE_THING_KO.search(t)):
|
||||
if kind is None or kind == "how_many" and NOT_IN_VIEW.search(t) or \
|
||||
kind == "where" and _thing(WHERE_THING.search(t))[0] in BIG:
|
||||
return None # "where is the toilet?": the way there, not the cameras
|
||||
if kind == "far" and not (FAR_THING.search(t) or SEE_THING_KO.search(t)):
|
||||
if FAR_ME.search(t):
|
||||
kind = "far_me"
|
||||
elif _last["thing"] is None or last not in SEE_KINDS or re.search(r"\bit\s+(?:to|from)\b", t, re.I) or \
|
||||
@@ -495,16 +597,44 @@ def _colours(t):
|
||||
return (said[-1] if said else None), denied - set(said[-1:])
|
||||
|
||||
|
||||
NUMBER = {"one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "한": 1, "두": 2, "세": 3, "네": 4, "다섯": 5,
|
||||
"여섯": 6, "혼자": 1, "둘": 2, "셋": 3, "넷": 4}
|
||||
COUNT_SAID = re.compile(r"\b(?P<e>one|two|three|four|five|six|\d)\b(?=.{0,12}\b(?:people|persons|of us|here)(?![a-z]))|"
|
||||
r"\bwe(?:'re| are) (?P<w>one|two|three|four|five|six|\d)\b|(?P<s>한|두|세|네|다섯|여섯)\s*사람|"
|
||||
r"\bi count (?P<c>one|two|three|four|five|six|\d)\b|(?P<k>한|두|세|네|다섯|여섯|\d)\s*(?:명|분)|"
|
||||
r"(?P<b>혼자|둘|셋|넷)(?:이야|이에요|입니다|이요|야|요)?\W*$", re.I)
|
||||
|
||||
|
||||
WRONG = re.compile(r"^\W*(?:no|nope|wrong|but|you'?re wrong|that'?s wrong|not (?:true|right)|아니|아닌데|틀렸)\b", re.I)
|
||||
# "wrong, it's a watch": looked at again even when the word names nothing known
|
||||
|
||||
|
||||
def _said_count(t):
|
||||
"""The number of people a correction names: "no, there are four of us", "아니야, 세명이야" -> 4 / 3."""
|
||||
m = COUNT_SAID.search(t)
|
||||
w = m and next(g for g in m.groups() if g)
|
||||
return w and (int(w) if w.isdigit() else NUMBER[w.lower()])
|
||||
|
||||
|
||||
def _said_thing(t):
|
||||
"""The thing a correction names: "nope, this is a book", "아닌데, 이거 오렌지야" -> "book" / "orange"."""
|
||||
m = re.search(_THING_EN, t, re.I) or re.search(_THING_KO, t)
|
||||
return m and _name(m.group("obj"))
|
||||
|
||||
|
||||
PALE = objects.LIGHT | {"light blue"} # a white shirt under a cool office light may read light blue
|
||||
|
||||
|
||||
def _verdict(c, said, denied, en, ko, verb, lang, before=None):
|
||||
"""A colour the person said (or denied) against the colour the camera sees now: agree only when it agrees.
|
||||
before: the colour said in the answer before."""
|
||||
if c is None:
|
||||
return _say(f"I can't see {en} well enough right now.", f"지금은 {_j(ko, '이', '가')} 잘 안 보여요.", lang)
|
||||
k = COLOUR_KO.get(c, c)
|
||||
if said == c or said is None and c not in denied:
|
||||
if said == c or said and c == f"light {said}" or said is None and c not in denied:
|
||||
lead = ("Yes, " if said else "You're right, looking again ", "네, " if said else "맞아요, 다시 보니 ")
|
||||
return _say(f"{lead[0]}{en} {verb} {c}.", f"{lead[1]}{_j(ko, '은', '는')} {k}으로 보여요.", lang)
|
||||
if said and {said, c} <= objects.LIGHT: # white in shade reads grey: both may be true
|
||||
if said and {said, c} <= PALE: # white in shade reads grey: both may be true
|
||||
return _say(f"To my camera {en} {verb} {c}; in this light it may well be {said}.",
|
||||
f"제 카메라에는 {k}으로 보이는데, 이 조명에서는 {COLOUR_KO.get(said, said)}일 수도 있어요.", lang)
|
||||
if c != before: # the new look sees otherwise than the answer before
|
||||
@@ -521,16 +651,25 @@ def _check(t, lang, frames, since, slow_line):
|
||||
kind, asked = _last["asked"]
|
||||
again = AGAIN.search(t)
|
||||
short = len(t.split()) <= CLAIM_WORDS and \
|
||||
not (ORDER.search(re.sub(r"\W+look\W*$", "", t)) and not again) # "put it in my right hand"; "..., look"
|
||||
not ((ORDER.search(re.sub(r"\W+look\W*$", "", t)) or HEAD.search(t)) and not again) # "put it in my right hand"; "..., look"
|
||||
hand = _side(t) if short and kind in ("holding", "hand", "raised") else None
|
||||
said, denied = _colours(t) if short and kind in ("shirt", "holding", "hand") else (None, set())
|
||||
if not (hand or said or denied or again):
|
||||
named = _said_thing(t) if short and kind in ("holding", "hand") and not hand else None
|
||||
count = _said_count(t) if short and kind == "how_many" else None
|
||||
again = again or WRONG.search(t) and short and len(t.split()) > 1 and _follow_up(t, kind)[0] is None
|
||||
if not (hand or said or denied or again or named or count):
|
||||
return None
|
||||
frames = _look(frames, since)
|
||||
_last["kind"] = kind # the thread goes on: "and now?" again
|
||||
if not frames:
|
||||
return _say(*NO_CAMERA, lang)
|
||||
if not (hand or said or denied):
|
||||
if count: # "no, there are four of us": counted again
|
||||
n = len(scene.people(frames))
|
||||
if n == count:
|
||||
return _say(f"Yes, I see {_n(n)} {'person' if n == 1 else 'people'}.", f"네, {n}명이 보여요.", lang)
|
||||
return _say(f"I count {_n(n)} {'person' if n == 1 else 'people'} in view now, not {count}; someone may be out of "
|
||||
f"my view.", f"제 카메라에는 지금 {n}명이 보여요. 화면 밖에 계신 분이 있을 수도 있어요.", lang)
|
||||
if not (hand or said or denied or named):
|
||||
got = _reply(kind, asked, frames, lang, slow_line)
|
||||
return got and _say("I looked again. ", "다시 봤어요. ", lang) + got
|
||||
p = scene.person_in_front(frames)
|
||||
@@ -564,7 +703,7 @@ def _check(t, lang, frames, since, slow_line):
|
||||
o = {**inn, "hand": hand} if inn else o
|
||||
if o is None:
|
||||
if scene.person_holds(None, frames) is False:
|
||||
return _say("I don't see anything I can recognise in your hands now.", "지금은 손에 제가 알아볼 수 있는 건 없어요.", lang)
|
||||
return _empty_hands(lang, now=True)
|
||||
return _say("I can't see your hands well enough to tell.", "손이 잘 안 보여서 모르겠어요.", lang)
|
||||
thing = (_a(o["name"], o["colour"]), _ko_name(o["name"]))
|
||||
if o["hand"] == hand:
|
||||
@@ -573,7 +712,13 @@ def _check(t, lang, frames, since, slow_line):
|
||||
return _say(f"I see {thing[0]} in your {o['hand']} hand, but I may be wrong.",
|
||||
f"제 카메라에는 {side[o['hand']]}손에 {_j(thing[1], '이', '가')} 보여요. 틀릴 수도 있어요.", lang)
|
||||
if o is None:
|
||||
return _say("I don't see anything I can recognise in your hands now.", "지금은 손에 제가 알아볼 수 있는 건 없어요.", lang)
|
||||
return _empty_hands(lang, now=True)
|
||||
if named: # "nope, this is a book": checked, not agreed
|
||||
if o["name"] == named:
|
||||
return _say(f"Yes, I see {_a(o['name'], o['colour'])} in your hand.",
|
||||
f"네, 손에 {_j(_ko_name(o['name']), '이', '가')} 보여요.", lang)
|
||||
return _say(f"To my camera it looks like {_a(o['name'])}, not {_a(named)}, but I may be wrong.",
|
||||
f"제 카메라에는 {_j(_ko_name(named), '이', '가')} 아니라 {_ko_name(o['name'])}(으)로 보여요. 틀릴 수도 있어요.", lang)
|
||||
return _verdict(o["colour"], said, denied, f"the {o['name']}", _ko_name(o["name"]), "looks", lang)
|
||||
|
||||
|
||||
@@ -583,7 +728,7 @@ def _reply(kind, t, frames, lang, slow_line=None):
|
||||
return _say("My cameras look forward, so I can't see what's behind me. " + describe(frames, "en"),
|
||||
"제 카메라는 앞만 보여서 뒤는 볼 수 없어요. " + describe(frames, "ko"), lang)
|
||||
if kind == "what_see":
|
||||
if re.search(r"table|desk|테이블", t, re.I):
|
||||
if re.search(r"table|desk|테이블|탁자|책상", t, re.I):
|
||||
things = _listing(frames, lang, small_only=True)
|
||||
return _say(f"On the table I see {things}." if things else "I don't see anything on the table I can name.",
|
||||
f"테이블 위에 {_j(things, '이', '가')} 보여요." if things else "테이블 위에 제가 알아볼 수 있는 건 없어요.", lang)
|
||||
@@ -592,8 +737,9 @@ def _reply(kind, t, frames, lang, slow_line=None):
|
||||
n = len(scene.people(frames))
|
||||
return _say(f"I see {_n(n)} {'person' if n == 1 else 'people'} right now." if n else "I don't see anyone right now.",
|
||||
f"지금 {n}명이 보여요." if n else "지금은 아무도 안 보여요.", lang)
|
||||
if kind in ("see", "there", "still", "see_ko"):
|
||||
m = {"see": SEE_THING, "there": THERE_IS, "still": STILL_THERE, "see_ko": SEE_THING_KO}[kind].search(t)
|
||||
if kind in ("see", "there", "still", "see_ko", "see_more", "where"):
|
||||
m = {"see": SEE_THING, "there": THERE_IS, "still": STILL_THERE, "see_ko": SEE_THING_KO, "see_more": SEE_MORE,
|
||||
"where": WHERE_THING}[kind].search(t)
|
||||
name, colour = _thing(m)
|
||||
if name is None:
|
||||
return None
|
||||
@@ -601,20 +747,20 @@ def _reply(kind, t, frames, lang, slow_line=None):
|
||||
if kind == "it":
|
||||
return _it_answer(t, frames, lang)
|
||||
if kind == "far":
|
||||
m = HOW_FAR_THING.search(t) or SEE_THING_KO.search(t)
|
||||
m = FAR_THING.search(t) or SEE_THING_KO.search(t)
|
||||
if m:
|
||||
name, colour = _thing(m)
|
||||
_last["name"] = name
|
||||
hits = scene.sees(name, colour, frames)
|
||||
hits = _sees(name, colour, frames)
|
||||
if not hits:
|
||||
return _say(f"I don't see {_a(name, colour)} right now.", f"지금은 {_j(_ko_name(name), '이', '가')} 안 보여요.", lang)
|
||||
_last["thing"] = hits[0]
|
||||
name = _last["thing"]["name"]
|
||||
again = [h for h in scene.sees(name, None, frames) if h["camera"] == _last["thing"]["camera"]] or [_last["thing"]]
|
||||
again = [h for h in _sees(name, None, frames) if h["camera"] == _last["thing"]["camera"]] or [_last["thing"]]
|
||||
d = min(again, key=lambda h: abs((h["bearing_deg"] or 0) - (_last["thing"]["bearing_deg"] or 0)))["distance_m"]
|
||||
if d is None:
|
||||
return _say("I can't measure how far it is.", "거리는 잴 수 없어요.", lang)
|
||||
return _say(f"The {name} is about {d:.1f} metres from me.", f"{_j(_ko_name(name), '은', '는')} 저한테서 {d:.1f}미터쯤 떨어져 있어요.", lang)
|
||||
return _say(f"The {name} is about {_metres(d)} from me.", f"{_j(_ko_name(name), '은', '는')} 저한테서 {_d(d)}미터쯤 떨어져 있어요.", lang)
|
||||
if kind == "holding":
|
||||
return _held_answer(frames, lang)
|
||||
p = scene.person_in_front(frames)
|
||||
@@ -635,18 +781,19 @@ def _reply(kind, t, frames, lang, slow_line=None):
|
||||
if p is None and not scene.people(frames):
|
||||
return _say("No, I can't see you right now.", "아니요, 지금은 안 보여요.", lang)
|
||||
d = p["distance_m"] if p else None
|
||||
return _say(f"Yes, I can see you{_m(d, 'en')}.", f"네, 보여요.{' ' + f'{d:.1f}미터쯤 앞에 계세요.' if d else ''}", lang)
|
||||
return _say(f"Yes, I can see you{_m(d, 'en')}.", f"네, 보여요.{' ' + f'{_d(d)}미터쯤 앞에 계세요.' if d else ''}", lang)
|
||||
if p is None:
|
||||
return _say("I can't see you well enough to tell. Could you step in front of me?",
|
||||
"잘 안 보여서 모르겠어요. 제 앞으로 와 주시겠어요?", lang)
|
||||
if kind == "far_me":
|
||||
if p["distance_m"] is None:
|
||||
return _say("I can't measure how far you are.", "거리는 잴 수 없어요.", lang)
|
||||
return _say(f"You're about {p['distance_m']:.1f} metres from me.", f"저한테서 {p['distance_m']:.1f}미터쯤 떨어져 계세요.", lang)
|
||||
return _say(f"You're about {_metres(p['distance_m'])} from me.", f"저한테서 {_d(p['distance_m'])}미터쯤 떨어져 계세요.", lang)
|
||||
if kind == "shirt":
|
||||
return _clothes_answer(p, t, lang)
|
||||
if kind == "hand": # "which hand?": the one holding something, else one raised
|
||||
if scene.object_in_hand(frames) or not p["raised"]:
|
||||
up = UP_ASKED.search(t) # "left or right, which one's up?"
|
||||
if not up and (HELD_ASKED.search(t) or scene.object_in_hand(frames) or not p["raised"]):
|
||||
return _held_answer(frames, lang)
|
||||
kind = "raised"
|
||||
if kind == "raised":
|
||||
@@ -683,6 +830,15 @@ def _reply(kind, t, frames, lang, slow_line=None):
|
||||
return None
|
||||
|
||||
|
||||
RECHECK_S = 30.0 # s; a one-word "really?" this soon after a seeing answer is a new look, also said
|
||||
# while Lumi still talks
|
||||
|
||||
|
||||
def recheck(text):
|
||||
""""Really?", "진짜?", "Now?" right after a seeing answer: worth interrupting Lumi for (a new look), though one word."""
|
||||
return bool(_last["kind"] and time.time() - _last["at"] < RECHECK_S and AGAIN.search(text.strip()))
|
||||
|
||||
|
||||
ABOUT_VIEW = re.compile(r"\b(?:see|seeing|look(?:ing)? at|camera|cameras|in front of you|around you|holding|wearing|"
|
||||
r"colou?r)\b|보여|보이|보고|카메라|들고|입고|무슨 색", re.I)
|
||||
|
||||
|
||||
+44
-18
@@ -54,6 +54,8 @@ def _norm(text, markers=()):
|
||||
t = re.sub(r"\b(?:take|pick up|pick|grab)\s?(?:해서|하고)", "집어서", t) # "컵 take해서": mixed
|
||||
t = re.sub(r"(?<=[가-힣])고\s*나서(?=[\s,]|$)", "고", t) # "가고 나서" = "가고"
|
||||
t = re.sub(r"(?<![가-힣])(집었|잡았)다가(?=[\s,]|$)", lambda m: m.group(1)[0] + "고", t) # "컵 집었다가" = "컵 집고"
|
||||
for said, same in _SAME: # "get yourself to" = "go to"
|
||||
t = re.sub(said, same, t)
|
||||
for honour, plain in _HON_KO: # "가셔서" = "가서", "받으시고" = "받고"
|
||||
t = re.sub(rf"(?<![가-힣]){honour}(?=[\s,.!?]|$)", plain, t)
|
||||
return re.sub(r"(?<![가-힣])(간|온|집은|잡은|든|받은|준|놓은|돈|기다린|들른|가신|오신|기다리신|받으신|집으신|잡으신|드신|주신|놓으신|도신)"
|
||||
@@ -61,6 +63,18 @@ def _norm(text, markers=()):
|
||||
lambda m: _AFTER_KO[m.group(1)], t).strip() # "p3에 간 다음에" = "p3에 가고"
|
||||
|
||||
|
||||
_SAME = [ # wordings read as the plain one (the blind mission sets, 2026-10-22)
|
||||
(r"\bget yourself (?=to )", "go "), (r"\b(?:take|get|grab) hold of\b", "take"),
|
||||
(r"\bmake a (left|right) turn\b", r"turn \1"),
|
||||
(r"\bturn (\d+(?:\.\d+)?) degrees? (?:to (?:the |your )?)?(left|right)\b", r"turn \2 \1"),
|
||||
(r"\breverse (?=\d)", "move back "), (r"\bkeep it in your hands?\b", "hold it"),
|
||||
(r"\bcome back to where (?:i am|you are|we are)\b", "come back"),
|
||||
(r"\buntil (?:someone|somebody|they|i|we) (?:says?|tells? you)(?: to)? (?:go on|continue|move on)\b"
|
||||
r"|\buntil you(?:'re| are) told to (?:go on|continue|move on)\b", "until i tell you to go on"),
|
||||
(r"(?:누가\s*)?계속\s*(?:가라고|하라고|가도 된다고)\s*(?:할|하실|말할)\s*때까지\s*(?:거기서\s*)?", ""),
|
||||
(r"(?<=\S)까지\s*(?=갔다 ?와|다녀와)", " "), # "p4까지 갔다 와요" = "p4 갔다 와요"
|
||||
(r"돌아오(?:세요|십시오)", "돌아와"), (r"(?:이리로|여기로|이쪽으로)\s*돌아와", "돌아와"),
|
||||
]
|
||||
_AFTER_KO = {"간": "가고", "온": "오고", "집은": "집고", "잡은": "잡고", "든": "들고", "받은": "받고", "준": "주고", "놓은": "놓고",
|
||||
"돈": "돌고", "기다린": "기다리고", "들른": "들르고", "가신": "가고", "오신": "오고", "기다리신": "기다리고",
|
||||
"받으신": "받고", "집으신": "집고", "잡으신": "잡고", "드신": "들고", "주신": "주고", "놓으신": "놓고",
|
||||
@@ -77,10 +91,11 @@ def _place(word, markers):
|
||||
"""A place word in a go clause -> marker name, "here", or None (not on the map)."""
|
||||
word = re.sub(r"(?<=\S) (?:point|marker)$|\s*(?:앞|옆|근처|쪽|포인트|지점)$", "", word.strip()) # "the final point", "p5 앞"
|
||||
w = re.sub(r"^(?:either |the |your |my |point |marker |포인트 ?)", "", word)
|
||||
exact = next((mk for mk in markers if mk.lower() == w or mk.lower() == w.replace(" ", "")), None)
|
||||
exact = next((mk for mk in markers if wording._key(mk) == wording._key(w)), None) # "coffee_corner", "부스 3"
|
||||
if exact:
|
||||
return exact
|
||||
close = wording.close_names(w, markers) if re.fullmatch(r"[a-z][a-z0-9_ ]*", w) else []
|
||||
close = wording.close_names(w, markers) if re.fullmatch(r"[a-z][a-z0-9_]*", w) else [] # one word: "coffee_corner
|
||||
# later" is no slip
|
||||
if len(close) == 1:
|
||||
return close[0] # a whisper slip of one name ("stagee로 가")
|
||||
m = re.fullmatch(brain._place_re(markers), word.strip())
|
||||
@@ -94,7 +109,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|(?: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*",
|
||||
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]
|
||||
return names if names and None not in names else None
|
||||
@@ -122,7 +137,8 @@ def _go(c, markers):
|
||||
if m:
|
||||
to = _places(m.group(1), markers)
|
||||
return to and {"do": "go", "to": to if len(to) > 1 else to[0]}
|
||||
m = re.fullmatch(r"(?:go|drive|head) (?:the )?([a-z][a-z0-9_]*)(?: point| marker)?", c) # whisper drops the "to"
|
||||
m = re.fullmatch(r"(?:go|drive|head) (?:the )?([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*)(?: point| marker| 포인트)?", c) # whisper
|
||||
# drops the "to"
|
||||
if m and m.group(1) not in ("home", "here") and (to := _places(m.group(1), markers)):
|
||||
return {"do": "go", "to": to[0]}
|
||||
if re.fullmatch(r"go (?:home )?(?:to )?charge(?: yourself)?|충전하러 (?:집으로 )?가", c):
|
||||
@@ -138,7 +154,7 @@ def _go(c, markers):
|
||||
if m and (to := _places(m.group(1), markers)) and len(to) == 1:
|
||||
return [{"do": "go", "to": to[0]}, {"do": "go", "to": "here"}] # "p3 갔다 와": there and back
|
||||
m = re.fullmatch(r"(?:(?:이거|이것|그거)\s+)?(.+?)\s*(?:중에서?|중)?\s*(?:아무 ?데나|아무 ?곳에나|하나|한 ?곳)?\s*"
|
||||
r"(?:으로|로|에|까지)?\s*(?:가져가|가져와|가져다 ?줘|가져다|갖다 ?줘|갖다|가|와|가 ?줘|돌아가|돌아와|갔다가|이동해|이동하고|이동해서|이동)"
|
||||
r"(?:으로|로|에|까지)?\s*(?:가져가|가져와|가져다 ?줘|가져다|갖다 ?줘|갖다|가|와|가 ?줘|돌아가|돌아와|갔다가|이동해|이동하고|이동해서|이동|go)"
|
||||
r"(?:서|고|세요|줘|요)?|(\S+?)(?:으로|로)", c)
|
||||
if m:
|
||||
to = _places(re.sub(r"\s*(?:중에서?|중)\s*(?:아무 ?데나|아무 ?곳에나|하나|한 ?곳)?$", "", m.group(1) or m.group(2)),
|
||||
@@ -157,7 +173,7 @@ def _move(c):
|
||||
pats = (rf"(?:(?:go|move|drive|step|walk|come|back up|head)\s+)?(?:to (?:the |your )?)?{_DIR}\s+(?:by\s+)?{_NUM} m",
|
||||
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"{_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:
|
||||
@@ -281,7 +297,7 @@ def _give(c):
|
||||
r"|wait (?:there )?(?:until|till) (?:someone|somebody|anyone|they|he|she) takes? it(?: from you)?"
|
||||
r"|hand it over|(?:give|hand) it", c) or \
|
||||
re.fullmatch(rf"(?:그거|그것을?|(?:(?:{COL})\s*)?(?:{OBJ})(?:을|를)?)?\s*(?:줘|주고|주세요|건네 ?줘|건네주고|"
|
||||
rf"건네 ?주세요|건네)", c):
|
||||
rf"건네 ?주세요|건네|전해 ?줘|전해 ?주고|전해 ?주세요|전해)", c):
|
||||
return {"do": "give"}
|
||||
if re.fullmatch(r"(?:거기 (?:있는|계신)\s*)?(?:나한테|저한테|나에게|저에게|그 사람한테|사람한테|그분께|분께|분한테)\s*"
|
||||
rf"(?:(?:이거|그거|이것|그것|이걸|그걸|(?:(?:이|그)\s*)?(?:{OBJ})(?:을|를)?)\s*)?"
|
||||
@@ -473,7 +489,7 @@ _GIVE_KO = r"(?:갖다 ?주고|가져다 ?주고|갖다 ?줘|갖다 ?드려|가
|
||||
def _is_name(n, markers):
|
||||
n = n.strip()
|
||||
return bool(n) and n not in _NOT_NAME and n.split()[-1] not in _NOT_NAME and n not in brain.OBJECTS and \
|
||||
n not in brain.COLOURS and not any(n == m.lower() for m in markers) and not re.fullmatch(r"p\d+", n)
|
||||
n not in brain.COLOURS and not any(n == wording.written(m) for m in markers) and not re.fullmatch(r"p\d+", n)
|
||||
|
||||
|
||||
def _ko_name(n):
|
||||
@@ -600,7 +616,7 @@ def _person(c, markers):
|
||||
if m and _places(m.group(1), markers) and len(_places(m.group(1), markers)) == 1:
|
||||
return [{"do": "go", "to": _places(m.group(1), markers)[0]}, {"do": "place", "on": {
|
||||
"name": brain.SUPPORTS[m.group(3)], "colour": brain.COLOURS.get(m.group(2)), "side": None}}]
|
||||
m = re.fullmatch(r"([a-z][a-z0-9_]*) (?:테이블|책상|식탁)(?: 위)?에 (?:놔|놓아|올려놔)", c)
|
||||
m = re.fullmatch(r"([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*) (?:테이블|책상|식탁)(?: 위)?에 (?:놔|놓아|올려놔)", c)
|
||||
if m and (to := _places(m.group(1), markers)) and to != ["here"]:
|
||||
return [{"do": "go", "to": to[0]}, {"do": "place", "on": {"name": "dining table", "colour": None,
|
||||
"side": None}}]
|
||||
@@ -689,7 +705,8 @@ def _clause_steps(c, markers, after=None):
|
||||
c = re.sub(r"^\S+ 말고\s+", "", c) # "미나 말고 사라한테": not Mina, Sara
|
||||
c = re.sub(r"^\S+ (?:없으니까|없어서|없대서)\s+", "", c) # "현우 없으니까 ...": the reason, not a step
|
||||
c = re.sub(r"\s+(?:거기로|내가) 갈게$", "", c)
|
||||
c = re.sub(r"(?<=[a-z0-9]) (?:하고|해서|하고서|하고 나서|한 다음에?)$", "", c) # "turn left 하고 p2로 가"
|
||||
c = re.sub(r"(?<=[a-z0-9가-힣]) (?:하고|해서|하고서|하고 나서|한 다음에?)$", "", c) # "turn left 하고 p2로 가",
|
||||
# "go to 입구 하고"
|
||||
raw, c = c, _sender(c)
|
||||
if not c:
|
||||
return []
|
||||
@@ -777,10 +794,18 @@ def _cut_says(text):
|
||||
return _SAY_EN.sub(keep, text), says
|
||||
|
||||
|
||||
def _split(t):
|
||||
def _split(t, markers=()):
|
||||
"""Clauses; a Korean marker name that ends like a verb ("창고 가서", "창고 point") is not cut after."""
|
||||
ends = tuple(wording.written(m) for m in markers if re.search(r"[가-힣](?:고|서)$", m))
|
||||
out = []
|
||||
for part in _SPLIT.split(t):
|
||||
out += [p for p in _SPLIT_KO.split(part) if p.strip()]
|
||||
pieces = []
|
||||
for p in _SPLIT_KO.split(part):
|
||||
if pieces and ends and re.search(rf"(?<![가-힣])(?:{'|'.join(ends)})$", pieces[-1]):
|
||||
pieces[-1] += " " + p
|
||||
else:
|
||||
pieces.append(p)
|
||||
out += [p for p in pieces if p.strip()]
|
||||
return out
|
||||
|
||||
|
||||
@@ -788,11 +813,11 @@ def _protect_lists(t, markers):
|
||||
"""'p3, p5 or p7' (one of them) must not be split as clauses: joined with '|'. Only a list that says "or",
|
||||
"one of", "random", "중": "go to p1 and p2" is two drives, not a choice."""
|
||||
place = rf"(?:{brain._place_re(markers)})"
|
||||
sep = r"\s*(?:,\s*(?:or|and)\b|,|\bor\b|\band\b|또는|(?<=\d)나)\s*"
|
||||
sep = r"\s*(?:,\s*(?:or|and)\b|,|\bor\b|\band\b|또는|(?<=[a-z\d가-힣])(?:이나|나)(?=\s))\s*" # "입구나 로비"
|
||||
|
||||
def join(m):
|
||||
before, after = t[:m.start()], t[m.end():]
|
||||
if re.search(r"\bor\b|또는|(?<=\d)나", m.group(0)) or re.match(r"\s*중", after) or \
|
||||
if re.search(r"\bor\b|또는|(?<=[a-z\d가-힣])나(?=\s)", m.group(0)) or re.match(r"\s*중", after) or \
|
||||
re.search(r"\b(?:(?:one|any) of|random(?: one)? of)(?: the)?\s*$", before):
|
||||
return re.sub(sep, "|", m.group(0))
|
||||
return m.group(0)
|
||||
@@ -811,7 +836,8 @@ _PIECE = re.compile(r"\s+(?=(?:go|come|wait|turn|pick up|grab|give|hand|put|brin
|
||||
def _pieces(c, markers, after):
|
||||
"""A clause read as several steps when it splits at step verbs and every piece reads; else None."""
|
||||
parts = _PIECE.split(c)
|
||||
if len(parts) < 2 or re.search(r"[가-힣]", c):
|
||||
names = "|".join(re.escape(wording.written(m)) for m in markers if re.search("[가-힣]", m)) or "^$"
|
||||
if len(parts) < 2 or re.search(r"[가-힣]", re.sub(names, "", c)): # Korean words, not a Korean name
|
||||
return None
|
||||
out = []
|
||||
for p in parts:
|
||||
@@ -828,7 +854,7 @@ def rules(text, markers=()):
|
||||
t = _protect_lists(_norm(cut, markers), markers)
|
||||
t = _INTERJECTION.sub("", t)
|
||||
steps, unread = [], []
|
||||
for c in _split(t):
|
||||
for c in _split(t, markers):
|
||||
c = c.replace("|", ", ")
|
||||
m = re.fullmatch(r"§(\d+)§", c.strip())
|
||||
got = [{"do": "say", "text": says[int(m.group(1))]}] if m else _clause(c, markers, steps[-1] if steps else None)
|
||||
@@ -919,7 +945,7 @@ def read(text, markers=(), llm=True):
|
||||
clauses unread, the LLM reads the whole command and its answer is kept only if every value in it is written in
|
||||
the command (_checked). "other": the LLM says it is not English or Korean, nothing is taken."""
|
||||
s, u = rules(text, markers)
|
||||
if not u or not llm or len(_split(_norm(_cut_says(text)[0], markers))) < 2:
|
||||
if not u or not llm or len(_split(_norm(_cut_says(text)[0], markers), markers)) < 2:
|
||||
return s, u, "rules"
|
||||
got = _llm(text, markers)
|
||||
if got == "other":
|
||||
@@ -1031,7 +1057,7 @@ def _checked(raw, text, markers):
|
||||
if x == "here" and re.search(r"\b(?:here|back|me)\b|여기|돌아|나한테|저한테", t):
|
||||
names.append("here")
|
||||
continue
|
||||
mk = next((m for m in markers if m.lower() == x.lower()), None)
|
||||
mk = next((m for m in markers if wording._key(m) == wording._key(x)), None)
|
||||
if mk is None or not brain.named_place(text, mk, markers):
|
||||
return None
|
||||
names.append(mk)
|
||||
|
||||
+38
-10
@@ -52,8 +52,14 @@ NAMED = [ # other markers on the map, as said / as whisper writes them -> the
|
||||
# English words of marker names as people say them in Korean: plain transliterations only, never a translation
|
||||
KO_SPOKEN = {"start": ["스타트"], "end": ["엔드"], "final": ["파이널", "화이널"], "middle": ["미들"], "home": ["홈"],
|
||||
"stage": ["스테이지"], "booth": ["부스"], "table": ["테이블"], "front": ["프론트", "프런트"],
|
||||
"init": ["이닛", "이니트"], "exit": ["엑시트", "엑싯"], "dock": ["도크"], "point": ["포인트"]}
|
||||
KO_NOT_ALONE = {"table", "point"} # "테이블에 놔" is the table, "포인트" a p-number: Korean form only inside a longer name
|
||||
"init": ["이닛", "이니트"], "exit": ["엑시트", "엑싯"], "dock": ["도크"], "point": ["포인트"],
|
||||
"coffee": ["커피"], "corner": ["코너"], "info": ["인포"], "desk": ["데스크"], "gate": ["게이트"],
|
||||
"hall": ["홀"], "zone": ["존"], "photo": ["포토"], "lounge": ["라운지"], "lobby": ["로비"], "room": ["룸"],
|
||||
"demo": ["데모"], "main": ["메인"], "cafe": ["카페"], "area": ["에어리어"], "center": ["센터"],
|
||||
"entrance": ["엔트런스"], "finish": ["피니시", "피니쉬"], "lab": ["랩"], "office": ["오피스"],
|
||||
"a": ["에이"], "b": ["비"], "c": ["씨"], "d": ["디"]} # letters only inside a longer name ("부스 에이")
|
||||
KO_NOT_ALONE = {"table", "point", "a", "b", "c", "d"} # "테이블에 놔" is the table, "포인트" a p-number, "비" rain:
|
||||
# the Korean form only inside a longer name
|
||||
NOT_SLIPS = {"point", "marker", "here", "there", "me", "home", "table", "left", "right", "back", "front", "it", "them"}
|
||||
CLOSE = 0.8 # difflib ratio for a whisper slip of a marker name ("stagee" -> stage)
|
||||
|
||||
@@ -190,7 +196,10 @@ def close_names(word, names):
|
||||
same digits ("booth3" is not booth_2, "p12" not p1). Several back: ask which one."""
|
||||
if len(_key(word)) < 3 or word in NOT_SLIPS:
|
||||
return []
|
||||
by = {_key(n): n for n in names if re.findall(r"\d+", n) == re.findall(r"\d+", word)}
|
||||
by = {_key(n): n for n in names if re.findall(r"\d+", n) == re.findall(r"\d+", word)
|
||||
and _key(n)[:1] == _key(word)[:1] and abs(len(_key(n)) - len(_key(word))) <= 1}
|
||||
# whisper keeps the first sound and the length: "send" is no
|
||||
# slip of "end", "stage" none of "storage"
|
||||
return [by[k] for k in difflib.get_close_matches(_key(word), by, n=3, cutoff=CLOSE)]
|
||||
|
||||
|
||||
@@ -202,18 +211,32 @@ def _spoken(name):
|
||||
for tok in toks:
|
||||
alts = [tok] + (KO_SPOKEN.get(tok, []) if len(toks) > 1 or tok not in KO_NOT_ALONE else [])
|
||||
if tok.isdigit():
|
||||
alts += [w for w, n in {**EN_NUM, **KO_EN_NUM}.items() if n == int(tok)]
|
||||
parts.append("(?:" + "|".join(sorted(map(re.escape, alts), key=len, reverse=True)) + ")")
|
||||
alts += [w for w, n in {**EN_NUM, **KO_EN_NUM, **(SINO if len(toks) > 1 else {})}.items() if n == int(tok)]
|
||||
# "부스 삼"; a lone "이" / "오" is a word, not 2 / 5
|
||||
alts = sorted(map(re.escape, alts), key=len, reverse=True)
|
||||
if re.fullmatch(r"[가-힣]{3,}", tok):
|
||||
alts.insert(0, r"\s?".join(tok)) # Korean words said or written apart: "커피 코너" for 커피코너
|
||||
parts.append("(?:" + "|".join(alts) + ")")
|
||||
return rf"(?<![a-z0-9_가-힣])" + r"[\s_.-]*".join(parts) + rf"(?![a-z0-9_])(?:(?<=[a-z0-9])|{_KO_END})"
|
||||
|
||||
|
||||
def written(name):
|
||||
"""A marker name as norm() writes it: one word, lower case ("Coffee Corner" -> "coffee_corner")."""
|
||||
return re.sub(r"\s+", "_", name.strip().lower())
|
||||
|
||||
|
||||
def marker(word, names):
|
||||
"""The marker of the map written as `word` in normalised text ("coffee_corner" -> "Coffee Corner"), or None."""
|
||||
return next((n for n in names if written(n) == word), None)
|
||||
|
||||
|
||||
def map_names(t, names):
|
||||
"""Marker names of this map in normalised text written as the names (lower case), then one-name slips after a
|
||||
"""Marker names of this map in normalised text written as the names (written()), then one-name slips after a
|
||||
place word ("to the stagee")."""
|
||||
names = [n for n in names if not re.fullmatch(r"p\d+", n.lower())] # p-numbers: markers() above
|
||||
for n in sorted(names, key=len, reverse=True):
|
||||
t = re.sub(_spoken(n), n.lower(), t)
|
||||
known = {n.lower() for n in names}
|
||||
t = re.sub(_spoken(n), written(n), t)
|
||||
known = {written(n) for n in names}
|
||||
|
||||
def slip(m):
|
||||
for w in (m.group(2).split()[0], m.group(2)): # one word, then two ("table fronts")
|
||||
@@ -221,7 +244,7 @@ def map_names(t, names):
|
||||
break
|
||||
close = close_names(w, names)
|
||||
if len(close) == 1:
|
||||
return m.group(1) + close[0].lower() + m.group(2)[len(w):]
|
||||
return m.group(1) + written(close[0]) + m.group(2)[len(w):]
|
||||
return m.group(0)
|
||||
return re.sub(r"(\b(?:to|from|at|toward|towards) (?:the )?)([a-z][a-z0-9_]*(?: [a-z0-9]+)?)", slip, t)
|
||||
|
||||
@@ -231,6 +254,10 @@ ASR_SLIPS = [ # how whisper writes Korean commands (tests/asr_check.py, 2026-1
|
||||
(r"(?<=로)\s*가죠(?![가-힣])", " 가 줘"), # "p3로 가 줘" written "p3로 가죠"
|
||||
(r"\blook (?:last|lest|less)(?=[\s.!,]*$)", "look left"), (r"\bdoc t\b", "dock 2"), # said at the end
|
||||
(r"고게(?=\s*(?:들|숙))", "고개"), (r"찝어", "집어"), (r"파이나(?=\s*(?:갔|가|로))", "파이널"),
|
||||
# the owner's English as whisper wrote it live (logs/lumi.log 2026-10-21 / 22)
|
||||
(r"\bcount to(?= p\s?\d)", "come to"), # "Let's count to p5."
|
||||
(r"\b(?:go )?(?:copy|pick) (\d+|one|two|three|four|five|six|seven|eight|nine|ten) point\b", r"go to p\1"),
|
||||
(r"\bfall(?:ow)? (?:lonely|of him)\b", "follow me"), # "Let's fall lonely.", "Let's fall of Him."
|
||||
]
|
||||
|
||||
|
||||
@@ -240,7 +267,8 @@ def norm(text, names=()):
|
||||
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()
|
||||
return re.sub(r"\s+", " ", markers(map_names(numbers(t), names))).strip() # the map's names first: "booth 3 point"
|
||||
# is booth_3, not "booth p3"
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user