Improve command, cup task and talk understanding in English and Korean

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-26 15:30:06 +09:00
co-authored by Claude Opus 5.5
parent e3a1c123c9
commit e3fcfd30ab
23 changed files with 1380 additions and 167 deletions
+26 -1
View File
@@ -211,6 +211,17 @@ _BANK = {
("What's the capital of Australia?", "none", "Canberra, not Sydney."), ("What's the capital of Australia?", "none", "Canberra, not Sydney."),
("Who's the president of France right now?", "search", "Let me check."), ("Who's the president of France right now?", "search", "Let me check."),
("What's the score of today's Dodgers game?", "search", "Let me check."), ("What's the score of today's Dodgers game?", "search", "Let me check."),
("how fast can a cheetah run?", "none", "Up to about 110 km/h, in short sprints."),
("Why so fast?", "none", "A light body, a very bendy spine and long legs make each stride huge."),
("A giraffe neck, how many bones it has?", "none", "Seven, the same as ours; each bone is just very long."),
("How long does a baby kangaroo stay in the pouch?", "none", "About six to eight months, then it hops out."),
("how much does a sloth sleep, like per day?", "none", "About 15 hours a day in the wild."),
("Namsan tower height is how much?", "none", "N Seoul Tower is about 236 metres; on the mountain top about 480 metres above the sea."),
("How quickly does a sunflower grow?", "none", "In good sun up to a few centimetres a day; it reaches two to three metres in a summer."),
("Can elephants really not jump?", "none", "Yes, they can't: their legs are built to carry weight, and one foot always stays on the ground."),
("Oh right, what's a hanok?", "none", "A traditional Korean house, with a tiled or thatched roof and floor heating."),
("Wait, what's the coldest place on Earth?", "none", "Antarctica; near Vostok station it once fell to about minus 89 °C."),
("What's the newest iPhone?", "search", "Let me check."),
], ],
"ko": [ "ko": [
("사람이 달에 처음 간 게 언제야?", "none", "1969년 7월, 아폴로 11호 때예요."), ("사람이 달에 처음 간 게 언제야?", "none", "1969년 7월, 아폴로 11호 때예요."),
@@ -230,7 +241,21 @@ _BANK = {
("에펠탑은 언제 세워지셨는지 여쭤봐도 될까요?", "none", "1889년 파리 만국박람회 때 완공됐어요."), ("에펠탑은 언제 세워지셨는지 여쭤봐도 될까요?", "none", "1889년 파리 만국박람회 때 완공됐어요."),
("호주 수도가 어디게?", "none", "캔버라예요. 시드니가 아니에요."), ("호주 수도가 어디게?", "none", "캔버라예요. 시드니가 아니에요."),
("지금 프랑스 대통령 누구야?", "search", "확인해 볼게요."), ("지금 프랑스 대통령 누구야?", "search", "확인해 볼게요."),
("오늘 야구 결과 어떻게 됐어요?", "search", "확인해 볼게요."), ("오늘 야구 몇 대 몇으로 끝났어요?", "search", "확인해 볼게요."),
("된장은 어떻게 만듭니까?", "none", "삶은 콩으로 메주를 쑤어 띄운 뒤 소금물에 담가 숙성시키고, 건더기를 건져 만듭니다."),
("김치 맛을 시게 만드는 건 뭐임?", "none", "유산균이에요. 익으면서 젖산을 만들어서 신맛이 나요."),
("치타는 을매나 빨리 뛰노?", "none", "짧게는 시속 110킬로미터쯤까지 달려요."),
("기린 목뼈 그거 몇 개야?", "none", "일곱 개예요. 사람이랑 같은데 하나하나가 아주 길어요."),
("캥거루 새끼는 주머니에 얼마나 있습니까?", "none", "약 6개월에서 8개월 동안 주머니에서 지냅니다."),
("나무늘보는 하루에 얼마나 자요?", "none", "야생에서는 하루에 15시간쯤 자요."),
("남산타워 height 몇 m예요?", "none", "N서울타워는 약 236미터이고, 산 위라서 해발로는 480미터쯤이에요."),
("해바라기는 얼마나 빨리 커?", "none", "햇빛이 좋으면 하루에 몇 센티미터씩, 여름 한철에 2~3미터까지 자라요."),
("코끼리가 점프를 못 한다는 게 참말이가?", "none", "네, 맞아요. 다리가 무게를 받치게 생겨서 항상 한 발은 땅에 있어요."),
("고래는 숨을 얼마나 참으실 수 있는지 여쭤봐도 될까요?", "none", "향유고래는 한 시간 넘게도 참을 수 있어요."),
("아 맞다, 판소리가 뭐야?", "none", "북 장단에 맞춰 한 사람이 노래와 말로 긴 이야기를 들려주는 우리 전통 음악이에요."),
("잠깐, 세상에서 제일 긴 강은?", "none", "나일강이에요. 약 6,650킬로미터예요."),
("그건 그렇고 정확히 몇 킬로?", "none", "약 6,650킬로미터예요. 아마존강과 비슷해서 재는 방법에 따라 달라요."),
("요즘 나온 갤럭시 최신 모델 뭐야?", "search", "확인해 볼게요."),
], ],
}, },
} }
+47
View File
@@ -0,0 +1,47 @@
"""Cup-task wordings for the intent bank (F1, night 4): fetch from a place said in every way ("the cup on p2",
"p2에 있는 컵", "피원 컵을", "move the cup from A to B", "옮겨"), at every Korean level; and "no": the same words
reported, asked about, put off or taken back (nothing moves). The words decide the fields (brain.parse_fetch)."""
_KO_FETCH = ["<place>에 있는 <obj> 가져와", "<place>에 있는 <obj> 좀 갖다 줘", "<place>에 놓인 <obj> 가져와",
"<place> <obj> 가져와", "<place>의 <obj> 가져다 줘", "<place> 위에 있는 <obj> 가져와",
"<place>에서 <obj> 집어서 가져와", "<place>에서 <obj> 들고 와", "<place>에 있는 <obj>을 여기로 가져와",
"<place>에서 <obj> 좀 챙겨 와", "<place>에 있는 <obj> 옮겨 와"]
_KO_END = [("가져와", ["가져와", "가져와요", "가져오세요", "가져오십시오", "가져와 주세요", "가져와 주시겠어요?",
"가져와 주시겠습니까?", "가져와 줄래?", "가져오게", "가져와 주게나", "가져온나", "가져와유",
"가져와 주이소", "가져와 주실 수 있으신가요?", "가져와 주시면 감사하겠습니다"]),
("갖다 줘", ["갖다 줘", "갖다 주세요", "갖다 주십시오", "갖다 주실래요?", "갖다 주게", "갖다 줘유",
"갖다 주이소", "갖다 주시겠어요?", "갖다 드려 주세요"]),
("가져다 줘", ["가져다 줘", "가져다 주세요", "가져다 주십시오", "가져다 주시겠습니까?", "가져다 주게나"]),
("들고 와", ["들고 와", "들고 와요", "들고 오세요", "들고 오십시오"]),
("챙겨 와", ["챙겨 와", "챙겨 와요", "챙겨 오세요"]),
("옮겨 와", ["옮겨 와", "옮겨 와 주세요", "옮겨 오십시오"])]
_EN_FETCH = ["bring me the <obj> on <place>", "get me the <obj> that's on <place>", "fetch the <obj> sitting at <place>",
"grab the <obj> at <place> and bring it here", "bring the <obj> over from <place>",
"<place> <obj>, bring it to me", "go to <place>, get the <obj> and bring it back to me",
"pick up the <obj> at <place> and bring it to me", "the <obj> on <place>, could you fetch it",
"move the <obj> from <place> over here", "carry the <obj> from <place> to me"]
_EN_FRAME = ["{}", "please {}", "could you {}", "would you mind, {}", "can you {} for me", "{} please", "lumi, {}",
"hey robot, {}", "excuse me, {}", "i need you to {}", "{} real quick", "do me a favour and {}"]
_NO = ["did you bring the <obj> from <place>?", "you brought the <obj> from <place> yesterday", "can you bring cups at all?",
"don't bring the <obj> from <place>", "i'll bring the <obj> from <place> myself", "tomorrow bring the <obj>",
"maybe later you can bring the <obj> from <place>", "my friend brought the <obj> from <place>",
"she asked whether you can fetch things", "bring me the <obj> from <place>, no wait, never mind",
"<place>에서 <obj> 가져왔어?", "어제 <obj> 가져왔지?", "<place>에서 <obj> 가져오지 마", "내가 <obj> 가져올게",
"나중에 <obj> 가져와 줘", "<obj> 가져올 수 있어?", "친구가 <place>에서 <obj> 가져왔대", "<obj> 가져오는 거 봤어",
"<place>에서 <obj> 가져와, 아 아니다 됐어", "<obj> 가져오시면 안 됩니다", "<obj> 가져다 주실 필요 없어요",
"할머니가 <obj> 가져오라고 하셨는데 괜찮아", "<obj> 가져오는 건 내일 해", "<place>에서 <obj> 가져다 줄 수 있나 궁금하네"]
def _ko():
"""Each wording with the endings of every level for its verb."""
out = []
for base in _KO_FETCH:
for verb, ends in _KO_END:
if base.endswith(verb):
out += [f"{base[:-len(verb)].rstrip()} {e}" for e in ends]
return out
INTENT = {"fetch": sorted(set(_ko() + [f.format(c) for c in _EN_FETCH for f in _EN_FRAME])), "no": _NO}
+24
View File
@@ -227,3 +227,27 @@ QUICK["no"] = QUICK.get("no", []) + [
"시간 괜찮아요", "시간 돼요", "give me a second", "give me a minute", "give me some time", "do you have time", "시간 괜찮아요", "시간 돼요", "give me a second", "give me a minute", "give me some time", "do you have time",
"이름 지어 줄까", "내 이름은 민수야", "제 이름 기억해요", "우리 애 몇 살 같아요", "제가 몇 살 같아요", "나 몇 살로 보여", "이름 지어 줄까", "내 이름은 민수야", "제 이름 기억해요", "우리 애 몇 살 같아요", "제가 몇 살 같아요", "나 몇 살로 보여",
"누가 이겼어", "누가 더 빨라", "몇 시에 끝나요", "몇 시에 시작해요"] "누가 이겼어", "누가 더 빨라", "몇 시에 끝나요", "몇 시에 시작해요"]
# ---------- night 4: Konglish verbs and short dialect forms ko_plain does not turn into the plain verb ----------
INTENT["pick"] += _v(["<obj> 그랩 해", "<obj> 그랩", "<obj> 픽 해", "<obj> 픽업해", "<obj> 캐치 해", "<obj> 홀드 해",
"<obj> 잡아 봐라", "<obj> 집어 도", "<obj> 쫌 집어"], ("", " 줘"))
INTENT["fetch"] += _v(["<obj> 겟 해 와", "<obj> 겟해 와", "<obj> 브링 해", "<obj> 가져와 봐라", "<obj> 갖고 온나",
"<obj> 퍼뜩 가져와", "<obj> 쫌 갖다 도", "나한테 <obj> 브링"], ("", " 줘"))
INTENT["follow"] += _v(["팔로우 해", "나 팔로우", "날 팔로우", "come with 나", "나랑 같이 가", "같이 가자 루미",
"내 뒤로 붙어", "졸졸 따라 댕겨", "따라 온나"], ("", " 줘"))
INTENT["come"] += _v(["컴 히어", "컴온 히어", "이리로 컴", "여기로 컴", "가까이 컴", "이리 온나", "일로 온나", "이리 오이라"],
("", " 해", " 해 줘"))
INTENT["wave"] += _v(["웨이브 해", "하이 해", "바이바이 해", "빠이빠이 해", "손 인사 해", "손으로 인사 해", "핸드 웨이브 해",
"손 흔들어 봐라", "손 쫌 흔들어"], ("", " 줘", " 봐"))
INTENT["arm_reach"] += _v(["손 줘라", "핸드 줘", "암 내밀어", "핸드 아웃 해", "손 쭉 내밀어 봐라", "팔 뻗어 봐라",
"손 이리 도", "손 쫌 도"], ("", " 줘"))
INTENT["arm_fold"] += _v(["암 다운 해", "암 폴드 해", "arm fold 해", "팔 원위치 해", "팔 집어넣어", "손 거둬 들여",
"팔 접어 봐라"], ("", " 줘"))
INTENT["look"] += _v(["룩 업 해", "룩 다운 해", "업 봐", "다운 봐", "레프트 봐", "라이트 봐", "위로 룩", "아래로 룩",
"고개 쫌 들어", "고개 쫌 숙여", "고개 들어 봐라", "고개 숙여 봐라"], ("", " 줘"))
INTENT["lift"] += _v(["바디 업", "바디 다운", "키 업", "키 다운", "몸 업", "몸 다운", "몸 쫌 올려", "몸 쫌 내려",
"키 쫌 키워", "키 쫌 줄여"], ("", " 해", " 해 줘"))
INTENT["turn"] += _v(["턴 해", "레프트 턴", "라이트 턴", "라이트로 턴", "레프트로 턴", "백 턴", "유턴 쫌", "한 바퀴 턴",
"왼쪽으로 돌아 봐라", "오른쪽으로 돌아 봐라"], ("", " 해", " 해 줘"))
INTENT["move"] += _v(["무브 포워드", "고 백", "백 해", "앞으로 무브", "뒤로 무브", "레프트로 무브", "라이트로 무브",
"앞으로 쪼매 가 봐라", "뒤로 쫌 빠져"], ("", " 줘"))
+363 -82
View File
File diff suppressed because it is too large Load Diff
+39 -1
View File
@@ -29,13 +29,15 @@ FETCHING = re.compile(r"\b(?:bring|fetch|deliver|carry)\b|가져|갖다", re.I)
_FILL = re.compile(rf"(?:{steps._FILL}|루미야?|lumi|hey|do me a favou?r|부탁(?:해|해요|할게)?|dear|sir|ma'?am|madam|buddy|" _FILL = re.compile(rf"(?:{steps._FILL}|루미야?|lumi|hey|do me a favou?r|부탁(?:해|해요|할게)?|dear|sir|ma'?am|madam|buddy|"
r"my friend|robot|로봇아?|선생님?|yo|bro|dude|okay lumi|ok lumi|robot please|루미 ?씨|로봇 양반|여보세요|" r"my friend|robot|로봇아?|선생님?|yo|bro|dude|okay lumi|ok lumi|robot please|루미 ?씨|로봇 양반|여보세요|"
r"go ahead|okay\?|ok\?|right\?|thanks|thank you|yes|yeah|yep|yes\?|네|응|그래|will ya|will you|won'?t you|" r"go ahead|okay\?|ok\?|right\?|thanks|thank you|yes|yeah|yep|yes\?|네|응|그래|will ya|will you|won'?t you|"
r"can\?|can|do it|do it now|just do it|alright\?|please\?|혹시|아 뭐라 그래야 되지|뭐라 그래야 되지|뭐더라|" r"can\?|can|do it|do it now|just do it|alright\?|please\?|over here\??|this way\??|어디 ?한번|어디 ?보자|얼마나 걸리나|(?:pls |please )?(?:eh|huh|da|see|ya|yah|innit)\??|혹시|아 뭐라 그래야 되지|뭐라 그래야 되지|뭐더라|"
r"(?:아\s*)?영어로 ?뭐더라|(?:아\s*)?뭐라고 ?하지|" r"(?:아\s*)?영어로 ?뭐더라|(?:아\s*)?뭐라고 ?하지|"
r"(?:거기서?\s*)?(?:서|가만히)\s*있(?:어|게|으세요|으십시오)\s*(?:줄래|줄 ?수 ?있어요?|주실래요|주세요|줘|줘잉|주라|" r"(?:거기서?\s*)?(?:서|가만히)\s*있(?:어|게|으세요|으십시오)\s*(?:줄래|줄 ?수 ?있어요?|주실래요|주세요|줘|줘잉|주라|"
r"주면 ?안 ?될까요?|주면 ?좋겠어요?|주실 ?수 ?있어요?|주십시오|주이소)?|" r"주면 ?안 ?될까요?|주면 ?좋겠어요?|주실 ?수 ?있어요?|주십시오|주이소)?|"
r"(?:거기서?\s*)?기다려\s*(?:줄래|주세요|줘)?)", re.I) # tags, hesitations, "...가서 서 있어 줄래?" r"(?:거기서?\s*)?기다려\s*(?:줄래|주세요|줘)?)", re.I) # tags, hesitations, "...가서 서 있어 줄래?"
RELATIVE = re.compile(r"^\W*(?:where|which|who|that|when)\s+(?:the|my|your|his|her|our|their|a|an|this|that|these|those|" RELATIVE = re.compile(r"^\W*(?:where|which|who|that|when)\s+(?:the|my|your|his|her|our|their|a|an|this|that|these|those|"
r"people|everyone|it|he|she|they|we|i)\b", re.I) # "look right, where the door is": no question r"people|everyone|it|he|she|they|we|i)\b", re.I) # "look right, where the door is": no question
SPEED_Q = re.compile(r"속도|몇으로|얼마나 (?:빨리|빠르게|천천히)|\bhow (?:fast|quick(?:ly)?|slow(?:ly)?)\b|\bwhat speed\b", re.I)
GREET = re.compile(r"인사|작별|\b(?:hello|hi|goodbye|bye)\b", re.I) # a greeting made by waving
PAST = re.compile(r"\byou (?:got|went|were|did|turned|looked|moved|came|said|told)\b|\b(?:earlier|before|yesterday)\b", re.I) PAST = re.compile(r"\byou (?:got|went|were|did|turned|looked|moved|came|said|told)\b|\b(?:earlier|before|yesterday)\b", re.I)
BANK_KINDS = {"look", "lift", "turn", "move", "come", "come_back", "follow", "wave", "arm", "go_to"} # a part the BANK_KINDS = {"look", "lift", "turn", "move", "come", "come_back", "follow", "wave", "arm", "go_to"} # a part the
# keyword rules miss, read by the intent bank (same slot rules) # keyword rules miss, read by the intent bank (same slot rules)
@@ -43,6 +45,22 @@ CHAIN_ONLY = {"look", "lift", "wave", "come", "come_back", "follow"} # a part
# a sentence the mission reader reads whole is still a chain # a sentence the mission reader reads whole is still a chain
BACKGROUND = re.compile(r"[가-힣](?:는|은|인|던)(?:데|디)(?:요)?\W*$") # "…말하는데," a clause that only sets the scene
SELF_PROMISE = re.compile(r"(?:^|\W)(?:i'?ll|i will|let me|i'?m going to|i can) (?:hold|take|keep|get|catch|grab) (?:it|that|this|them)\W*$|"
r"(?:^|\W)(?:내가|제가) (?:들|받|잡)(?:게|을게|을게요|게요|을께)\W*$", re.I) # the speaker's part
def _restated(words, before):
"""A Korean part that says the order before it again in another level ("손 거둬!", "아 거두시겠어요?")."""
from assistant import wording
said = [w for w in re.findall(r"\w+", wording.ko_plain(words)) if not re.fullmatch(r"(?:줘|봐|주|좀|요)[가-힣]?|허허|하하|호호|헤헤|아|어", w)]
if not said or len(said) > 3 or not re.fullmatch(r"[가-힣]{2,}|[가와]", said[-1]):
return False
last = said[-1]
return any(last == w or len(w) > 1 and (w.startswith(last) or last.startswith(w))
for w in re.findall(r"\w+", wording.ko_plain(before)) if re.fullmatch(r"[가-힣]+", w))
def _rule(words, markers): def _rule(words, markers):
"""brain.intent of a part, also of a Korean -고 form ("나 보고" read as "나 봐").""" """brain.intent of a part, also of a Korean -고 form ("나 보고" read as "나 봐")."""
rule = brain.intent(words, markers) rule = brain.intent(words, markers)
@@ -57,6 +75,8 @@ def _rule(words, markers):
from assistant import intent_bank # "glance to your right", "고개 숙이고": the bank, by meaning from assistant import intent_bank # "glance to your right", "고개 숙이고": the bank, by meaning
got = intent_bank.read(ko, markers) got = intent_bank.read(ko, markers)
rule = got if got and got[0] in BANK_KINDS else None rule = got if got and got[0] in BANK_KINDS else None
if rule and rule[0] == "come_back" and re.fullmatch(r"\W*(?:루미야?\s*)?(?:원래 ?자리|제자리)(?:에|로)?\W*", words):
rule = None # "제자리에, 손 내밀어": "ready", no drive back
return rule return rule
@@ -69,6 +89,9 @@ def parts(text):
for p in _SPLIT.split(cut): for p in _SPLIT.split(cut):
out += [q for q in steps._SPLIT_KO.split(p) if q.strip()] out += [q for q in steps._SPLIT_KO.split(p) if q.strip()]
out = [re.sub(r"§(\d+)§", lambda m: f'"{says[int(m.group(1))]}"', p).strip(" ,.!") for p in out] out = [re.sub(r"§(\d+)§", lambda m: f'"{says[int(m.group(1))]}"', p).strip(" ,.!") for p in out]
for i in range(len(out) - 1, 0, -1): # "뒤로 물러서 줘": 서 is the verb's, 줘 no part of its own
if re.fullmatch(r"(?:줘|줘요|주세요|주십시오|줄래요?\??|주실래요?\??|주라|주게|주이소|봐|봐요|보세요)\W*", out[i]):
out[i - 1] += " " + out.pop(i)
return [p for p in out if p and not re.fullmatch(rf"(?:{_FILL.pattern}|\W)+", p, re.I)] return [p for p in out if p and not re.fullmatch(rf"(?:{_FILL.pattern}|\W)+", p, re.I)]
@@ -90,6 +113,8 @@ def plan(text, markers=(), cant=None):
return None # "turn around and look": the head looks behind return None # "turn around and look": the head looks behind
out = [] out = []
for p in ps: for p in ps:
if SELF_PROMISE.search(p) or out and _restated(p, out[-1][1]) or brain.GREET_ONLY.match(p): # "hello robot, …"
continue # "흰색 머그컵 잡아!, 아 잡아 줄 수 있어요?": the order once
got, unread = steps.rules(p, markers) got, unread = steps.rules(p, markers)
rule = _rule(p, markers) rule = _rule(p, markers)
if got and not unread and not (rule and rule[0] in ("look", "lift", "wave", "come", "come_back", "follow")): if got and not unread and not (rule and rule[0] in ("look", "lift", "wave", "come", "come_back", "follow")):
@@ -100,6 +125,13 @@ def plan(text, markers=(), cant=None):
out.append(["quick", p, rule]) out.append(["quick", p, rule])
elif RELATIVE.search(p): elif RELATIVE.search(p):
return None # a part that tells more about the one before return None # a part that tells more about the one before
elif BACKGROUND.search(p):
continue # "이장이 말하는디, 팔 제자리로 해", "I'll hold it, give it here"
elif out and out[-1][0] in ("quick", "steps") and _restated(p, out[-1][1]):
continue # "손 거둬!, 아 거두시겠어요?": the same order again, politely
elif out and out[-1][0] == "quick" and out[-1][2][0] == "wave" and re.search(r"(?:면서|며|서)\W*$", out[-1][1]) and \
GREET.search(p) and not rule:
continue # "손 흔들면서 인사하고 고개 숙여": the wave is the greeting
elif ASK.search(p) or rule and rule[0] in ("weather", "search") or cant is not None and cant.match(p): elif ASK.search(p) or rule and rule[0] in ("weather", "search") or cant is not None and cant.match(p):
out.append(["talk", p, None]) out.append(["talk", p, None])
else: else:
@@ -112,6 +144,12 @@ def plan(text, markers=(), cant=None):
said[i] and said[i] == said[i - 1]))] said[i] and said[i] == said[i - 1]))]
if len(out) < 2: if len(out) < 2:
return None # "wave, wave, wave!": one wave, said with feeling return None # "wave, wave, wave!": one wave, said with feeling
if any(k == "talk" and SPEED_Q.search(p) and i and re.search(r"고$|\b(?:holding|carrying|with)\b", out[i - 1][1], re.I)
for i, (k, p, _) in enumerate(out)):
return None # "컵 들고 몇으로 가?": how fast it goes so, no order
if any(k == "quick" and w[0] == "wave" and re.search(r"(?<!가)서$", p) and i + 1 < len(out) and
GREET.search(out[i + 1][1]) for i, (k, p, w) in enumerate(out)):
return None # "손 흔들어서 작별 인사 해 줘": the wave is the greeting
kinds = [k for k, _, _ in out] kinds = [k for k, _, _ in out]
if "talk" not in kinds and "quick" not in kinds or "steps" not in kinds and "quick" not in kinds: if "talk" not in kinds and "quick" not in kinds or "steps" not in kinds and "quick" not in kinds:
return None # all steps: a mission (read back); all talk: the LLM return None # all steps: a mission (read back); all talk: the LLM
+4
View File
@@ -113,6 +113,10 @@ def read(text, markers=(), goal=None):
ends = [m.end() for r in (_BACK_UP_RE, _AROUND, _BACK, _RETRY) for m in r.finditer(t)] ends = [m.end() for r in (_BACK_UP_RE, _AROUND, _BACK, _RETRY) for m in r.finditer(t)]
if not ends or _NOT_ORDER.search(t): if not ends or _NOT_ORDER.search(t):
return None return None
if brain.to_someone_else(text) or brain.held_back(re.sub(r"(?:포기하|멈추|그만두)지 ?마\w*|\bdon.?t (?:give up|stop)\b", " ", text)) or brain.ARM_TALK.search(text) or \
re.search(r"(?:라고|자고|하라고|가라고) ?(?:했|하더|그러)|(?:나|니|까|냐|어)\s+(?![루누]미|로봇)[가-힣]{2}(?:아|야)\s*\?\s*$|봤(?:냐|니|어요?|나요)\s*\?|(?<![가-힣])아까(?![가-힣])|\b(?:also|too)\W*$", text):
return None # "아까 저 아저씨가 다시 가라고 했어", "재시도해부러" said after "-믄", "Maria, you go back",
# "다른 길 있나 민수야?" (asked to Minsu), "여러분, 돌아와 보세요"
if _TAKEN_BACK.search(t, max(ends)) or _FIXED.search(t, max(ends)): if _TAKEN_BACK.search(t, max(ends)) or _FIXED.search(t, max(ends)):
return None # "try again. never mind", "go around— no, not need" return None # "try again. never mind", "go around— no, not need"
fixed = list(_FIXED.finditer(t)) fixed = list(_FIXED.finditer(t))
+10 -6
View File
@@ -24,13 +24,13 @@ SPAN_M = 0.2 # m; "한 뼘", one hand span; estimate
STEP_M = 0.5 # m; one step ("two steps", "한 걸음", "반 걸음"); estimate of a person's step STEP_M = 0.5 # m; one step ("two steps", "한 걸음", "반 걸음"); estimate of a person's step
TURN_MORE_DEG = 15.0 # deg; "a bit more" right after a turn: this much further the same way TURN_MORE_DEG = 15.0 # deg; "a bit more" right after a turn: this much further the same way
DIRS = (("back", r"\bback(?:wards?)?\b(?! down\b)|\bbackward\b|\breverse\b|^(?:let'?s )?(?:bake|big)\b(?= \d| half| a )|뒤로|뒤쪽|후진|" DIRS = (("back", r"\bback(?:wards?)?\b(?! down\b)|\bbackward\b|\breverse\b|\bretreat\b|^(?:let'?s )?(?:bake|big)\b(?= \d| half| a )|뒤로|뒤쪽|후진|"
r"물러"), # whisper's "let's bake / big one meter" r"물러"), # whisper's "let's bake / big one meter"
("forward", r"\bforwards?\b|\bahead\b|앞으로|앞쪽|전진"), ("forward", r"\bforwards?\b|\bahead\b|앞으로|앞쪽|전진"),
("left", r"\b(?:to the |to your )?left\b|왼쪽|왼편|웬쪽|좌측"), ("left", r"\b(?:to the |to your )?left\b|왼 ?쪽|왼편|웬쪽|좌측"),
("right", r"(?<!all )\b(?:to the |to your )?right\b(?! now| away| here| there| back)|오른쪽|오른편|우측")) ("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|" VERB = re.compile(r"\b(?:move|go|come|drive|step|scoot|scooch|shift|inch|roll|back (?:up|off)|reverse|get)\b|"
r"가|와|이동|움직|물러|빠져|후진|전진|비켜") r"(?<![신인는])가|와|이동|움직|물러|빠져|후진|전진|비켜") # not "…있으신가요?"
NEAR_THING = re.compile(r"(?:테이블|책상|탁자|의자|소파|문|벽|창문)\s*(?:앞|옆|뒤)|" NEAR_THING = re.compile(r"(?:테이블|책상|탁자|의자|소파|문|벽|창문)\s*(?:앞|옆|뒤)|"
r"(?<![가-힣])(?!(?:루미야?|조금만?|살짝|다시|그냥|이제|저기요?|여기|거기|약간|천천히|빨리|얼른|어서|그럼|근데|" r"(?<![가-힣])(?!(?:루미야?|조금만?|살짝|다시|그냥|이제|저기요?|여기|거기|약간|천천히|빨리|얼른|어서|그럼|근데|"
r"그리고|좀|더|한|두|세|반|쭉|바로|똑바로|계속|한번|한 번|일단|먼저|자|아주|많이|쪼끔|쬐끔|요만큼|뼘|걸음|발짝|발자국|미터|센티|센치|밀리)만?(?:\s|$))(?:[가-힣][가-힣_]{0,9}|(?<![a-z0-9_.])(?!(?:m|cm|mm|lumi|loomi|rumi|hey|ok|okay|please)\b)[a-z][a-z0-9_]*)\s*" r"그리고|좀|더|한|두|세|반|쭉|바로|똑바로|계속|한번|한 번|일단|먼저|자|아주|많이|쪼끔|쬐끔|요만큼|뼘|걸음|발짝|발자국|미터|센티|센치|밀리)만?(?:\s|$))(?:[가-힣][가-힣_]{0,9}|(?<![a-z0-9_.])(?!(?:m|cm|mm|lumi|loomi|rumi|hey|ok|okay|please)\b)[a-z][a-z0-9_]*)\s*"
@@ -52,12 +52,13 @@ SPANS = re.compile(rf"(?:(?<![\w.]){_COUNT}\s*)?뼘")
TINY = re.compile(r"\b(?:tiny|teeny|wee|hair|hairs?breadth|smidge|smidgen|tad|touch|nudge|slightly|little tiny)\b|" TINY = re.compile(r"\b(?:tiny|teeny|wee|hair|hairs?breadth|smidge|smidgen|tad|touch|nudge|slightly|little tiny)\b|"
r"\bfew (?:centimet(?:er|re)s|cm)\b|\binch (?:forward|back|left|right|ahead)|" r"\bfew (?:centimet(?:er|re)s|cm)\b|\binch (?:forward|back|left|right|ahead)|"
r"살짝|아주 조금|쪼끔|쬐끔|약간|요만큼|조금만 살짝") r"살짝|아주 조금|쪼끔|쬐끔|약간|요만큼|조금만 살짝")
LITTLE = re.compile(r"\b(?:a little|a bit|little bit|bit)\b|조금|쪼금") # "좀" is "please" as often as "a bit" LITTLE = re.compile(r"\b(?:a little|a bit|little bit|bit)\b|조금|쪼금|쪼매|쫌만") # "좀" is "please" as often as "a bit"
VAGUE = re.compile(r"\b(?:more|less|longer|further|farther|bit more|bit less) than\b|(?:^|\s)몇\s*(?:미터|센티|m\b|걸음)|\bsome (?:meters?|metres?)\b|\bto (?:m|meters?|metres?)\b|" VAGUE = re.compile(r"\b(?:more|less|longer|further|farther|bit more|bit less) than\b|(?:^|\s)몇\s*(?:미터|센티|m\b|걸음)|\bsome (?:meters?|metres?)\b|\bto (?:m|meters?|metres?)\b|"
r"\b(?:some|like|uh|um)\s*$|(?<![가-힣])[이삼사오육칠팔구]?[십백][일이삼사오육칠팔구]?\s*(?:만\s*)?" r"\b(?:some|like|uh|um)\s*$|(?<![가-힣])[이삼사오육칠팔구]?[십백][일이삼사오육칠팔구]?\s*(?:만\s*)?"
r"(?:가|와|이동|움직|후진|전진)") # an amount half said: asked, never a guess r"(?:가|와|이동|움직|후진|전진)") # an amount half said: asked, never a guess
NUM_WORD = re.compile(r"\b(?:eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|" NUM_WORD = re.compile(r"\b(?:eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|"
r"thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|dozen|couple|several|few|half)\b") r"thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|dozen|couple|several|few|half)\b")
UNIT_WORD = re.compile(r"미터|센티|센치|밀리|(?<![a-z])(?:cm|mm|meters?|metres?|centimet(?:er|re)s?|millimet(?:er|re)s?)(?![a-z])")
KO_NUM_WORD = re.compile(r"(?<![가-힣])(?:하나|둘|셋|넷|다섯|여섯|일곱|여덟|아홉|열|스물|서른|마흔|쉰)(?:만|쯤|정도)?(?![가-힣])") KO_NUM_WORD = re.compile(r"(?<![가-힣])(?:하나|둘|셋|넷|다섯|여섯|일곱|여덟|아홉|열|스물|서른|마흔|쉰)(?:만|쯤|정도)?(?![가-힣])")
# "앞으로 다섯만 가": a count with no unit, asked # "앞으로 다섯만 가": a count with no unit, asked
KO_COUNT = re.compile(KO_NUM_WORD.pattern + r"|(?<![가-힣])[이삼사오육칠팔구]?[십백][일이삼사오육칠팔구]?(?:만|쯤|정도)?(?![가-힣])|" KO_COUNT = re.compile(KO_NUM_WORD.pattern + r"|(?<![가-힣])[이삼사오육칠팔구]?[십백][일이삼사오육칠팔구]?(?:만|쯤|정도)?(?![가-힣])|"
@@ -122,6 +123,9 @@ def amount(t):
return 0.25, True # "a quarter of a meter" return 0.25, True # "a quarter of a meter"
if VAGUE.search(t): if VAGUE.search(t):
return "?", False # "more than a meter", "to meters" (two?), "move back some" return "?", False # "more than a meter", "to meters" (two?), "move back some"
m = re.search(r"(?<![\w.])(\d+) ?m ?([1-9]0)(?:만|쯤|정도)?(?![\d.]|\s*(?:m|cm|mm|센|밀|도|times|번)(?![a-z]))", t)
if m:
return int(m.group(1)) + int(m.group(2)) / 100, True # "1미터 50": 1.5 m
m = re.search(r"(?<![\w.])(\d+(?:\.\d+)?) m(?![a-z])", t) m = re.search(r"(?<![\w.])(\d+(?:\.\d+)?) m(?![a-z])", t)
if m: if m:
return float(m.group(1)), True return float(m.group(1)), True
@@ -135,7 +139,7 @@ def amount(t):
if m and not re.search(r"\b(?:few|couple|several|some)\b", t): if m and not re.search(r"\b(?:few|couple|several|some)\b", t):
n = m.group(1) n = m.group(1)
return (float(n) if n and n[0].isdigit() else _NATIVE.get(n, 1)) * unit, False return (float(n) if n and n[0].isdigit() else _NATIVE.get(n, 1)) * unit, False
if re.search(r"(?<![a-z\d.])\d", t) or NUM_WORD.search(t) or KO_NUM_WORD.search(t): if re.search(r"(?<![a-z\d.])\d", t) or NUM_WORD.search(t) or KO_NUM_WORD.search(t) or UNIT_WORD.search(t):
return "?", False # "move back 20", "two feet", "a couple of metres", return "?", False # "move back 20", "two feet", "a couple of metres",
# "오른쪽으로30가게" # "오른쪽으로30가게"
if LITTLE.search(t): if LITTLE.search(t):
+60 -13
View File
@@ -34,18 +34,18 @@ FILLS = 3 # place / object fills made of each template (the same e
# ---------- guards: words the bank never reads ---------- # ---------- 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|forget it|" NEGATION = re.compile(r"\b(?:don'?t|do not|never|no need|not now|no more|stop \w+ing|quit \w+ing|without|forget it|"
r"never ?mind|scratch that|cancel that)\b|취소|아니다|됐다|" r"never ?mind|scratch that|cancel that)\b|취소|아니다|됐다|"
r"[가-힣]지 ?마(?:세요|요|라|십시오)?(?![가-힣])|하지 ?말|말고|[가-힣]지 ?(?:말아|말라|마시|마셔|말게)|필요 ?없|안 ?(?:해|돼|가|와)(?:도)?\b|그만", re.I) r"[가-힣]지 ?마(?:세요|요|라|십시오|쇼|소|이소|시오|셔)?(?:잉|요)?(?![가-힣])|하지 ?말|말고|[가-힣]지 ?(?:말아|말라|마시|마셔|말게)|필요 ?없|안 ?(?:해|돼|가|와)(?:도)?\b|그만", re.I)
LATER = re.compile(r"\b(?:when|whenever|if|unless|after|before|once|until|till|as soon as|later|tomorrow|tonight|" LATER = re.compile(r"\b(?:when|whenever|if|unless|after|before|once|until|till|as soon as|later|tomorrow|tonight|"
r"next time|in (?:\w+ ){0,2}(?:minute|hour|second|min|sec)s?|in a (?:while|bit)|soon)\b|분 ?(?:뒤|후|있다)|" r"next time|some ?day|one day|in (?:\w+ ){0,2}(?:minute|hour|second|min|sec)s?|in a (?:while|bit)|soon)\b|분 ?(?:뒤|후|있다)|"
r"[가-힣](?<![정화측반전표라장내외평단그러])면(?:\s|$)|(?:하|으|오|가|되|끝나|있으|오시)면|나중에|이따|내일|" r"[가-힣](?<![정화측반전표라장내외평단그러])면(?:\s|$)|(?:하|으|오|가|되|끝나|있으|오시)면|나중에|이따|내일|"
r"다음에|있다가|(?:^|\s)(?:후|뒤|전)에(?![서가-힣])|때(?:에)?\s|다음 ?(?:주|달|번|시간)에?|" r"다음에|있다가|(?:^|\s)(?:후|뒤|전)에(?![서가-힣])|때(?:에)?\s|다음 ?(?:주|달|번|시간)에?|"
r"(?:^|\s)(?:\d{1,2}|한|두|세|네|다섯|여섯|일곱|여덟|아홉|열|열한|열두) ?시(?:에|쯤|까지)|" r"(?:^|\s)(?:\d{1,2}|한|두|세|네|다섯|여섯|일곱|여덟|아홉|열|열한|열두) ?시(?:에|쯤|까지)|"
r"\b(?:next (?:week|month|year|monday|tuesday|wednesday|thursday|friday|saturday|sunday)|" r"\b(?:next (?:week|month|year|monday|tuesday|wednesday|thursday|friday|saturday|sunday)|"
r"at (?:\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)(?::\d\d)? ?(?:o'?clock|pm|am|p\.m\.|a\.m\.))", re.I) r"at (?:\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)(?::\d\d)? ?(?:o'?clock|pm|am|p\.m\.|a\.m\.))", 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|" ABILITY = re.compile(r"\b(?:are you able|able to|know how|i heard you can|heard (?:that )?you can|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"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"\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|기능|\bfunction\b|\bfeature\b|보여 ?(?:줄|주실|주세요|줘)|할 ?줄|줄 ?알|(?<!줄 )(?<!주실 )(?<!주 )(?<!줄)(?<!주실)수 ?있(?:어|어요|니|나요|습니까|을까)\s*\??$|가능해|가능한가|가능하", re.I) r"\bshow me (?:you can|how)\b|기능|\bfunction\b|\bfeature\b|줄 ?(?:은|도)? ?(?:알|아|압|안)|보여 ?(?:줄|주실|주세요|줘)|할 ?줄|줄 ?알|(?<!줄 )(?<!주실 )(?<!주 )(?<!줄)(?<!주실)수 ?있(?:어|어요|니|나요|습니까|을까)\s*\??$|가능해|가능한가|가능하", re.I)
WONDER = re.compile(r"\bi wonder\b|\bwonder(?:ing)? (?:if|whether|how)\b|\bi bet\b|\b(?:i )?guess (?:it|the robot)\b|" WONDER = re.compile(r"\bi wonder\b|\bwonder(?:ing)? (?:if|whether|how)\b|\bi bet\b|\b(?:i )?guess (?:it|the robot)\b|"
r"\b(?:can|could|does|did|will|would|is|was) (?:it|this|that|the robot|this robot|that robot|he|she|this thing)\b|" r"\b(?:can|could|does|did|will|would|is|was) (?:it|this|that|the robot|this robot|that robot|he|she|this thing)\b|"
r"\b(?:it|the robot|this robot|this thing) (?:can|could|does|will|is able)\b|\bcan it\b|" r"\b(?:it|the robot|this robot|this thing) (?:can|could|does|will|is able)\b|\bcan it\b|"
@@ -56,7 +56,7 @@ WONDER = re.compile(r"\bi wonder\b|\bwonder(?:ing)? (?:if|whether|how)\b|\bi bet
# "can it wave? I wonder", "does it follow people?", "이거 손 흔들 수 있나?", "얘 따라오나 봐" # "can it wave? I wonder", "does it follow people?", "이거 손 흔들 수 있나?", "얘 따라오나 봐"
NOT_TO_LUMI = re.compile( NOT_TO_LUMI = re.compile(
r"\bshall we\b|\bwe(?:'re| are) (?:heading|going|off|gonna)\b|\bwe (?:should|could|can|will|might|must|need to)\b|\bwe'll\b|" r"\bshall we\b|\bwe(?:'re| are) (?:heading|going|off|gonna)\b|\bwe (?:should|could|can|will|might|must|need to)\b|\bwe'll\b|"
r"\byou and (?:i|me)\b|\bmy plan\b|\bour plan\b|우리(?!.*악수).*(?:자|까|래|기로)\s*[??.!~]*$|" # plans between people r"\byou and (?:i|me)\b|\bmy plan\b|\bour plan\b|우리끼리|우리(?!.*악수).*(?:자|까|래|기로)\s*[??.!~]*$|" # plans between people
r"\bimagine\b|\bsuppose\b|\bwhat if\b|\bwould you ever\b|\bif you were\b|\bpretend\b|\bhypothetical|" r"\bimagine\b|\bsuppose\b|\bwhat if\b|\bwould you ever\b|\bif you were\b|\bpretend\b|\bhypothetical|"
r"만약|[가-힣](?:라면|다면)|어떨까|겠다\s*[!.~]*$|" # hypotheticals r"만약|[가-힣](?:라면|다면)|어떨까|겠다\s*[!.~]*$|" # hypotheticals
r"\battention\b|\bladies and gentlemen\b|\b(?:visitors|guests|attendees|passengers)(?: are)? (?:please|should|must|may|" r"\battention\b|\bladies and gentlemen\b|\b(?:visitors|guests|attendees|passengers)(?: are)? (?:please|should|must|may|"
@@ -70,6 +70,8 @@ QUESTION = re.compile(r"^\W*(?:(?:hey|so|um+|uh+|lumi|okay|ok)\W+)*(?:what|where
r"어디|뭐|무엇|왜|언제|누구|어떻게|몇|어느|무슨|어떤|얼마|[가-힣]까\s*[??]+\s*$|봤(?:어|니|나|냐|어요|습니까)|본 ?적|" r"어디|뭐|무엇|왜|언제|누구|어떻게|몇|어느|무슨|어떤|얼마|[가-힣]까\s*[??]+\s*$|봤(?:어|니|나|냐|어요|습니까)|본 ?적|"
r"\bhave you (?:been|gone|ever)\b|(?:어|아|해|여)도 ?(?:돼|되|될까|괜찮)|" r"\bhave you (?:been|gone|ever)\b|(?:어|아|해|여)도 ?(?:돼|되|될까|괜찮)|"
r"알려 ?(?:줘|주|줄)|설명해|가르쳐|말해 ?(?:줘|봐|주)|\btell me\b|\bexplain\b|\bdescribe\b|" r"알려 ?(?:줘|주|줄)|설명해|가르쳐|말해 ?(?:줘|봐|주)|\btell me\b|\bexplain\b|\bdescribe\b|"
r"상태(?:야|예요|에요|니|냐|입니까|인가요)?\s*\??\s*$|(?:open|오픈|열림|닫힘)(?:이야|이에요|이니|인가요|입니까)|"
r"\b(?:is|are) (?:your|the) (?:hand|gripper|fingers?|arm|head)s? (?:open|closed|up|down|out)\b|"
r"정확도|얼마나|을매나|속도|(?:열려|닫혀|켜져|꺼져|접혀|펴져) ?있(?:어|어요|니|나요|습니까)?\s*[??]", re.I) r"정확도|얼마나|을매나|속도|(?:열려|닫혀|켜져|꺼져|접혀|펴져) ?있(?:어|어요|니|나요|습니까)?\s*[??]", re.I)
# "그리퍼 열려 있어요?": a state asked, no motion # "팔 정확도 알려 줘": a question, no motion # "그리퍼 열려 있어요?": a state asked, no motion # "팔 정확도 알려 줘": a question, no motion
OTHER_SENSE = re.compile(r"instagram|insta\b|\bsns\b|\baccount\b|\bsubscribe\b|인스타|계정|채널|구독|팔로우 ?해 ?주세요|" OTHER_SENSE = re.compile(r"instagram|insta\b|\bsns\b|\baccount\b|\bsubscribe\b|인스타|계정|채널|구독|팔로우 ?해 ?주세요|"
@@ -81,7 +83,8 @@ REPEAT = re.compile(r"^\W*(?:(?:\w+\W+){0,2})?(?:again|one more time|once more|d
# "again", "한 번만 더 해 줘": what again is the history's (driving.read, the LLM) # "again", "한 번만 더 해 줘": what again is the history's (driving.read, the LLM)
SEVERAL = re.compile(r"\b(?<!hundred )and\b(?! a half\b)|\bwait\w*|\bcorrection\b|\binstead\b|" SEVERAL = re.compile(r"\b(?<!hundred )and\b(?! a half\b)|\bwait\w*|\bcorrection\b|\binstead\b|"
r"\b(?:look|turn|go|move|wave|come|follow|pick|take|put|lift|raise|lower|reach|grab|bring)\b[^,]*,\s*(?:(?:\w+\W+){0,2})?(?:look|turn|go|move|wave|come|follow|pick|take|put|lift|raise|lower|reach|grab|bring|tell|say|sing|show|ask|answer|check)\b|\b(?:then|after that|also|plus|while|no|not|wait|stay|sleep|sorry|i mean|actually|rather)\b|;|" r"\b(?:look|turn|go|move|wave|come|follow|pick|take|put|lift|raise|lower|reach|grab|bring)\b[^,]*,\s*(?:(?:\w+\W+){0,2})?(?:look|turn|go|move|wave|come|follow|pick|take|put|lift|raise|lower|reach|grab|bring|tell|say|sing|show|ask|answer|check)\b|\b(?:then|after that|also|plus|while|no|not|wait|stay|sleep|sorry|i mean|actually|rather)\b|;|"
r"(?!갖고|고고|에서)(?<!가)[가-힣](?:서|고)(?:[\s,.…]|$)|하고|셔서|면서|다가(?![와오])|갔다|다녀|아니|기다|대기|(?:가|와) ?있어|계세요|" r"(?!갖고|고고|에서)(?<!가)[가-힣](?:서|고)(?:[\s,.…]|$)|(?:으로|로|에) ?가서|"
r"(?:흔들|흔드시|보시|돌|내리|올리|집어|내밀|숙이|들|봐 ?주시)고(?=[가-힣])|(?:쪽|나|날|위|아래|앞)보고(?=[가-힣])|(?:집어|와|가져와)서(?=[가-힣])|하고|셔서|면서|다가(?![와오])|갔다|다녀|아니|기다|대기|(?:가|와) ?있어|계세요|"
r"계십시오", re.I) r"계십시오", re.I)
# several requests or a stay ("go to p3 and wait", "가서 기다려", "p3에 가 있어"): steps.read's # 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|" 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|"
@@ -713,7 +716,7 @@ def _load():
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|" 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|\bif you please\b", re.I) r"cool|helpful) if you(?: could)?\b|^\W*go ahead and\b|\bfor a (?:sec|second|moment|bit)\b|\bif you please\b", re.I)
SLANG = [(re.compile(rf"(?<![\w가-힣]){a}(?![\w가-힣])", re.I), b) for a, b in ( SLANG = [(re.compile(rf"(?<![\w가-힣]){a}(?![\w가-힣])", re.I), b) for a, b in (
("wav", "wave"), ("reech", "reach"), ("ur", "your"), ("u", "you"), ("lemme", "let me"), ("luk", "look"), ("wav", "wave"), ("reech", "reach"), ("ur", "your"), ("u(?!-?turn)", "you"), ("lemme", "let me"), ("luk", "look"),
("pickup", "pick up"), ("plz|pls", "please"), ("mister robot|hey robot|yo robot|bro|buddy|lol|beep boop", ""), ("pickup", "pick up"), ("plz|pls", "please"), ("mister robot|hey robot|yo robot|bro|buddy|lol|beep boop", ""),
("^\\W*robot", ""), (",?\\s*robot(?=\\s*[,.!?]|\\s*$)", ""), ("^\\W*robot", ""), (",?\\s*robot(?=\\s*[,.!?]|\\s*$)", ""),
("보이소|보시오|보시게|보십시오", "봐"), ("주이소|주시게", "주세요"), ("따라온나|따라오시게|따라오이소", "따라와"), ("보이소|보시오|보시게|보십시오", "봐"), ("주이소|주시게", "주세요"), ("따라온나|따라오시게|따라오이소", "따라와"),
@@ -788,6 +791,7 @@ def core(text, markers=()):
"감사합니다") cut, and the one marker named written as CANON_PLACE ("go to the coffee corner" -> "go to p3").""" "감사합니다") cut, and the one marker named written as CANON_PLACE ("go to the coffee corner" -> "go to p3")."""
from assistant import brain from assistant import brain
t = TAIL.sub("", brain.CALLING.sub("", plain(text))).strip(" ,.!?~") or text t = TAIL.sub("", brain.CALLING.sub("", plain(text))).strip(" ,.!?~") or text
t = re.sub(r"(?<![가-힣])좀\s+(?=[가-힣])", "", t) # "뒤로 좀 돌아 줘": a softener, not a word to compare
named = [m for m in markers if brain.named_place(t, m, markers)] named = [m for m in markers if brain.named_place(t, m, markers)]
if len(named) == 1: if len(named) == 1:
low = brain._norm(t, markers) low = brain._norm(t, markers)
@@ -852,8 +856,9 @@ DIR = {"forward": r"\b(?:forward|forwards|forword|ahead|straight)\b|\bto the fro
CARRY = (r"\b(?:bring(?! yourself)|fetch|deliver|carry)\b|\bget me\b|\b(?:to|for) me\b(?=.*\b(?:bring|get|fetch|hand|pass)\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"\bget(?:ting)?\b.*\bfrom\b|\bgo get\b|가져|갖다|가지고 ?와|가져다|챙겨 ?(?:와|다)|갖고 ?와") # words that bring a thing to someone r"\bget(?:ting)?\b.*\bfrom\b|\bgo get\b|가져|갖다|가지고 ?와|가져다|챙겨 ?(?:와|다)|갖고 ?와") # 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|" COME_SAID = (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|와|오세요|오십시오|오시|올래") r"\bget closer\b|\broll over\b|\bdrive over\b|\bmy side\b|\bnext to me\b|\bto me\b|와|오세요|오십시오|오시|올래|"
r"(?<![가-힣])컴(?= ?히어|(?![가-힣]))") # Konglish "컴 히어 해 줘", "이리 컴"
LIFT_SAID_MAX_M = 0.3 # m; a longer lift amount said is no lift request ("grow to three meters tall") LIFT_SAID_MAX_M = 0.3 # m; a longer lift amount said is no lift request ("grow to three meters tall")
LIFT_BODY = (r"\b(?:yourself|your (?:body|torso|upper body)|body|make you|taller|shorter|smaller|small|tall|high|lift|rise|grow|" LIFT_BODY = (r"\b(?:yourself|your (?:body|torso|upper body)|body|make you|taller|shorter|smaller|small|tall|high|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"shrink|come down|go up|go down|move up|move down|raise up|lower down|come up|sink down|elevate|squat|height|"
@@ -868,7 +873,7 @@ MOVE_VERB = (r"\b(?:move|go|step|back up|backup|scoot|slide|shift|drive|roll|rev
LOOK_DIR = {"left": r"\bleft|왼|레프트|(?:^|\s)좌로|좌측", "right": r"\bright|\brite\b|오른|라이트|(?:^|\s)우로|우측", LOOK_DIR = {"left": r"\bleft|왼|레프트|(?:^|\s)좌로|좌측", "right": r"\bright|\brite\b|오른|라이트|(?:^|\s)우로|우측",
"up": r"\bup|\bupward|\bceiling|\bsky\b|\bhigher\b|천장|하늘|(?<!원)위", "down": r"\bdown|\bfloor|\bground|\bfeet\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|" 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)") r"\bme in the eye|\bmy face\b|나한테|저한테|쳐다봐|(?:^|\s)(?:여기|이쪽|저|나|날|절)(?:를|을)?\s*(?:(?:좀|한 ?번|잠깐|잠시|다시)\s*)*(?:바라|쳐다)?(?:봐|보세요|look)")
EN_NUM = {w: i for i, w in enumerate("zero one two three four five six seven eight nine ten eleven twelve thirteen " EN_NUM = {w: i for i, w in enumerate("zero one two three four five six seven eight nine ten eleven twelve thirteen "
@@ -1011,7 +1016,7 @@ def _slot(kind, text, markers, holding):
not re.search(rf"(?<![a-z0-9]){re.escape(named[0].lower())}(?![0-9])", said): not re.search(rf"(?<![a-z0-9]){re.escape(named[0].lower())}(?![0-9])", said):
return None # "exit a" with only Exit_B, "booth 13" with Booth_12: asked return None # "exit a" with only Exit_B, "booth 13" with Booth_12: asked
return ("go_to", named[0]) return ("go_to", named[0])
if kind == "come" and (re.search(CARRY + r"|따라", t) or not re.search(COME_VERB, t)): if kind == "come" and (re.search(CARRY + r"|따라", t) or not re.search(COME_SAID, t)):
return None # "나한테 가져와", "이리 줘": not a trip to the person return None # "나한테 가져와", "이리 줘": not a trip to the person
if kind == "come" and re.search(r"\bwith (?:me|us)\b|함께|같이", t): if kind == "come" and re.search(r"\bwith (?:me|us)\b|함께|같이", t):
return ("follow", "") # "just come with me": walk along return ("follow", "") # "just come with me": walk along
@@ -1057,7 +1062,7 @@ def _slot(kind, text, markers, holding):
not re.search(r"\bface\b|\bother (?:side|way)\b|\d+\s*(?:degrees?|도)", t.replace("360", "")) and \ not re.search(r"\bface\b|\bother (?:side|way)\b|\d+\s*(?:degrees?|도)", t.replace("360", "")) and \
said_amount(text)[1] in (None, 360): said_amount(text)[1] in (None, 360):
return ("turn", ("right" if re.search(r"\bright\b|오른쪽", t) else "left") + " 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): if re.search(r"\baround\b|\bu-?turn\b|유턴|뒤로 (?:(?:좀|한 ?번|얼른|빨리)\s*)?돌|뒤돌|\bother way\b|\babout face\b|한 바퀴", t):
return None if re.search(r"\bleft|\bright\b|왼|오른", t) else ("turn", "around 180") 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")] d = [x for x in _dirs(t) if x in ("left", "right")]
if not d and said_amount(text)[1] == 180: if not d and said_amount(text)[1] == 180:
@@ -1159,12 +1164,54 @@ def read(text, markers=(), holding=False):
kind = kind_of(text, markers) kind = kind_of(text, markers)
if isinstance(kind, tuple): # two motions close: only when the words fit one of them if isinstance(kind, tuple): # two motions close: only when the words fit one of them
kind, other = kind kind, other = kind
if other not in ACTS or _slot(other, text, markers, holding) is not None: if other == "put" and not holding and not PUT_VERB.search(text):
pass # "원래 자리로 가 줘": no put verb, nothing held: the trip back
elif other not in ACTS or _slot(other, text, markers, holding) is not None:
return None return None
if kind and _verb_conflict(kind, text, holding):
return None
got = _slot(kind, text, markers, holding) if kind else None got = _slot(kind, text, markers, holding) if kind else None
return ("fetch", said) if got and got[0] == "fetch" else got return ("fetch", said) if got and got[0] == "fetch" else got
PICK_VERB = re.compile(r"집|잡|들어|들고|가져|갖다|챙겨|\b(?:pick|grab|take|get|fetch|bring|hold)\b", re.I)
LOOK_VERB = re.compile(r"봐|보세|쳐다|바라|\b(?:look|see|watch)\b", re.I)
PUT_VERB = re.compile(r"놓|놔|둬|두|내려|\b(?:put|place|drop|set|leave)\b", re.I)
BACK_VERB = re.compile(r"돌아|복귀|컴백|리턴|가|와|\b(?:return|go|come|head|back)\b", re.I)
POINTED = re.compile(r"저기 ?저|저 ?자리|(?<!아까 )그 ?자리로|\bthat (?:spot|place|position)\b|\bover there\b", re.I)
def _verb_conflict(kind, text, holding):
"""The bank's kind against the verb said: "저 컵 봐" is no pick, "바닥에 있는 거 집어 줘" no look, "저기 저 자리로 가"
a pointed place, not back; holding a thing, the hand words are the hand reader's ("손 펴", "제자리 좀")."""
if kind in ("pick", "fetch") and LOOK_VERB.search(text) and not PICK_VERB.search(text):
return True
if kind == "look" and PICK_VERB.search(text) and not LOOK_VERB.search(text) and not HEAD_WORD.search(text):
return True
if kind == "come_back" and (POINTED.search(text) or not BACK_VERB.search(text)):
return True
if kind in ("turn", "move") and (HEAD_WORD.search(text) or re.search(r"돌아 ?보|허리|\bwaa*i*st\b|\btorso\b", text, re.I)):
return True # "머리 왼쪽으로 15도 돌려": the head
if kind == "look" and BODY_WORD.search(text) and not HEAD_WORD.search(text):
return True # "본체를 오른쪽으로 돌려", "torso 정면": the body
if kind == "look" and GO_VERB.search(text) and not HEAD_WORD.search(text) and not LOOK_VERB.search(text):
return True # "라이트로 살짝 가 줘": a drive
if kind == "arm_reach" and (HAND_SHAPE.search(text) or COME_VERB.search(text) and not ARM_WORD.search(text)):
return True # "손 펴 주시겠어요" (open), "할머니한테 와 줘" (come)
if kind == "wave" and not WAVE_VERB.search(text):
return True # "손 벌려 줘", "손 쥐어 빨리", "손 좀 주이소"
return holding and kind in ("arm_open", "arm_fold", "arm_reach", "arm_close")
HEAD_WORD = re.compile(r"머리|고개|얼굴|시선|\b(?:head|eyes|(?<!about )face|gaze)\b", re.I)
BODY_WORD = re.compile(r"본체|몸|허리|상체|몸통|\b(?:body|torso|waist|upper body|yourself)\b", re.I)
GO_VERB = re.compile(r"(?<![가-힣])가(?: ?줘| ?주|$|\s)|이동|움직|무브|\b(?:move|go|drive|roll|scoot)\b", re.I)
HAND_SHAPE = re.compile(r"펴|펼|쥐|주먹|넣|접|내려|오므|놔|놓|\b(?:open|close|fist|tuck|fold|lower)\b", re.I)
COME_VERB = re.compile(r"(?<![가-힣])와(?![가-힣])|와 ?(?:줘|주)|오세요|오십시오|\bcome\b", re.I)
ARM_WORD = re.compile(r"손|팔|\b(?:hand|arm)\b", re.I)
WAVE_VERB = re.compile(r"흔들|흔드|악수|인사|빠이|바이|웨이브|하이|\b(?:wave|waving|hello|hi|hey|shake|greet|bye)\b", re.I)
if __name__ == "__main__": if __name__ == "__main__":
if sys.argv[1:] == ["build"]: if sys.argv[1:] == ["build"]:
n = len(_load()[1]) n = len(_load()[1])
+72 -22
View File
@@ -123,8 +123,14 @@ CLOSE_BOX = 0.85 # a person is really closer than TOO_CLOSE on
HEAD_SIGN = 1.0 # +image angle -> +head yaw (checked: + = robot's left) HEAD_SIGN = 1.0 # +image angle -> +head yaw (checked: + = robot's left)
LOOK = {"left": (40, None), "right": (-40, None), "center": (0, head.HEAD_REST_PITCH), "up": (None, 20), "down": (None, -5)} LOOK = {"left": (40, None), "right": (-40, None), "center": (0, head.HEAD_REST_PITCH), "up": (None, 20), "down": (None, -5)}
# ^ yaw/pitch in degrees for "look" commands: +yaw = left, +pitch = up (checked on the dashboard 2026-10-12) # ^ yaw/pitch in degrees for "look" commands: +yaw = left, +pitch = up (checked on the dashboard 2026-10-12)
WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|lumia|loomi|loomy|lumie|lumee|lumy|lummy|lummi|looney|lu-mi|rumi|rumy|roomie)\b" WAKE_UP_EN = r"wake up|wakey wakey|time to wake up"
r"|루미|누미", re.I) WAKE_UP_KO = r"(?:일어나|깨어나)(?:요|세요|십시오|라|봐|봐요)?|기상"
WAKE = re.compile(rf"\b(hi|hey|hello|okay|ok|hai|high|{WAKE_UP_EN})?[\s,.!]*(lumi|lumia|loomi|loomy|lumie|lumee|lumy|lummy|lummi|looney|lu-mi|rumi|rumy|roomie)\b"
rf"(?:[\s,.!]*(?:{WAKE_UP_EN})\b)?"
rf"|(?:(?:{WAKE_UP_KO})[\s,.!~]*)?(?:헤이 ?|하이 ?)?(?:루미|누미)(?:야|아)?(?:[\s,.!~]*(?:{WAKE_UP_KO}))?"
rf"|^\W*(?:(?:hey|ok|okay|come on)\W+)?(?:{WAKE_UP_EN})\W*$|^\W*(?:(?:자|이제|얼른)\s+)?(?:{WAKE_UP_KO})[\s.!~]*$", re.I)
# ^ "Hey Lumi", "Lumi", "wake up (Lumi)", "Lumi, wake up", "루미야", "헤이 루미", "루미야 일어나", "일어나세요";
# a bare "wake up" / "일어나" only as the whole utterance ("I wake up at 7" is no call)
WAKE_REPLY = {"en": "Yes? How can I help?", "ko": "네? 무엇을 도와드릴까요?"} WAKE_REPLY = {"en": "Yes? How can I help?", "ko": "네? 무엇을 도와드릴까요?"}
NAME_ONLY = re.compile(r"^\s*(hi |hey |hello )?(lumi|loomi|rumi|루미)[\s,.!?]*$", re.I) NAME_ONLY = re.compile(r"^\s*(hi |hey |hello )?(lumi|loomi|rumi|루미)[\s,.!?]*$", re.I)
FETCH_STOP = re.compile(r"\b(sto+pp?|stob|halt|freeze|don'?t move)\b|^\W*(?:lumi\W+)?stopped\W*$|스탑|스텁|멈추(?:세요|십시오)|^\W*abort\W*$|\babort (?:the |this |your )?(?:mission|task|trip)\b|\bcancel (?:the |this |your )?(?:mission|task|trip)\b|" FETCH_STOP = re.compile(r"\b(sto+pp?|stob|halt|freeze|don'?t move)\b|^\W*(?:lumi\W+)?stopped\W*$|스탑|스텁|멈추(?:세요|십시오)|^\W*abort\W*$|\babort (?:the |this |your )?(?:mission|task|trip)\b|\bcancel (?:the |this |your )?(?:mission|task|trip)\b|"
@@ -313,7 +319,7 @@ HELLO_ONLY = re.compile(r"^(?=\W*\w)\s*(?:(?:hi|hey|hello|hiya|hai|hallo|helo|hi
r"(?:how are you(?: doing)?(?: today)?[\s,.!?]*)?$|" # "how are you?" r"(?:how are you(?: doing)?(?: today)?[\s,.!?]*)?$|" # "how are you?"
r"^\s*(?:안녕|안녕하세요|안녕하십니까|하이)[\s.!~?]*$", re.I) # "안녕하세요", "하이" r"^\s*(?:안녕|안녕하세요|안녕하십니까|하이)[\s.!~?]*$", re.I) # "안녕하세요", "하이"
CALL_REST = re.compile(r"^(?:[\W_]|\b(?:hi|hey|hello|hiya|hai|ok|okay|there|how are you(?: doing)?(?: today)?)\b|" CALL_REST = re.compile(r"^(?:[\W_]|\b(?:hi|hey|hello|hiya|hai|ok|okay|there|how are you(?: doing)?(?: today)?)\b|"
r"안녕(?:하세요|하십니까)?|하이|야|아)*$", re.I) # what is left of a call without the name r"안녕(?:하세요|하십니까)?|하이|헤이|야|아)*$", re.I) # what is left of a call without the name
CAMERA_HALF_FOV = 42.0 # deg; half the camera's view (+ the head's YAW_LIMIT for the head camera) CAMERA_HALF_FOV = 42.0 # deg; half the camera's view (+ the head's YAW_LIMIT for the head camera)
WAKE_MAX_S = 6.0 # s; longer utterances are not checked for the wake word WAKE_MAX_S = 6.0 # s; longer utterances are not checked for the wake word
BARGE_IN_LOGPROB = -0.6 # an interruption must be heard more clearly than a normal answer (-1.0) BARGE_IN_LOGPROB = -0.6 # an interruption must be heard more clearly than a normal answer (-1.0)
@@ -3255,35 +3261,53 @@ STOP_UNSAID = re.compile( # a stop that is taken back, for later, said about t
r"\bstop it,? (?-i:(?!Lumi\b|Robot\b)[A-Z][a-z]+)\b", re.I) r"\bstop it,? (?-i:(?!Lumi\b|Robot\b)[A-Z][a-z]+)\b", re.I)
STOP_LATER = re.compile( # a stop for later ("내일 그만하시게", "행사가 끝난 후에 멈춰 주세요") or reported ("아까 직원분이
# 그만하라고 지시했습니다"); "내가 멈추라고 했지!" is said now
r"(?:^|\s)(?:나중에|이따가?|있다가|내일|모레|다음에|다음 ?번에)\s|(?:끝난|끝나고|마친|마치고|끝내고) ?(?:후|뒤|다음)?에?\s|"
r"[가-힣]고 ?나서\s|(?<!내가 )(?<!제가 )(?<!내가)(?:그만하|멈추|멈춰 ?달|정지하|서)라고\s*(?:\S+\s+)?"
r"(?:했|하셨|그랬|말했|말씀|지시|하더|하던|한다|하네)")
STOP_PAD = re.compile(r"^(?:\W*(?:hey|hi|yo|oh|okay|ok|so|um+|uh+|listen|right|alright|all right|excuse me|mister robot|" STOP_PAD = re.compile(r"^(?:\W*(?:hey|hi|yo|oh|okay|ok|so|um+|uh+|listen|right|alright|all right|excuse me|mister robot|"
r"robot|lumi|loomi|루미 ?씨|루미 ?선생|루미야?|로봇아?|로봇 양반|어+|아+|야|저기요?)\b)+|" r"robot|lumi|loomi|루미 ?씨|루미 ?선생|루미야?|로봇아?|로봇 양반|어+|아+|야|저기요?)\b)+|"
r"(?:\W*\b(?:please|plz|pls|bro|now|right now|real quick|thanks|thank you|okay|ok|would you|will you|" r"(?:\W*\b(?:please|plz|pls|bro|now|right now|real quick|thanks|thank you|okay|ok|would you|will you|"
r"right|already|빨리|좀|제발|당장|루미야?)\b)+\W*$", re.I) r"right|already|lumi|robot|빨리|좀|제발|당장|루미야?)\b)+\W*$", re.I)
STOP_ONLY = re.compile( # a whole sentence that only says stop / enough / stay (after calls and fillers): stop at once STOP_ONLY = re.compile( # a whole sentence that only says stop / enough / stay (after calls and fillers): stop at once
r"(?:(?:sto+p|stahp|stob|top it|enough|that'?s enough|that is enough|no more|quit it|cut it out|kill it|abort|" r"(?:(?:sto+p|stahp|stob|top it|enough|that'?s enough|that is enough|no more|quit it|cut it out|knock it off|whoa,? there|whoa(?:,? whoa)+|kill it|abort|"
r"stop (?:everything|driving|moving|it|that|the robot|right there|right now)|enough (?:music|of that)|" r"stop (?:everything|driving|moving|it|that|the robot|right there|right now)|enough (?:music|of that)|"
r"hold it|stop 해|그만|그만해|그만해요|그만하세요|그만하십시오|그만해 ?줄래요?|" r"hold it(?: (?:right )?(?:there|here))?|stop 해|그만|그만해|그만해요|그만하세요|그만하십시오|그만해 ?줄래요?|"
r"그만해 ?주세요|그마내|그만둬|멈춰|멈쳐|멈처|멈추라고|멈춰 ?봐|거기까지|고마 ?(?:서라|해라|해|하이소)|서|don'?t go|가지 ?마|그마+안|" r"그만해 ?주세요|그마내|그만둬|멈춰|멈쳐|멈처|멈추라고|멈춰 ?봐|거기까지|고마 ?(?:서라|해라|해|하이소)|서|don'?t go|가지 ?마|그마+안|"
r"얼음|cut it|노래 ?꺼|음악 ?꺼|stop the (?:music|song)|music off|stay|stay (?:here|there|put|right there)|" r"얼음|cut it|노래 ?꺼|음악 ?꺼|stop the (?:music|song)|music off|stay|stay (?:here|there|put|right there)|"
r"(?:just )?wait there|stop following(?: me)?|finish follow|(?:여기|거기)(?:서)? ?(?:그대로 ?)?(?:있어|있어요|계세요|stay|서|서세요|" r"(?:just )?wait there|stop following(?: me)?|finish follow|(?:여기|거기)(?:서)? ?(?:그대로 ?)?(?:있어|있어요|계세요|stay|서|서세요|"
r"기다려)|그대로 있어|가만히 있어|stay 해|wait 해)\W*){1,3}", re.I) r"기다려)|그대로 있어|가만히 있어|stay 해|wait 해)\W*){1,3}", re.I)
STOP_POLITE = re.compile( # a stop asked politely, after wording.ko_plain: "멈춰 주시겠어요?" -> "멈춰 줘?", "can you stop for me?"
r"\W*(?:(?:좀|지금|당장|잠깐|잠시|거기서?|이제)\s*)*(?:멈춰|멈춰 서|정지해|그만해|스톱해|스탑해|서)(?: ?줘)?\W*|"
r"\W*(?:(?:please|lumi|hey|okay|ok)\W+)*(?:can|could|would|will) (?:you|u) (?:please |just |kindly )?(?:stop|halt|freeze)"
r"(?: (?:right )?(?:now|here|there|please))?(?: for (?:me|us|a (?:second|sec|moment|bit|minute)))?(?:,? please)?\W*|"
r"\W*(?:would|do) you mind stopping(?: (?:now|here|there))?(?: for (?:me|us|a (?:second|moment)))?(?:,? please)?\W*", re.I)
def stop_order(text, markers): def stop_order(text, markers):
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button; """"stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button;
"can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop. Not a negated stop ("don't stop", "계속 "can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop. Not a negated stop ("don't stop", "계속
해"), talk about stopping ("he said stop", "bus stop", "my laptop freezes", "내 다리도 자주 멈춰"); a short bare 해"), talk about stopping ("he said stop", "bus stop", "my laptop freezes", "내 다리도 자주 멈춰"); a short bare
stop word always stops (also stretched: "stooop", "머엄춰").""" stop word always stops (also stretched: "stooop", "머엄춰")."""
if NOT_STOP.search(text) and not re.fullmatch(r"\W*(?:(?:no|ok|okay|lumi|루미야?|hey)\W+)*(?:sto+pp?|stob|stopped|halt|freeze|멈춰|머+엄*춰|" if NOT_STOP.search(text) and not re.fullmatch(r"\W*(?:(?:lumi|robot|hey|okay|ok)\W+)*(?:would|do) you mind stopping"
r"(?:,? (?:now|here|there|please|for (?:me|us|a (?:second|moment))))*\W*", text, re.I) \
and not re.fullmatch(r"\W*(?:(?:no|ok|okay|lumi|루미야?|hey)\W+)*(?:sto+pp?|stob|stopped|halt|freeze|멈춰|머+엄*춰|"
r"그만|정지|스톱|스탑|stop it|stop now)\W*", text, re.I): r"그만|정지|스톱|스탑|stop it|stop now)\W*", text, re.I):
return False return False
if STOP_UNSAID.search(text): if STOP_UNSAID.search(text) or STOP_LATER.search(text):
return False return False # "이따가 멈춰 주세요": a stop for later
bare = STOP_PAD.sub("", text.strip()).strip(" ,.!?~") bare = STOP_PAD.sub("", text.strip()).strip(" ,.!?~")
if bare and STOP_ONLY.fullmatch(bare): if bare and STOP_ONLY.fullmatch(bare):
return True # "hi Lumi, stop, okay?", "enough already", "Lumi, wait" return True # "hi Lumi, stop, okay?", "enough already", "Lumi, wait"
# (watch out / 위험해 / "Lumi, wait" / hold on: on a mission these halt it (mission_talk), never end it) # (watch out / 위험해 / "Lumi, wait" / hold on: on a mission these halt it (mission_talk), never end it)
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text)) or from assistant import wording
plain = brain_mod.CALLING.sub("", wording.ko_plain(text)).strip()
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text)) or STOP_POLITE.fullmatch(plain) or
re.match(r"^\W*(?:stop|halt|freeze|멈춰|정지|스톱)\W*[,.!]", text, re.I)) re.match(r"^\W*(?:stop|halt|freeze|멈춰|정지|스톱)\W*[,.!]", text, re.I))
return bool(FETCH_STOP.search(text) or asked) and (brain_mod.intent(text, markers) or ("",))[0] not in ("quiet", "look") \ return bool(FETCH_STOP.search(text) or asked) and (brain_mod.intent(text, markers) or ("",))[0] not in ("quiet", "look") \
and not brain_mod.STOP_TALK.search(text) and ("?" not in text or asked) and not brain_mod.STOP_TALK.search(text) and ("?" not in text or asked)
@@ -3299,14 +3323,16 @@ HAND_STATE_Q = re.compile( # how the hand is now (A1): "is your hand open?", "
r"\b(?:is|are|r|was) (?:your|ur|the) (?:hand|gripper|claw|fingers?|arm)s? (?:still |now |already )?(?:open|opened|closed|shut|out|" r"\b(?:is|are|r|was) (?:your|ur|the) (?:hand|gripper|claw|fingers?|arm)s? (?:still |now |already )?(?:open|opened|closed|shut|out|"
r"extended|empty|folded|in|up|down|stretched)\b|\b(?:hand|gripper|arm) (?:open|closed?|out)\s*(?:이야|이에요|인가요?|이니|상태|\?)|" r"extended|empty|folded|in|up|down|stretched)\b|\b(?:hand|gripper|arm) (?:open|closed?|out)\s*(?:이야|이에요|인가요?|이니|상태|\?)|"
r"^\W*(?:(?:right|um|basically|next|so|okay)\W+)*did (?:you|u) drop (?:it|that|something|the \w+)\W*$|" r"^\W*(?:(?:right|um|basically|next|so|okay)\W+)*did (?:you|u) drop (?:it|that|something|the \w+)\W*$|"
r"(?:손|그리퍼|집게|손가락|팔)(?:이|은|는|가)? ?(?:지금 |아직 |다 )?(?:open|close|펴져|펴진|열려|열린|닫혀|닫힌|접혀|접힌|뻗어져|오므려져|" r"(?:손|그리퍼|집게|손가락|팔)(?:이|은|는|가)? ?(?:지금 |아직 |다 )?(?:open|close|오픈|클로즈|펴져|펴진|열려|열린|닫혀|닫힌|접혀|접힌|뻗어져|오므려져|"
r"쥐어져)\s*(?:있|상태|이야|인가)", re.I) r"쥐어져)\s*(?:있|상태|이야|인가)", re.I)
def status_question(text): def status_question(text):
""""What are you doing?", "where are you going?", "is your hand open?": answered from the task state ("들고 있는 거 """"What are you doing?", "where are you going?", "is your hand open?": answered from the task state ("들고 있는 거
줘" is a request).""" 줘" is a request)."""
return bool(HAND_STATE_Q.search(text)) or bool(STATUS_Q.search(text)) and not NOT_STATUS_NOW.search(text) and not EMPTY_HAND.search(text) hand = HAND_STATE_Q.search(text) and not re.search(r"\b(?:stretch|stick|hold|put|reach|extend|get|move|bring)\b", text, re.I)
return bool(hand) or bool(STATUS_Q.search(text)) and not NOT_STATUS_NOW.search(text) and not EMPTY_HAND.search(text)
# hand: not "may I ask you to stretch your arm out?" (an order)
def says_goodbye(text): def says_goodbye(text):
@@ -3338,6 +3364,11 @@ NOT_A_STEP = re.compile(r"^\W*(?:(?:please|and|then|also)\s+)*(?:dance|jump|fly|
r"bring|take|give|hand|put|carry|deliver)\b|.*(?:춤|점프|날아|수영|박수)", re.I) # a part not read: asked r"bring|take|give|hand|put|carry|deliver)\b|.*(?:춤|점프|날아|수영|박수)", re.I) # a part not read: asked
CAN_TOLD = re.compile(r"\b(?:you|u) (?:can|could|are able to|know how to)\b|(?<!줄 )(?<!주실 )(?<!줄)(?<!주실)수 ?(?:도 ?)?있(?:지|죠|잖|겠지|겠죠|을 ?걸)|"
r"줄 ?(?:도 ?)?알(?:지|죠|잖)", re.I) # with a tag: Lumi's ability said back, a question (TAG)
MYEOT_SLIP = re.compile(r"(?<![가-힣])멸(?=\s*(?:센티|센치|미터|밀리|키로|킬로|그램|개|번|도|시|분|초|명|살|층|cm|mm|kg|m\b))", re.I)
def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True): 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 """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"; "detour" (data: assistant/detour.read's tests/command_check: (kind, data). Kinds in this order: "stop"; "detour" (data: assistant/detour.read's
@@ -3348,10 +3379,15 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
reading: assistant/intent_bank.py); (None, None): the LLM reads 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.""" it. seen: seeing.answer or a stand-in; chain_ok: False on a mission or while a chain runs."""
from assistant import chain, intent_bank from assistant import chain, intent_bank
text = MYEOT_SLIP.sub("몇", text or "") # whisper's 멸 for 몇: "멸 센티까지 잡아?" asks, orders nothing
text = re.sub(r"(?<=[가-힣])(?=[a-zA-Z]{2})", " ", text) # "원래 자리에put back": the English word apart
text = re.sub(r"\bcome on back\b", "come back", text, flags=re.I) # not 1 m back
text = re.sub(r"(?<![\d.])360(?= ?돌아)", "360도", text) # "루미 360 돌아 봐": a full turn, not "turn round"
if stop_order(text, markers): if stop_order(text, markers):
return "stop", None return "stop", None
told = intent_bank.TAG.search(text) and (chain.PAST.search(text) or intent_bank.PAST_EN.search(text) or told = intent_bank.TAG.search(text) and (chain.PAST.search(text) or intent_bank.PAST_EN.search(text) or
intent_bank.past_ko(text)) # "you went to P5 earlier, right?": asked intent_bank.past_ko(text) or CAN_TOLD.search(text))
# "you went to P5 earlier, right?", "you can lift your arm, right?", "너 팔 접을 수 있지?": asked, no order
text = brain_mod.strip_asides(text) # "hi Lumi, it's my birthday, put it down!": the command (A1) text = brain_mod.strip_asides(text) # "hi Lumi, it's my birthday, put it down!": the command (A1)
if sing.picked(text, last): # after the list of songs: "the first one", "Fantastic Baby" if sing.picked(text, last): # after the list of songs: "the first one", "Fantastic Baby"
return "sing", None return "sing", None
@@ -3371,15 +3407,18 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
plan = None # "그 cup 들고 wave 해" with a cup in the hand: no second pick; the LLM plan = None # "그 cup 들고 wave 해" with a cup in the hand: no second pick; the LLM
if plan: if plan:
return "chain", plan return "chain", plan
got = seen(text) if seen else None held_order = (holding() if callable(holding) else holding) and not hold and \
(brain_mod.held_place(text, markers) or brain_mod.held_give(text, markers)) # "put it down ok?" with a cup:
got = seen(text) if seen and not held_order else None # the hand, not "I put it down, now?"
if got: if got:
return "seeing", got return "seeing", got
if status_question(text): if status_question(text):
return "status", None return "status", None
if (holding() if callable(holding) else holding) and brain_mod.held_put_back(text, markers): if (holding() if callable(holding) else holding) and not brain_mod.held_back(text) and \
not brain_mod.ARM_TALK.search(text) and brain_mod.held_put_back(text, markers):
return "quick", ("put", "back") # "it's my birthday, put that back where you found it!" return "quick", ("put", "back") # "it's my birthday, put that back where you found it!"
song = sing.asked(text, last) # "Let it go 불러 줘": a song title, never the hand (A1) song = sing.asked(text, last) # "Let it go 불러 줘": a song title, never the hand (A1)
if hold and not song: # a wave / arm rule may act on a question-form request ("악수 한번 할까요?", if hold and not song and not told: # a wave / arm rule may act on a question-form request ("악수 한번 할까요?",
arm_rule = brain_mod.intent(text, markers) # "would it be possible to wave at me?"); intent() itself refuses arm_rule = brain_mod.intent(text, markers) # "would it be possible to wave at me?"); intent() itself refuses
if arm_rule and arm_rule[0] in ("wave", "arm"): # negations, later times, remarks, ability questions (A1) if arm_rule and arm_rule[0] in ("wave", "arm"): # negations, later times, remarks, ability questions (A1)
return arm_quick(arm_rule, holding) return arm_quick(arm_rule, holding)
@@ -3392,7 +3431,9 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
cor = brain_mod.correction(text, b.history) cor = brain_mod.correction(text, b.history)
if cor: if cor:
return "correction", cor return "correction", cor
if not song and (brain_mod.hand_request(text, False, b, markers) or brain_mod.hand_request(text, True, b, markers)): if not song and not brain_mod.ARM_TALK.search(text) and not brain_mod.held_back(text) and \
(brain_mod.hand_request(text, False, b, markers) or brain_mod.hand_request(text, True, b, markers)):
# not "it'd be cool if you could hand it over someday", "I heard you can take things from people"
held = holding() if callable(holding) else holding held = holding() if callable(holding) else holding
hand = brain_mod.hand_request(text, held, b, markers) hand = brain_mod.hand_request(text, held, b, markers)
if hand: if hand:
@@ -3408,12 +3449,16 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
if sing.asked(text, last): if sing.asked(text, last):
return "sing", None return "sing", None
rule = brain_mod.intent(text, markers) rule = brain_mod.intent(text, markers)
if rule and rule[0] in QUICK_RULES - {"come_back", "weather", "search"} and brain_mod.ARM_TALK.search(text):
return None, None # "자네 컵 잡는 거 제법이더군", "do you know how to drive right 30 cm?",
# "70센티 앞으로 움직일 리가 있나": a remark or an ability, no motion
if rule and rule[0] in QUICK_RULES: if rule and rule[0] in QUICK_RULES:
return "quick", rule return "quick", rule
if not rule: if not rule:
from assistant import intent_bank from assistant import intent_bank
rule = intent_bank.read(text, markers, holding) # the same request in other words, by meaning rule = None if brain_mod.GREET_ONLY.match(text or "") else \
if rule and rule[0] in ("wave", "arm") and brain_mod.ARM_TALK.search(text): intent_bank.read(text, markers, holding) # the same request in other words, by meaning ("hello robot": no wave)
if rule and rule[0] not in ("come_back", "weather", "search") and brain_mod.ARM_TALK.search(text):
rule = None # "it'd be cool if you could take your hand back someday": talk (A1) rule = None # "it'd be cool if you could take your hand back someday": talk (A1)
if rule: if rule:
return arm_quick(rule, holding) return arm_quick(rule, holding)
@@ -3436,7 +3481,7 @@ ARM_AGAIN = re.compile(r"^\W*(?:(?:okay|ok|yes|yeah|lumi|please|robot|루미야?
FILLER_PART = re.compile(r"\W*(?:(?:hey|yo|hi|okay|ok|excuse me|um+|uh+|so|now|please|thanks|thank you|real quick|quick|" FILLER_PART = re.compile(r"\W*(?:(?:hey|yo|hi|okay|ok|excuse me|um+|uh+|so|now|please|thanks|thank you|real quick|quick|"
r"right now|lumi|robot|buddy|mister robot|bro|dude|어이|야|저기요?|루미야?|로봇아?|당장|지금|빨리|" r"right now|lumi|robot|buddy|mister robot|bro|dude|어이|야|저기요?|루미 ?씨|루미야?|로봇아?|당장|지금|빨리|"
r"얼른|어서|끝까지|이제|좀|제발)\W*)+", re.I) # a part of the words that is no step: a call, "now" r"얼른|어서|끝까지|이제|좀|제발)\W*)+", re.I) # a part of the words that is no step: a call, "now"
@@ -3445,7 +3490,10 @@ def read_mission(text, markers):
A single move / turn / arm / go, or words that are only partly a plain command, stay with the other paths.""" A single move / turn / arm / go, or words that are only partly a plain command, stay with the other paths."""
from assistant import steps from assistant import steps
got, unread, by = steps.read(text, markers, llm=False) got, unread, by = steps.read(text, markers, llm=False)
unread = [u for u in unread if not FILLER_PART.fullmatch(u)] # "팔 접어, 당장", "hey robot, fold your arm" from assistant import chain
unread = [u for u in unread if not FILLER_PART.fullmatch(u) and # "팔 접어, 당장", "hey robot, fold your arm"
not chain._restated(u, text.lower().replace(u, " "))] # "컵 잡아!, 아 잡아 줄 수 있어요?": said again
# (the parts come lower-cased: "부스 B로 가서" is the part itself, not said twice)
rule = brain_mod.intent(text, markers) or ("", "") rule = brain_mod.intent(text, markers) or ("", "")
if unread and rule[0] == "look" and rule[1].endswith(f" {brain_mod.HEAD_YAW[1]:g}"): if unread and rule[0] == "look" and rule[1].endswith(f" {brain_mod.HEAD_YAW[1]:g}"):
return None # "turn around and look": the head looks behind (brain.BEHIND_WORDS) return None # "turn around and look": the head looks behind (brain.BEHIND_WORDS)
@@ -3462,7 +3510,9 @@ def read_mission(text, markers):
return None return None
if len(got) > 1 and all(st == got[0] for st in got) and got[0]["do"] in ("arm", "wave", "look", "lift"): if len(got) > 1 and all(st == got[0] for st in got) and got[0]["do"] in ("arm", "wave", "look", "lift"):
got = got[:1] # "reach out, reach out to me": one reach, said twice got = got[:1] # "reach out, reach out to me": one reach, said twice
plain = not steps.is_mission(got) and (len(got) == 1 or (brain_mod.intent(text, markers) or ("",))[0] == "fetch") one_part = len(steps._split(steps._norm(steps._cut_says(text)[0], markers), markers)) == 1
plain = not steps.is_mission(got) and (len(got) == 1 or one_part or (brain_mod.intent(text, markers) or ("",))[0] == "fetch")
# ^ "컵 가져와 주셨으면 해요": one part a plain fetch can do stays the fetch, not a mission
if not unread and (plain or (len(got) == 1 and got[0]["do"] in ("move", "turn", "arm"))): # "take the cup and put if not unread and (plain or (len(got) == 1 and got[0]["do"] in ("move", "turn", "arm"))): # "take the cup and put
return None # it on the chair": two steps, not a pick return None # it on the chair": two steps, not a pick
return got, unread, by return got, unread, by
+117 -17
View File
@@ -35,16 +35,21 @@ _SUP_KO = "|".join(k for k in brain.SUPPORTS if not k.isascii())
_NUM = r"(\d+(?:\.\d+)?)" _NUM = r"(\d+(?:\.\d+)?)"
_DIR = r"(forward|ahead|straight|back(?:wards?)?|left|right)" _DIR = r"(forward|ahead|straight|back(?:wards?)?|left|right)"
_DIR_KO = r"(앞으로|뒤로|왼쪽으로|오른쪽으로)" _DIR_KO = r"(앞으로|뒤로|왼쪽으로|오른쪽으로)"
_FILL = (r"(?:please|let'?s|lets|hey lumi|hi lumi|hey|hi|lumi|loomi|rumi|okay|ok|alright|all right|so|well|real quick|if you can|if you could|자|저기|저기요|혹시|instead|um+|uh+|er|hmm|thank you|thanks|now|then|and|also|first|next|" _FILL = (r"(?:(?:저기 |그 )?(?:이보게(?: 루미)?|어이(?: 로봇아?| 루미야?)?|아야(?: 루미)?|야야(?: 루미)?|우리 루미|보소|자네|"
r"finally|after that|there|for me|again|carefully|slowly|could you|can you|would you|will you|lumi야|루미야|루미|음|응|어|야 로봇|로봇아|로봇야|" r"루미 ?(?:님|씨|군|양)(?:께서|께)?|로봇 ?씨|여보세요|실례지만|실례합니다|죄송한데요?|죄송하지만|죄송합니다만|"
r"번거로우시겠지만)|" # calls of every level ("이보게 루미", "루미 님께서") before "루미" alone
r"please|let'?s|lets|hey lumi|hi lumi|hey|hi|lumi|loomi|rumi|okay|ok|alright|all right|so|well|real quick|if you can|if you could|자|저기|저기요|혹시|instead|um+|uh+|er|hmm|thank you|thanks|now|then|and|also|first|next|"
r"finally|after that|there|for me|for us|again|carefully|slowly|could you|can you|would you|will you|lumi야|루미야|루미|음|응|어|야 로봇|로봇아|로봇야|"
r"감사합니다|고마워요|고마워|고맙습니다|좀|먼저|우선|일단|그다음|그 다음|마지막으로|다시|lastly|first of all|" r"감사합니다|고마워요|고마워|고맙습니다|좀|먼저|우선|일단|그다음|그 다음|마지막으로|다시|lastly|first of all|"
r"(?:i'?d|i would) like you to|i want you to|i need you to|you should|kindly|go ahead and|maybe|possibly|" r"(?:i'?d|i would) like you to|i want you to|i need you to|you should|kindly|go ahead and|maybe|possibly|"
r"do me a favou?r and|be a dear and|right away|quickly|if you don'?t mind)") r"do me a favou?r and|be a dear and|right away|quickly|if you don'?t mind|excuse me|sorry|"
r"거시기|에구|에이그|아|얘|no|nope|actually|change of plans?|아니|아니야|아니요|아뇨|아니 아니|" # "no, bring it to p4 instead": the new order
r"ㅎㅎ+|ㅋㅋ+|응\??|한 ?번만|쪼까|쫌|퍼뜩|얼른|빨리|어서|우리|거기서|그|robot)")
_PEOPLE = r"(?:them|him|her|someone|somebody|the person(?: there)?|people|the people|everyone|everybody|the guests?)" _PEOPLE = r"(?:them|him|her|someone|somebody|the person(?: there)?|people|the people|everyone|everybody|the guests?)"
# where one step ends and the next starts # where one step ends and the next starts
_SPLIT = re.compile(r"\s*(?:,|;|\.(?=\s|$)|\band then\b|\bthen\b|\band\b|\bafter that\b|\bafterwards\b|\bonce you'?re there\b|" _SPLIT = re.compile(r"\s*(?:,|;|\.(?=\s|$)|\band then\b|\bthen\b|\band\b|\bafter that\b|\bafterwards\b|\bonce you'?re there\b|"
r"\bwhen you get there\b|그리고 나서|그러고 나서|그런 다음에?|그 후에?|그리고|그 ?다음에?|그담에|다음에)\s*") r"\bwhen you get there\b|그리고 나서|그러고 나서|그런 다음에?|그 후에?|그리고|그 ?다음에?|그담에|다음에)\s*")
_SPLIT_KO = re.compile(r"(?<=[가-힣](?:고|서))(?<!라고)(?<!다고)(?<!자고)(?<!냐고)(?<!에서)(?<!말고)\s+(?!있)|(?<=다가)\s+") # "들고 ", "가서 ": a verb _SPLIT_KO = re.compile(r"(?<=[가-힣](?:고|서))(?<!라고)(?<!다고)(?<!자고)(?<!냐고)(?<!에서)(?<!말고)\s+(?!있)(?!(?<![가와해]서\s)(?:줘|줘요|주세요|주십시오|줄래|주실래|주라|주게|주이소|봐|봐요|보세요)(?![가-힣]))|(?<=다가)\s+") # "들고 ", "가서 ": a verb
# joining two steps, not a quote # joining two steps, not a quote
def _norm(text, markers=()): def _norm(text, markers=()):
@@ -73,6 +78,11 @@ _SAME = [ # wordings read as the plain one (the blind mission sets, 2026-10-22
r"|\buntil you(?:'re| are) told to (?:go on|continue|move on)\b", "until i tell you to go on"), 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*(?:가라고|하라고|가도 된다고)\s*(?:할|하실|말할)\s*때까지\s*(?:거기서\s*)?", ""),
(r"(?<=\S)까지\s*(?=갔다 ?와|다녀와)", " "), # "p4까지 갔다 와요" = "p4 갔다 와요" (r"(?<=\S)까지\s*(?=갔다 ?와|다녀와)", " "), # "p4까지 갔다 와요" = "p4 갔다 와요"
(r"컴백\s*(?:하|해)\S*|컴 ?백(?=[\s,.!?]|$)", "돌아와"), (r"오더(?:를)?\s*(?=받)", "지시 "), # Konglish
(r"원 ?서클\s*(?=돌)", "한 바퀴 "), (r"\bwait\s*(?:하고|해서)", "기다리고"),
(r"\b((?:give|hand|take|bring|send) (?:it|this|that) |go |head |come )too\b", r"\1to"), # whisper's "too"
(r"웨이트\s*(?:하고|해서|했다가)", "기다리고"), (r"웨이트\s*해\S*", "기다려"),
(r"(?<=[가-힣a-z0-9_])(에|로|으로)\s*고\s*해서", r"\1 가서"), (r"들렀다가|들렀다 ?(?=와)", "갔다가"),
(r"돌아오(?:세요|십시오)", "돌아와"), (r"(?:이리로|여기로|이쪽으로)\s*돌아와", "돌아와"), (r"돌아오(?:세요|십시오)", "돌아와"), (r"(?:이리로|여기로|이쪽으로)\s*돌아와", "돌아와"),
] ]
_AFTER_KO = {"간": "가고", "온": "오고", "집은": "집고", "잡은": "잡고", "든": "들고", "받은": "받고", "준": "주고", "놓은": "놓고", _AFTER_KO = {"간": "가고", "온": "오고", "집은": "집고", "잡은": "잡고", "든": "들고", "받은": "받고", "준": "주고", "놓은": "놓고",
@@ -89,7 +99,7 @@ _HON_KO = [("가셔서", "가서"), ("가시고", "가고"), ("가셨다가", "
# ---------- one clause -> one step ---------- # ---------- one clause -> one step ----------
def _place(word, markers): def _place(word, markers):
"""A place word in a go clause -> marker name, "here", or None (not on the map).""" """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 앞" 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) w = re.sub(r"^(?:either |the |your |my |point |marker |포인트 ?)", "", word)
exact = next((mk for mk in markers if wording._key(mk) == wording._key(w)), None) # "coffee_corner", "부스 3" exact = next((mk for mk in markers if wording._key(mk) == wording._key(w)), None) # "coffee_corner", "부스 3"
if exact: if exact:
@@ -294,12 +304,17 @@ def _give(c):
if re.fullmatch(rf"(?:give|hand) (?:it|that|this|the (?:(?:{COL}) )?(?:{OBJ})s?)?(?: over)?" if re.fullmatch(rf"(?:give|hand) (?:it|that|this|the (?:(?:{COL}) )?(?:{OBJ})s?)?(?: over)?"
rf"(?: to (?:me|you|{_PEOPLE}|the person there|whoever is(?: there)?|anyone(?: there)?|anybody(?: there)?|" rf"(?: to (?:me|you|{_PEOPLE}|the person there|whoever is(?: there)?|anyone(?: there)?|anybody(?: there)?|"
rf"the (?:first )?(?:person|one) you (?:see|meet)))?(?: there)?" rf"the (?:first )?(?:person|one) you (?:see|meet)))?(?: there)?"
r"|wait (?:there )?(?:until|till) (?:someone|somebody|anyone|they|he|she) takes? it(?: from you)?" rf"|wait (?:there )?(?:until|till) (?:someone|somebody|anyone|they|he|she) (?:takes?|comes? (?:and|to) (?:take|get)s?) "
rf"(?:it|the (?:(?:{COL}) )?(?:{OBJ})s?)(?: from you)?"
r"|(?:누가|누군가|사람이|손님이|그 사람이|그분이)\s*(?:(?:그거|그걸|컵을?|이거)\s*)?(?:가져갈|받을|가지러 올|찾으러 올)\s*때까지\s*"
r"(?:기다려|기다리고|기다렸다가|대기해|있어)"
r"|hand it over|(?:give|hand) it", c) or \ r"|hand it over|(?:give|hand) it", c) or \
re.fullmatch(rf"(?:그거|그것을?|(?:(?:{COL})\s*)?(?:{OBJ})(?:을|를)?)?\s*(?:줘|주고|주세요|건네 ?줘|건네주고|" re.fullmatch(rf"(?:그거|그것을?|(?:(?:{COL})\s*)?(?:{OBJ})(?:을|를)?)?\s*(?:줘|주고|주세요|건네 ?줘|건네주고|"
rf"건네 ?주세요|건네|전해 ?줘|전해 ?주고|전해 ?주세요|전해)", c): rf"건네 ?주세요|건네|전해 ?줘|전해 ?주고|전해 ?주세요|전해)", c):
return {"do": "give"} return {"do": "give"}
if re.fullmatch(r"(?:거기 (?:있는|계신)\s*)?(?:나한테|저한테|나에게|저에게|그 사람한테|사람한테|그분께|분께|분한테)\s*" if re.fullmatch(r"(?:나|저) (?:줘|주세요|주고)", c) or \
re.fullmatch(r"(?:(?:그거|그걸|이거|이걸)\s+)?(?:거기 (?:있는|계신)\s*)?(?:나한테|저한테|나에게|저에게|(?:그|저|이) ?사람(?:한테|에게)|사람한테|"
r"(?:그|저|이) ?분(?:께|한테)|분께|분한테)\s*"
rf"(?:(?:이거|그거|이것|그것|이걸|그걸|(?:(?:이|그)\s*)?(?:{OBJ})(?:을|를)?)\s*)?" rf"(?:(?:이거|그거|이것|그것|이걸|그걸|(?:(?:이|그)\s*)?(?:{OBJ})(?:을|를)?)\s*)?"
r"(?:줘|주고|주세요|건네|건네줘|건네주고|건네주세요|건네 ?줘|건네 ?주세요|드려|드리고|갖다 ?줘|갖다 ?주세요)", c) or \ r"(?:줘|주고|주세요|건네|건네줘|건네주고|건네주세요|건네 ?줘|건네 ?주세요|드려|드리고|갖다 ?줘|갖다 ?주세요)", c) or \
re.fullmatch(r"(?:이|그|저|두|세|네) ?분(?:께|한테|에게)\s*(?:줘|주고|드려|드리고|건네|건네 ?줘|건네 ?드려)", c): re.fullmatch(r"(?:이|그|저|두|세|네) ?분(?:께|한테|에게)\s*(?:줘|주고|드려|드리고|건네|건네 ?줘|건네 ?드려)", c):
@@ -407,12 +422,12 @@ def _wait(c, markers, after):
m = re.fullmatch(rf"(?:(.+?)에서\s*)?(?:(\d+(?:\.\d+)?) s\s*(?:동안|정도|만)?\s*)?{_KO_GIVER}\s*(?:({COL})\s*)?({OBJ}|물건|뭔가|무언가|그거|뭐|무엇을|뭘|이거)?\s*" m = re.fullmatch(rf"(?:(.+?)에서\s*)?(?:(\d+(?:\.\d+)?) s\s*(?:동안|정도|만)?\s*)?{_KO_GIVER}\s*(?:({COL})\s*)?({OBJ}|물건|뭔가|무언가|그거|뭐|무엇을|뭘|이거)?\s*"
r"(?:을|를)?\s*(?:주면|건네주면|건네면|갖다주면|가져다주면|가져다 주면|줄 때까지|건네줄 때까지|줄 거야|" r"(?:을|를)?\s*(?:주면|건네주면|건네면|갖다주면|가져다주면|가져다 주면|줄 때까지|건네줄 때까지|줄 거야|"
r"줄 거예요|가져올 거야)\s*(?:기다렸다가|기다려서|기다리고|기다려|기다려요)?\s*" r"줄 거예요|가져올 거야)\s*(?:기다렸다가|기다려서|기다리고|기다려|기다려요)?\s*"
r"(받아서|받아|받고|받아와|받아 와|받아요)?", c) r"(받아서|받아 ?가지고 ?와|받아 ?가지고|받아|받고|받아와|받아 와|받아요)?", c)
if m and (m.group(1) is None or _at_place(m.group(1), markers)): if m and (m.group(1) is None or _at_place(m.group(1), markers)):
obj = brain.OBJECTS.get(m.group(4) or "") obj = brain.OBJECTS.get(m.group(4) or "")
return ([{"do": "go", "to": _at_place(m.group(1), markers)}] if m.group(1) else []) + \ return ([{"do": "go", "to": _at_place(m.group(1), markers)}] if m.group(1) else []) + \
[{"do": "receive", "object": obj, "wait_s": float(m.group(2)) if m.group(2) else WAIT_GIVE_S}] + \ [{"do": "receive", "object": obj, "wait_s": float(m.group(2)) if m.group(2) else WAIT_GIVE_S}] + \
([{"do": "go", "to": "here"}] if m.group(5) in ("받아 와", "받아와") else []) ([{"do": "go", "to": "here"}] if re.fullmatch(r"받아 ?(?:가지고 ?)?와", m.group(5) or "") else [])
if after and re.fullmatch(r"(?:거기|여기)(?:서|에서)", c): if after and re.fullmatch(r"(?:거기|여기)(?:서|에서)", c):
return [] # "p3로 가서 | 거기서 | 기다려": the place of the next step return [] # "p3로 가서 | 거기서 | 기다려": the place of the next step
if after and after["do"] == "receive" and after.get("wait_s") and re.fullmatch(r"받아서|받아|받고|받아 와|받아와|받아요", c): if after and after["do"] == "receive" and after.get("wait_s") and re.fullmatch(r"받아서|받아|받고|받아 와|받아와|받아요", c):
@@ -461,10 +476,10 @@ def _wait(c, markers, after):
_POLITE = re.compile(r"(?<=[가-힣])\s*(?:주십시오|주시겠어요|주시겠습니까|주실 수 있나요|주실 수 있습니까|주실 수 있어요|" _POLITE = re.compile(r"(?<=[가-힣])\s*(?:주십시오|주시겠어요|주시겠습니까|주실 수 있나요|주실 수 있습니까|주실 수 있어요|"
r"줄 수 있어요|줄 수 있어|주실래요|줄래요?|줘 ?봐요?|줘요?|주세요|죠)\??$") # every speech level r"줄 수 있어요|줄 수 있어|주실래요|줄래요?|줘 ?봐요?|줘요?|주세요|주라|죠)\??$") # every speech level
_HONORIFIC = [(r"(가|와|놔|돌아|집어|잡어|잡아|들어|줘) ?봐요?$", r"\1"), # "가봐", "놔 봐": try / do it _HONORIFIC = [(r"(가|와|놔|돌아|집어|잡어|잡아|들어|줘) ?봐요?$", r"\1"), # "가봐", "놔 봐": try / do it
(r"(?<=[가-힣]) ?주시고$", "고"), (r"(?<=[가-힣]) ?주셔서$", "서"), # "가 주시고": 가고 (r"(?<=[가-힣]) ?주시고$", "고"), (r"(?<=[가-힣]) ?주셔서$", "서"), # "가 주시고": 가고
(r"가(?:십시오|세요|시죠|요)$", "가"), (r"오(?:십시오|세요|시죠)$", "와"), (r"도(?:십시오|세요)$", "돌아"), (r"가(?:십시오|세요|시죠|요)$", "가"), (r"((?:으로|로|에) )가게나?$", r"\1가"), (r"오(?:십시오|세요|시죠)$", "와"), (r"도(?:십시오|세요)$", "돌아"),
(r"드리(?:십시오|세요)$", "드려"), (r"(?:주|드리)십시오$", "줘"), (r"물러나(?:세요|십시오|요)?$", "가"), (r"드리(?:십시오|세요)$", "드려"), (r"(?:주|드리)십시오$", "줘"), (r"물러나(?:세요|십시오|요)?$", "가"),
(r"회전(?:해|하세요|하십시오|해요)$", "돌아"), (r"말씀(?:해|하세요|하십시오|해요|해 주세요)$", "말해"), (r"회전(?:해|하세요|하십시오|해요)$", "돌아"), (r"말씀(?:해|하세요|하십시오|해요|해 주세요)$", "말해"),
(r"놓으(?:십시오|세요)$", "놔"), (r"기다리(?:십시오|세요|시죠|셔요)$", "기다려"), (r"놓으(?:십시오|세요)$", "놔"), (r"기다리(?:십시오|세요|시죠|셔요)$", "기다려"),
@@ -684,9 +699,10 @@ def _clause(c, markers, after=None):
def _clause_steps(c, markers, after=None): def _clause_steps(c, markers, after=None):
c = re.sub(r"^(?:second(?:ly)?|third(?:ly)?|fourth|first(?:ly)?|last(?:ly)?|step \d)[\s,]+", "", c.strip(" .!?")) # "second, go to ..." c = re.sub(r"^(?:second(?:ly)?|third(?:ly)?|fourth|first(?:ly)?|last(?:ly)?|step \d)[\s,]+", "", c.strip(" .!?")) # "second, go to ..."
c = re.sub(rf"^(?:{_FILL}[\s,]+)+|(?:[\s,]+{_FILL})+$", "", c).strip(" .!?,") c = re.sub(rf"^(?:{_FILL}(?:[\s,]+|$))+|(?:[\s,]+{_FILL})+$", "", c).strip(" .!?,")
if re.search(r"[가-힣]", c): if re.search(r"[가-힣]", c):
c = re.sub(r"\s+", " ", c) c = re.sub(r"\s+", " ", wording.ko_plain(c)).strip(" .!?~") # every speech level / dialect as 반말: "돌아오게나",
c = re.sub(rf"^(?:{_FILL}(?:[\s,]+|$))+|(?:[\s,]+{_FILL})+$", "", c).strip(" .!?,~") # "가 주시겄슈" -> "돌아와", "가 줘"
c = re.sub(r"\s좀\s", " ", c) c = re.sub(r"\s좀\s", " ", c)
c = re.sub(r"^(?:야\s+)?로봇(?:아|야)?[,\s]+|^야[,\s]+(?!로봇)", "", c) # "야 로봇", "로봇아", "야": calling it c = re.sub(r"^(?:야\s+)?로봇(?:아|야)?[,\s]+|^야[,\s]+(?!로봇)", "", c) # "야 로봇", "로봇아", "야": calling it
c = c.replace("그리퍼를", "손을").replace("물러나", "뒤로 물러나") if "뒤로" not in c else c.replace("그리퍼를", "손을") c = c.replace("그리퍼를", "손을").replace("물러나", "뒤로 물러나") if "뒤로" not in c else c.replace("그리퍼를", "손을")
@@ -705,7 +721,7 @@ def _clause_steps(c, markers, after=None):
c = re.sub(r"^\S+ 말고\s+", "", c) # "미나 말고 사라한테": not Mina, Sara 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+ (?:없으니까|없어서|없대서)\s+", "", c) # "현우 없으니까 ...": the reason, not a step
c = re.sub(r"\s+(?:거기로|내가) 갈게$", "", c) 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 입구 하고" # "go to 입구 하고"
raw, c = c, _sender(c) raw, c = c, _sender(c)
if not c: if not c:
@@ -735,7 +751,8 @@ def _clause_steps(c, markers, after=None):
c = re.sub(r"\bstraight ahead\b", "forward", c) c = re.sub(r"\bstraight ahead\b", "forward", c)
c = re.sub(r"\bthe gripper\b", "your hand", c) c = re.sub(r"\bthe gripper\b", "your hand", c)
c = c.replace("그리퍼", "손") c = c.replace("그리퍼", "손")
m = re.fullmatch(r"(.+?)에 있는 (?:사람|분|손님)(?:한테|에게|께)\s*(?:갖다|가져다|건네) ?(?:줘|주고|주세요)?", c) m = re.fullmatch(r"(.+?)에 (?:있는|계신) (?:사람|분|손님)(?:한테|에게|께)\s*(?:(?:갖다|가져다|건네) ?(?:줘|주고|주세요|드려|드리고)?|"
r"줘|주고|드려|드리고)", c)
if m: if m:
to = _places(m.group(1), markers) to = _places(m.group(1), markers)
return to and len(to) == 1 and [{"do": "go", "to": to[0]}, {"do": "give"}] or None return to and len(to) == 1 and [{"do": "go", "to": to[0]}, {"do": "give"}] or None
@@ -743,6 +760,8 @@ def _clause_steps(c, markers, after=None):
if m and c != raw: if m and c != raw:
obj, col = _thing(m.group(1), m.group(2)) obj, col = _thing(m.group(1), m.group(2))
return [{"do": "pick", "object": obj, "colour": col}] return [{"do": "pick", "object": obj, "colour": col}]
if after and after["do"] in ("pick", "receive") and re.fullmatch(r"(?:여기로\s*)?(?:(?:받아|집어) ?)?(?:가져와|가지고 ?와|갖고 ?와)", c):
return [{"do": "go", "to": "here"}] # "민수한테 컵 받아서 가져와": as "bring it here"
if c in ("bring it back to me", "bring it to me", "bring it back") or \ if c in ("bring it back to me", "bring it to me", "bring it back") or \
re.fullmatch(r"(?:나한테|저한테|나에게|저에게)\s*(?:가져와|가져다 ?줘|가져와서|가져다 ?주고|가져다|갖다 ?줘|갖다)" re.fullmatch(r"(?:나한테|저한테|나에게|저에게)\s*(?:가져와|가져다 ?줘|가져와서|가져다 ?주고|가져다|갖다 ?줘|갖다)"
r"(?:요| ?주세요)?", c): r"(?:요| ?주세요)?", c):
@@ -769,10 +788,83 @@ def _clause_steps(c, markers, after=None):
if hand and hand[0] == "receive" and not (after and re.match(r"(?:just )?(?:hold|keep)\b|.*들고 ?있", c)) \ if hand and hand[0] == "receive" and not (after and re.match(r"(?:just )?(?:hold|keep)\b|.*들고 ?있", c)) \
and not re.search(r"누가|누군가|someone|somebody|something|anything|things|주면|gives?\b", c): and not re.search(r"누가|누군가|someone|somebody|something|anything|things|주면|gives?\b", c):
return [{"do": "receive", "object": hand[1], "from_hand": True}] # "take this from me", "이거 받아": from the person's hand return [{"do": "receive", "object": hand[1], "from_hand": True}] # "take this from me", "이거 받아": from the person's hand
m = re.fullmatch(rf"(?:find|look for|search for|locate|look around for) (?:the |a |an |my )?(?:({COL}) )?({OBJ})s?|"
rf"(?:(?:{COL})\s*)?(?:{OBJ})\s*(?:을|를)?\s*찾(?:아서|고|아 ?가지고)", c)
if m: # "find the red cup and bring it to me": the pick looks around
t = re.search(rf"(?:({COL})\s*)?({OBJ})", c)
obj, col = _thing(t.group(1), t.group(2))
return [{"do": "pick", "object": obj, "colour": col}]
m = re.fullmatch(r"(.+?)(?:으로|로|에) (?:가져가|가지고 가|갖고 가|들고 가)(?:서| 줘)?", c)
if m and (to := _places(m.group(1), markers)) and len(to) == 1:
return [{"do": "go", "to": to[0]}] # "피사로 가져가": as "take it to p4"
s = _place_at(c, markers) or _fetch_clause(c, markers)
if s:
return s
s = _place_step(c) or _say(c) s = _place_step(c) or _say(c)
return [s] if s else None return [s] if s else None
_PUT_KO = r"(?:놔|놓아|놓고|내려놔|내려 ?놓고|둬|두고|놔두고|놔둬|올려 ?놔|올려 ?놓고)"
_GIVE_AT_KO = r"(?:갖다 ?주고|갖다 ?줘|가져다 ?주고|가져다 ?줘|갖다 ?드리고|갖다 ?드려|전해 ?주고|전해 ?줘|배달해 ?주고|배달해)"
def _place_at(c, markers):
""""put it on p3", "deliver the cup to p5", "컵을 p5에 갖다 놓고", "p3에 갖다 줘": (the named thing picked here,) a
drive there, then put down (put / leave / 놔) or handed over (deliver / 갖다 줘). None otherwise."""
m = re.fullmatch(rf"(put|place|set|leave|drop|deliver|drop off) (?:it|that|this|the ((?:(?:{COL}) )?(?:{OBJ}))s?)"
r"(?: down| off)? (?:on|at|in|to) (?:the )?(.+?)", c)
if m:
verb, thing, where = m.groups()
else:
m = re.fullmatch(rf"(?:(?:이거|그거|이걸|그걸|((?:(?:{COL})\s*)?(?:{OBJ}))(?:을|를)?)\s+)?(.+?)(?:에다가?|에|로|으로) "
rf"(?:(갖다|가져다|가져가서) ?)?({_PUT_KO}|{_GIVE_AT_KO})(?: 줘| 주고)?", c)
if not m or (m.group(4) in ("갖다 줘", "갖다줘", "가져다 줘", "가져다줘") and not m.group(1)):
return None # "p3에 갖다 줘" alone: a fetch / give, not this
thing, where = m.group(1), m.group(2)
verb = "put" if re.fullmatch(_PUT_KO, m.group(4)) else "deliver"
to = _places(where, markers)
if not to or len(to) != 1 or to == ["here"]:
return None
pick = []
if thing:
t = re.fullmatch(rf"(?:({COL})\s*)?({OBJ})", thing.strip())
obj, col = _thing(t.group(1), t.group(2))
pick = [{"do": "pick", "object": obj, "colour": col}]
return pick + [{"do": "go", "to": to[0]}, {"do": "give"} if verb == "deliver" else {"do": "place", "on": None}]
_FETCH_VERB = re.compile(r"\b(?:bring|fetch|get|carry|move)\b|가져|갖다|가지고|갖고|옮겨")
def _fetch_clause(c, markers):
"""A whole fetch said as one part of several ("bring me the cup from p2 and then go home", "p1에서 병 가져다 p2에
놔 주고 ..."): brain.parse_fetch's reading as steps, only when it names the object and every place it names."""
if not _FETCH_VERB.search(c) or brain.not_an_order(c, asked=True) or not (
re.match(r"(?:(?:please|just|go and|go) )?(?:bring|fetch|get|carry|move|take|grab)\b", c) or
re.search(r"(?:가져와|가져와서|가져다 ?(?:줘|주고|놔|놓고)?|가져다가|갖다 ?(?:줘|주고|놔|놓고)|갖다가|가지고 ?와(?:서)?|"
r"갖고 ?와(?:서)?|챙겨 ?와(?:서)?|옮겨(?: ?줘| ?주고| ?와| ?놔)?|들고 ?와(?:서)?|주시고|(?<!갖)(?<!가지)고)$", c)):
return None # an order said now, not "did you bring ...", "I'll bring ..."
c = re.sub(r"(?<=[가-힣]) ?고$", " 주고", c) if re.search(r"(?:갖다|가져다)고$", c) else c # "가져다 주시고" (_HONORIFIC)
task, problems = brain.parse_fetch(c, markers)
src, dest = task["source"], task["dest"]
if problems == ["dest"] and isinstance(src, dict) and re.search(r"(?:다가|서|고)$", c):
return [{"do": "go", "to": src["marker"]}, {"do": "pick", "object": task["object"], "colour": task["colour"],
**({"prefer": task["prefer"]} if task.get("prefer") else {})}] # "p1에서 컵 가져다가 | p3에 놔"
if problems or src == "here" and dest == "here":
return None
out = [{"do": "go", "to": src["marker"]}] if isinstance(src, dict) else []
out.append({"do": "pick", "object": task["object"], "colour": task["colour"],
**({"prefer": task["prefer"]} if task.get("prefer") else {})})
out.append({"do": "go", "to": dest["marker"] if isinstance(dest, dict) else "here"} |
({"implied": True} if dest == "here" and re.search(r"(?:와서|다가|가지고|갖고)$", c) else {})) # "가져와서 | p6로": no
# trip back first
if task["finish"] == "place":
out.append({"do": "place", "on": None})
elif dest == "here" and not re.search(r"(?:와서|다가|가지고|갖고)$", c): # "가져와서 | p3에 있는 사람한테 줘"
out.append({"do": "give", "fetch_give": True}) # handed over only when more follows (rules); the plain fetch
return out # holds it here
# ---------- whole commands ---------- # ---------- whole commands ----------
_STEP_VERB = (r"(?:go|come|drive|head|return|give|hand|put|place|set|leave|take|pick|grab|get|bring|carry|turn|move|" _STEP_VERB = (r"(?:go|come|drive|head|return|give|hand|put|place|set|leave|take|pick|grab|get|bring|carry|turn|move|"
r"wait|hold|keep|open|close|reach|fold|receive|ask|find|look for)\b") r"wait|hold|keep|open|close|reach|fold|receive|ask|find|look for)\b")
@@ -801,8 +893,9 @@ def _split(t, markers=()):
for part in _SPLIT.split(t): for part in _SPLIT.split(t):
pieces = [] pieces = []
for p in _SPLIT_KO.split(part): for p in _SPLIT_KO.split(part):
if pieces and ends and re.search(rf"(?<![가-힣])(?:{'|'.join(ends)})$", pieces[-1]): if pieces and ends and re.search(rf"(?<![가-힣])(?:{'|'.join(ends)})$", pieces[-1]) or \
pieces[-1] += " " + p pieces and re.search(r"(?:갖고|가지고)$", pieces[-1]) and re.match(r"(?:와|오)", p):
pieces[-1] += " " + p # "갖고 와": one verb (bring), not "take it | come"
else: else:
pieces.append(p) pieces.append(p)
out += [p for p in pieces if p.strip()] out += [p for p in pieces if p.strip()]
@@ -851,6 +944,11 @@ def _pieces(c, markers, after):
def rules(text, markers=()): def rules(text, markers=()):
"""(steps, unread clauses). Steps are merged where two clauses mean one ("look for the table" + "put it there").""" """(steps, unread clauses). Steps are merged where two clauses mean one ("look for the table" + "put it there")."""
text = re.sub(r"(?<=[가-힣A-Za-z0-9])(으로|로|에)(가서|가고|가면)(?=[가-힣])", r"\1 \2 ", text or "") # written without text = re.sub(r"(?<=[가-힣A-Za-z0-9])(으로|로|에)(가서|가고|가면)(?=[가-힣])", r"\1 \2 ", text or "") # written without
if re.search(r"[가-힣]{9,}", text): # Korean written without spaces: "피사에가서5분있다가다시오세요"
text = re.sub(r"(실례지만|죄송한데요|가서|와서|돌고|있다가|기다렸다가|기다리고|갔다가|하고|해서|집어서|잡아서|집고|잡고|들고|"
r"받아서|받고|다시)(?=[가-힣\d])|(?<=[가-힣\d]에)(?=있는|계신)|(?<=있는|계신)(?=[가-힣])", r"\1 ", text)
text = re.sub(r"(?<=[가-힣])(?=\d)|(?<=\d[초분])(?=[가-힣])|(?<=다시)(?=[와오])|(?<=[아어와여해])(?=주(?:세요|시|라|십|실|게))",
" ", text)
cut, says = _cut_says(text) # spaces: "부스A로가서저희" cut, says = _cut_says(text) # spaces: "부스A로가서저희"
t = _protect_lists(_norm(cut, markers), markers) t = _protect_lists(_norm(cut, markers), markers)
t = _INTERJECTION.sub("", t) t = _INTERJECTION.sub("", t)
@@ -889,6 +987,8 @@ def rules(text, markers=()):
steps.append(s) steps.append(s)
steps = [s for i, s in enumerate(steps) # "bring it" then a place to go: no trip back first steps = [s for i, s in enumerate(steps) # "bring it" then a place to go: no trip back first
if not (s.pop("implied", False) and i + 1 < len(steps) and steps[i + 1]["do"] == "go")] if not (s.pop("implied", False) and i + 1 < len(steps) and steps[i + 1]["do"] == "go")]
steps = [s for i, s in enumerate(steps) if not (s.pop("fetch_give", False) and
(i == len(steps) - 1 or steps[i + 1]["do"] in ("wait", "place")))]
steps, unread = _people(steps, unread, text) steps, unread = _people(steps, unread, text)
if steps and not unread and all(s["do"] == "wait" for s in steps): if steps and not unread and all(s["do"] == "wait" for s in steps):
return [], [text.strip()] # "hold on a second", "wait here": talk to me, not a task return [], [text.strip()] # "hold on a second", "wait here": talk to me, not a task
+4 -4
View File
@@ -29,11 +29,11 @@ LOUDER = re.compile(r"\blouder\b|\bspeak up\b|\b(?:can'?t|cannot|can not|couldn'
r"(?:소리|목소리)\S*\s*너무\s*작", re.I) r"(?:소리|목소리)\S*\s*너무\s*작", re.I)
QUIETER = re.compile(r"\bquieter\b|\bsofter\b|\btoo loud\b|\bnot so loud\b|\bless loud\b|\bso loud\b|" QUIETER = re.compile(r"\bquieter\b|\bsofter\b|\btoo loud\b|\bnot so loud\b|\bless loud\b|\bso loud\b|"
r"\b(?:lower|turn down|drop) (?:your |the )?(?:voice|volume|sound)\b|\b(?:volume|sound) down\b|" r"\b(?:lower|turn down|drop) (?:your |the )?(?:voice|volume|sound)\b|\b(?:volume|sound) down\b|"
r"\bturn (?:it |yourself )?down\b|\b(?:speak|talk) (?:more )?(?:quietly|softly)\b|" r"\bturn (?:it |yourself )?down\b|\btone (?:it |yourself )?down\b|\b(?:speak|talk) (?:more )?(?:quietly|softly)\b|"
r"작게|시끄러|(?:소리|볼륨|목소리)\s*(?:를|을|좀|\s)*(?:줄여|낮춰|내려)|(?:소리|목소리)\S*\s*너무\s*커", re.I) r"작게|조용조용|조곤조곤|소곤소곤|시끄러|(?:소리|볼륨|목소리)\s*(?:를|을|좀|\s)*(?:줄여|낮춰|내려)|(?:소리|목소리)\S*\s*너무\s*커", re.I)
VOICE = re.compile(r"\b(?:speak|speaking|talk|talking|say|saying|said|voice|speech|words)\b|말|얘기|이야기|목소리", re.I) VOICE = re.compile(r"\b(?:speak|speaking|talk|talking|say|saying|said|voice|speech|words)\b|말|얘기|이야기|목소리", re.I)
SLOW = re.compile(r"\b(?:slower|slowly|slow down)\b|천천히|느리게|느릿", re.I) SLOW = re.compile(r"\b(?:slower|slowly|slow down)\b|천천히|느리게|느릿|슬로우하게|슬로우리", re.I)
FAST = re.compile(r"\b(?:faster|quicker|quickly|speed up)\b|빨리|빠르게", re.I) FAST = re.compile(r"\b(?:faster|quicker|quickly|speed up)\b|빨리|빠르게|패스트하게|퀵하게", re.I)
TOO_FAST = re.compile(r"\b(?:too|so) fast\b|(?:너무|넘)\s*빨라|빠르네|빨라요", re.I) TOO_FAST = re.compile(r"\b(?:too|so) fast\b|(?:너무|넘)\s*빨라|빠르네|빨라요", re.I)
TOO_SLOW = re.compile(r"\b(?:too|so) slow(?:ly)?\b|(?:너무|넘)\s*느려|느리네|느려요", re.I) TOO_SLOW = re.compile(r"\b(?:too|so) slow(?:ly)?\b|(?:너무|넘)\s*느려|느리네|느려요", re.I)
DRIVE = re.compile(r"\b(?:go|going|drive|driving|move|moving|walk|come|run|follow|forward)\b|" DRIVE = re.compile(r"\b(?:go|going|drive|driving|move|moving|walk|come|run|follow|forward)\b|"
+44 -9
View File
@@ -20,7 +20,10 @@ EN_NUM = {"one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven
"ten": 10, "eleven": 11, "twelve": 12} "ten": 10, "eleven": 11, "twelve": 12}
KO_EN_NUM = {"원": 1, "투": 2, "쓰리": 3, "스리": 3, "뜨리": 3, "트리": 3, "포": 4, "파이브": 5, "화이브": 5, KO_EN_NUM = {"원": 1, "투": 2, "쓰리": 3, "스리": 3, "뜨리": 3, "트리": 3, "포": 4, "파이브": 5, "화이브": 5,
"식스": 6, "씩스": 6, "세븐": 7, "쎄븐": 7, "에잇": 8, "에이트": 8, "나인": 9, "텐": 10, "일레븐": 11, "식스": 6, "씩스": 6, "세븐": 7, "쎄븐": 7, "에잇": 8, "에이트": 8, "나인": 9, "텐": 10, "일레븐": 11,
"트웰브": 12} # English numbers said in Korean ("피쓰리", "포인트 원") "트웰브": 12, "써틴": 13, "서틴": 13, "포틴": 14, "피프틴": 15, "휘프틴": 15, "식스틴": 16, "세븐틴": 17,
"에이틴": 18, "나인틴": 19} # English numbers said in Korean ("피쓰리", "포인트 원")
KO_EN_TENS = {"트웬티": 20, "트웨니": 20, "써티": 30, "서티": 30, "포티": 40, "피프티": 50, "휘프티": 50, "식스티": 60,
"세븐티": 70, "에이티": 80, "나인티": 90} # before a unit only (numbers): "에이티 센티"
NATIVE = {"한": 1, "두": 2, "세": 3, "네": 4, "다섯": 5, "여섯": 6, "일곱": 7, "여덟": 8, "아홉": 9, "열": 10} NATIVE = {"한": 1, "두": 2, "세": 3, "네": 4, "다섯": 5, "여섯": 6, "일곱": 7, "여덟": 8, "아홉": 9, "열": 10}
SINO = {"일": 1, "이": 2, "삼": 3, "사": 4, "오": 5, "육": 6, "륙": 6, "칠": 7, "팔": 8, "구": 9} SINO = {"일": 1, "이": 2, "삼": 3, "사": 4, "오": 5, "육": 6, "륙": 6, "칠": 7, "팔": 8, "구": 9}
_D = "[일이삼사오육륙칠팔구]" _D = "[일이삼사오육륙칠팔구]"
@@ -112,6 +115,12 @@ def markers(t):
def numbers(t): def numbers(t):
"""Distances and angles in lower-case text -> digits and metres: "half a meter" -> "0.5 m", "오십 센치" -> "0.5 m", """Distances and angles in lower-case text -> digits and metres: "half a meter" -> "0.5 m", "오십 센치" -> "0.5 m",
"일 미터 반" -> "1.5 m", "구십 도" -> "90도".""" "일 미터 반" -> "1.5 m", "구십 도" -> "90도"."""
t = re.sub(rf"(?<![가-힣])(?:({'|'.join(KO_EN_TENS)})\s?)?({'|'.join(sorted(KO_EN_NUM, key=len, reverse=True))})?"
rf"(?<=[가-힣])\s*(?=(?:{UNIT}|도|degrees?|디그리스?)(?![a-z가-힣]))",
lambda m: f"{KO_EN_TENS.get(m.group(1), 0) + KO_EN_NUM.get(m.group(2), 0)} "
if m.group(1) or m.group(2) else m.group(0), t)
# Konglish amounts: "텐 센치", "에이티 센티", "트웬티 파이브 도"
t = re.sub(r"(\d+)\s*디그리스?(?![가-힣])", r"\1도", t) # "피프틴 디그리"
t = re.sub(r"\bone and a half\b", "1.5", t) t = re.sub(r"\bone and a half\b", "1.5", t)
t = re.sub(rf"\b({'|'.join(TENS)})(?:[ -]({'|'.join(list(EN_NUM)[:9])}))?\b", t = re.sub(rf"\b({'|'.join(TENS)})(?:[ -]({'|'.join(list(EN_NUM)[:9])}))?\b",
lambda m: str(TENS[m.group(1)] + EN_NUM.get(m.group(2), 0)), t) lambda m: str(TENS[m.group(1)] + EN_NUM.get(m.group(2), 0)), t)
@@ -122,7 +131,7 @@ def numbers(t):
lambda m: str(1000 * _num(m.group(1)) if m.group(1) else 1000), t) # "a thousand", "five thousand" lambda m: str(1000 * _num(m.group(1)) if m.group(1) else 1000), t) # "a thousand", "five thousand"
t = re.sub(rf"\b([2-9]|{'|'.join(list(EN_NUM)[1:9])}) hundred(?: and)?(?: (\d+))?\b", t = re.sub(rf"\b([2-9]|{'|'.join(list(EN_NUM)[1:9])}) hundred(?: and)?(?: (\d+))?\b",
lambda m: str(100 * _num(m.group(1)) + int(m.group(2) or 0)), t) # "two hundred and fifty" lambda m: str(100 * _num(m.group(1)) + int(m.group(2) or 0)), t) # "two hundred and fifty"
t = re.sub(rf"\b({'|'.join(TEEN)}|eleven|twelve)\b(?=\s*{UNIT}(?![a-z]))", t = re.sub(rf"\b({'|'.join(TEEN)}|eleven|twelve)\b(?=\s*(?:{UNIT}(?![a-z])|degrees?\b|도(?![가-힣])))",
lambda m: str(TEEN.get(m.group(1)) or EN_NUM[m.group(1)]), t) # "fifteen centimetres" lambda m: str(TEEN.get(m.group(1)) or EN_NUM[m.group(1)]), t) # "fifteen centimetres"
t = re.sub(r"\b(?:a|one) hundred(?: and)? (\d+)\b", lambda m: str(100 + int(m.group(1))), t) t = re.sub(r"\b(?:a|one) hundred(?: and)? (\d+)\b", lambda m: str(100 + int(m.group(1))), t)
t = re.sub(r"\b(?:a|one) hundred\b", "100", t) t = re.sub(r"\b(?:a|one) hundred\b", "100", t)
@@ -143,11 +152,16 @@ def numbers(t):
t = re.sub(rf"(?:(?<=으로)|(?<=로))\s*({_SINO})\s*도(?![가-힣])", lambda m: f" {sino(m.group(1))}도", t) t = re.sub(rf"(?:(?<=으로)|(?<=로))\s*({_SINO})\s*도(?![가-힣])", lambda m: f" {sino(m.group(1))}도", t)
t = re.sub(rf"(?<![가-힣\d])({_SINO})\s*도(?=\s+(?:왼쪽|오른쪽|뒤로|돌))", lambda m: f"{sino(m.group(1))}도", t) t = re.sub(rf"(?<![가-힣\d])({_SINO})\s*도(?=\s+(?:왼쪽|오른쪽|뒤로|돌))", lambda m: f"{sino(m.group(1))}도", t)
t = re.sub(r"(\d+)\s*degrees?(?=\s*[가-힣])", r"\1도", t) # "왼쪽으로 45 degrees 돌아" t = re.sub(r"(\d+)\s*degrees?(?=\s*[가-힣])", r"\1도", t) # "왼쪽으로 45 degrees 돌아"
t = re.sub(r"(?<![\d.])(\d+) 도(?=\s+(?:왼|오른|위|아래|밑|좌|우|뒤|돌|회전|틀|꺾))", r"\1도", t) # "고개를 90 도 오른쪽으로"
t = re.sub(rf"(?:^|(?<=으로)|(?<=[~,\s몸]))({_SINO})\s*도(?=\s*(?:왼|오른|좌|우|회전|돌|틀|꺾|만|쯤|정도|얼른|빨리|천천히|살짝|좀|퍼뜩|언능))",
lambda m: f"{sino(m.group(1))}도 ", t) # written together: "왼쪽으로십오도회전해"
t = re.sub(r"(?<![\d.])(\d+) ?(?:m|미터)\s?([1-9])0(?![\d.]|\s*(?:센|cm|밀|mm|미|m\b|도))(?=\s*(?:만|쯤|정도)?\s*(?:[가-힣]|$))",
lambda m: f"{m.group(1)}.{m.group(2)} m", t) # "1미터 50" is 1.5 m
t = re.sub(rf"\bhalf (?:a |an )?{UNIT}", "0.5 m", t) t = re.sub(rf"\bhalf (?:a |an )?{UNIT}", "0.5 m", t)
t = re.sub(rf"반\s*{UNIT}", "0.5 m", t) t = re.sub(rf"반\s*{UNIT}", "0.5 m", t)
for w, d in NUM_WORDS.items(): for w, d in NUM_WORDS.items():
if w.isascii(): if w.isascii():
t = re.sub(rf"\b{w}\b(?=\s*(?:{UNIT}(?![a-z])|degrees?|and a (?:half|0\.5)))", d, t) # "one meter", "a meter" t = re.sub(rf"\b{w}\b(?=\s*(?:{UNIT}(?![a-z])|degrees?|도(?![가-힣])|and a (?:half|0\.5)))", d, t) # "one meter", "a meter"
else: else:
t = re.sub(rf"(?<![가-힣]){w}\s*(?={UNIT})", d + " ", t) t = re.sub(rf"(?<![가-힣]){w}\s*(?={UNIT})", d + " ", t)
t = re.sub(rf"(?<![\d.])0(\d)\s*(?={UNIT}(?![a-z]))", r"0.\1 ", t) # whisper's "05 meters": 0.5 m t = re.sub(rf"(?<![\d.])0(\d)\s*(?={UNIT}(?![a-z]))", r"0.\1 ", t) # whisper's "05 meters": 0.5 m
@@ -274,7 +288,7 @@ ASR_SLIPS = [ # how whisper writes Korean commands (tests/asr_check.py, 2026-1
(r"([a-z0-9])\.?\s+(으로|로)\s*(?=가|와|이동|돌아)", r"\1\2 "), # "P3. 로가줘", "final point. 로 가": one word (r"([a-z0-9])\.?\s+(으로|로)\s*(?=가|와|이동|돌아)", r"\1\2 "), # "P3. 로가줘", "final point. 로 가": one word
(r"(?<=로)\s*가죠(?![가-힣])", " 가 줘"), # "p3로 가 줘" written "p3로 가죠" (r"(?<=로)\s*가죠(?![가-힣])", " 가 줘"), # "p3로 가 줘" written "p3로 가죠"
(r"\blook (?:last|lest|less)(?=[\s.!,]*$)", "look left"), (r"\bdoc t\b", "dock 2"), # said at the end (r"\blook (?:last|lest|less)(?=[\s.!,]*$)", "look left"), (r"\bdoc t\b", "dock 2"), # said at the end
(r"고게(?=\s*(?:들|숙))", "고개"), (r"찝어", "집어"), (r"파이나(?=\s*(?:갔|가|로))", "파이널"), (r"고게(?=\s*(?:들|숙)|[를는도가]?\s)", "고개"), (r"찝어", "집어"), (r"파이나(?=\s*(?:갔|가|로))", "파이널"),
# the owner's English as whisper wrote it live (logs/lumi.log 2026-10-21 / 22) # 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"\bcount to(?= p\s?\d)", "come to"), # "Let's count to p5."
# the head up / down, said or heard loosely (2026-10-23 15:08-15:16: "Look at the bellow.", "Look it up.") # the head up / down, said or heard loosely (2026-10-23 15:08-15:16: "Look at the bellow.", "Look it up.")
@@ -296,6 +310,10 @@ ASR_SLIPS = [ # how whisper writes Korean commands (tests/asr_check.py, 2026-1
_NO = r"(?<![가-힣a-z])" _NO = r"(?<![가-힣a-z])"
KONGLISH = [ # English direction words said in Korean -> the Korean word ("레프트로 반 미터 가 줘요", "라이트 턴 해") KONGLISH = [ # English direction words said in Korean -> the Korean word ("레프트로 반 미터 가 줘요", "라이트 턴 해")
(r"왼쭉|왼족", "왼쪽"), (r"멈처|멈쳐", "멈춰"), (r"슴니(?=다|까)", "습니"), (r"(?<![가-힣])야루미", "야 루미"),
(r"(?:쉐|셰)이크 ?핸즈?|핸드 ?쉐이크", "악수"), (r"(?<![가-힣])히어로(?= ?(?:와|오|가까이))", "이리로"),
(r"리프트 ?다운(?: ?(?:해|하(?:게나?|세요|십시오|시게|시오)?))?(?=\s|$|[?.!~,])", "몸 내려"),
(r"리프트 ?업(?: ?(?:해|하(?:게나?|세요|십시오|시게|시오)?))?(?=\s|$|[?.!~,])", "몸 올려"), # read by norm and ko_plain
(_NO + r"레프트\s*(?:쪽으로|으로|로|쪽)?", "왼쪽으로 "), (_NO + r"레프트\s*(?:쪽으로|으로|로|쪽)?", "왼쪽으로 "),
(_NO + r"라이트\s*(?:쪽으로|으로|로|쪽)(?![가-힣])|" + _NO + r"라이트(?=\s*(?:턴|turn|무브|move|\d|반\s*미터))", (_NO + r"라이트\s*(?:쪽으로|으로|로|쪽)(?![가-힣])|" + _NO + r"라이트(?=\s*(?:턴|turn|무브|move|\d|반\s*미터))",
"오른쪽으로 "), # "라이트 켜" is a light "오른쪽으로 "), # "라이트 켜" is a light
@@ -311,6 +329,7 @@ KONGLISH = [ # English direction words said in Korean -> the Korean word ("레
(r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*업(?![가-힣])", r"\1 들어"), (r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*업(?![가-힣])", r"\1 들어"),
(r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*다운(?![가-힣])", r"\1 숙여"), (r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*다운(?![가-힣])", r"\1 숙여"),
(_NO + r"헤드(?=\s)", "고개"), (_NO + r"헤드(?=\s)", "고개"),
(_NO + r"웨이스트(?=\s|를|을|는|가)", "허리"),
] ]
@@ -415,8 +434,17 @@ _END_NOT_ASKED = r"(?=(?:\s+(?:빨리|얼른|어서|좀|제발|당장|지금|ple
_HON = r"(?:세요|세용|세여|십시오|시오|셔요|시죠|실래요|실래|시겠어요|시겠습니까|시겠어|시게|이소(?:마|예)?|거라|너라|렴|라고요?|랑께요?|래이|이라|쇼|시라|시지요|실래예|씨요|세예)" _HON = r"(?:세요|세용|세여|십시오|시오|셔요|시죠|실래요|실래|시겠어요|시겠습니까|시겠어|시게|이소(?:마|예)?|거라|너라|렴|라고요?|랑께요?|래이|이라|쇼|시라|시지요|실래예|씨요|세예)"
_LOOK_AT = r"(왼쪽|오른쪽|위|위쪽|아래|아래쪽|뒤|뒤쪽|앞|하늘|천장|바닥|여기|이쪽|저쪽|나|날|저|정면|좌측|우측)" _LOOK_AT = r"(왼쪽|오른쪽|위|위쪽|아래|아래쪽|뒤|뒤쪽|앞|하늘|천장|바닥|여기|이쪽|저쪽|나|날|저|정면|좌측|우측)"
KO_PLAIN = [ KO_PLAIN = [
*((re.compile(a), b) for a, b in KONGLISH[:8]), # slips / Konglish above
(re.compile(r"(?<=[가-힣?!.~]) +(?:허허|하하|헤헤|호호|히히|ㅋ+|ㅎ+)[\s!.~]*$"), ""), # a laugh after it: "돌아 봐요 허허"
(re.compile(r"(?<![가-힣])(?:퍼뜩|퍼떡|언능|얼렁|싸게싸게)(?![가-힣])"), "빨리"), # dialect "quickly"
(re.compile(r"(?<=봐) 봐(?=\s*(?:[,.!?~…]|$))"), ""), # "돌아가 봐 봐": once
(re.compile(r"(?<=[려어아여]) (?:좀|한 ?번) (?=놔|놓|둬|두)"), " "), # "컵 내려 좀 놔 줘": a softener
(re.compile(r"(?<=[가-힣])게나(?=\s*(?:[,.!?~…]|$))"), "게"), # 하게체 "이동하게나", "주게나"
(re.compile(r"겄슈|겄어유|겠슈"), "겠어요"), (re.compile(r"(?<=[가-힣])세유(?=\s*(?:[,.!?~…]|$))"), "세요"), # 충청
(re.compile(r"(?<![가-힣])(\S*?[가-힣])(?:으)?(?:시겠어요|시겠습니까|시겠어|실래요|실래)\s*\?"), "STEMQ"),
# "회전하시겠어요?": please turn
(re.compile(r"(?<=아니 )(\S+?)(?:이요|요)(?=\s*(?:[,.!?~…]|$))"), r"\1"), # "아 아니 정면이요": the noun (re.compile(r"(?<=아니 )(\S+?)(?:이요|요)(?=\s*(?:[,.!?~…]|$))"), r"\1"), # "아 아니 정면이요": the noun
(re.compile(r"오른쭉|오른족"), "오른쪽"), (re.compile(r"(?<![가-힣])외쪽"), "왼쪽"), (re.compile(r"고게(?= )"), "고개"), (re.compile(r"오른쭉|오른족"), "오른쪽"), (re.compile(r"(?<![가-힣])외쪽"), "왼쪽"), (re.compile(r"고게(?=[를는도가]?\s)"), "고개"),
(re.compile(r"(루미야|루미씨|루미 씨)(?=[가-힣])"), r"\1 "), # "루미야오른쪽 봐" (re.compile(r"(루미야|루미씨|루미 씨)(?=[가-힣])"), r"\1 "), # "루미야오른쪽 봐"
(re.compile(r"(?<![가-힣])쫌(?![가-힣])"), "좀"), (re.compile(r"(?<![가-힣])놉여"), "높여"), (re.compile(r"(?<![가-힣])쫌(?![가-힣])"), "좀"), (re.compile(r"(?<![가-힣])놉여"), "높여"),
(re.compile(r"(?<= )주드라(?:고|구)|(?<= )주드랑께"), "줘"), # 전라: "와 주드라고" (re.compile(r"(?<= )주드라(?:고|구)|(?<= )주드랑께"), "줘"), # 전라: "와 주드라고"
@@ -429,7 +457,10 @@ KO_PLAIN = [
(re.compile(r"(\d+(?:\.\d+)?\s*(?:도|미터|센티(?:미터)?|센치|cm|m)(?![가-힣a-z]))\s+(?:좀|쫌|한번|한 번)\s+(?=[가-힣])"), r"\1 "), (re.compile(r"(\d+(?:\.\d+)?\s*(?:도|미터|센티(?:미터)?|센치|cm|m)(?![가-힣a-z]))\s+(?:좀|쫌|한번|한 번)\s+(?=[가-힣])"), r"\1 "),
# "45도 좀 돌아 줘": the amount, then the verb # "45도 좀 돌아 줘": the amount, then the verb
(re.compile(r"(?<= )조(?:잉)?(?=\s*(?:[,.!?~…]|$))"), "줘"), # "흔들어 조잉", "손 한번 조" (re.compile(r"(?<= )조(?:잉)?(?=\s*(?:[,.!?~…]|$))"), "줘"), # "흔들어 조잉", "손 한번 조"
(re.compile(r"악수 ?(?:한 ?번)? ?(?:할까요?|하실래요?|합시다|하십시다|하자잉|허자잉?|하입시더)"), "악수하자"), # shake hands = wave (re.compile(r"악수 ?(?:한 ?번)? ?(?:할까요?|하실까요?|할래요?|하시죠|하시겠어요|하실래요?|합시다|하십시다|하자잉|허자잉?|하입시더|하세|허세|합세|하시게)(?![가-힣])\s*\??"),
"악수하자"), # shake hands = wave; 하게체 "악수하세"
(re.compile(r"(?<=[어아여해줘봐와가라자워려춰켜꺼놔둬]) (?:응|엉|알았지|알겠지|알았죠|알겠죠|오케이)"
r"\s*[?!.~]*(?=\s*$)"), ""), # a tag after the order: "고개 들어 응?"
(re.compile(r"(?<=[가-힣](?:라|자)) 마(?=\s*(?:[,.!?~…]|$))"), ""), # 경상: "팔 접어 봐라 마" (re.compile(r"(?<=[가-힣](?:라|자)) 마(?=\s*(?:[,.!?~…]|$))"), ""), # 경상: "팔 접어 봐라 마"
(re.compile(_LOOK_AT + r" ?(?:한번 )?(?:바|보게)(?= 주|\s*(?:[,.!?~]|$))"), r"\1 봐"), # whisper "왼쪽바", 하게체 "하늘보게" (re.compile(_LOOK_AT + r" ?(?:한번 )?(?:바|보게)(?= 주|\s*(?:[,.!?~]|$))"), r"\1 봐"), # whisper "왼쪽바", 하게체 "하늘보게"
(re.compile(r"(\S+) ?주면 안 (?:돼|될까|되나|되겠니|되겠어|되겠습니까)(?:요)?\s*\??" + r"(?=\s*(?:[,.!~…]|$))"), r"\1 줘?"), (re.compile(r"(\S+) ?주면 안 (?:돼|될까|되나|되겠니|되겠어|되겠습니까)(?:요)?\s*\??" + r"(?=\s*(?:[,.!~…]|$))"), r"\1 줘?"),
@@ -473,7 +504,9 @@ def _stem_l(word):
if not j or j[2] != 8: if not j or j[2] != 8:
return None return None
stem = word[:-1] + _syl(j[0], j[1]) stem = word[:-1] + _syl(j[0], j[1])
return {"드": "들", "도": "돌", "여": "열", "미": "밀", "내미": "내밀", "흔드": "흔들"}.get(stem, stem) if stem.endswith("시") and len(stem) > 1 and stem not in ("다시",):
stem = stem[:-1].removesuffix("으") or stem # honorific: "트실 수" -> 트, "도실 수" -> 도, "집으실" -> 집
return {"드": "들", "도": "돌", "트": "틀", "여": "열", "미": "밀", "내미": "내밀", "흔드": "흔들"}.get(stem, stem)
def _can_you(m, kind): def _can_you(m, kind):
@@ -508,12 +541,14 @@ def ko_plain(t):
for rx, to in KO_PLAIN: for rx, to in KO_PLAIN:
if to in ("CAN_L", "CAN_N"): if to in ("CAN_L", "CAN_N"):
t = rx.sub(lambda m: _can_you(m, to), t) t = rx.sub(lambda m: _can_you(m, to), t)
elif to == "STEM": elif to in ("STEM", "STEMQ"):
def stem(m): def stem(m):
w = m.group(1) w = m.group(1)
if KO_SOCIAL_BEFORE.search(m.string[:m.start()]): if KO_SOCIAL_BEFORE.search(m.string[:m.start()]):
return m.group(0) return m.group(0)
got = _stem_aform(w[:-1] if w.endswith("으") and len(w) > 1 and _jamo(w[-2]) and _jamo(w[-2])[2] else w) got = _stem_aform(w[:-1] if w.endswith("으") and len(w) > 1 and _jamo(w[-2]) and _jamo(w[-2])[2] else w)
if to == "STEMQ" and got:
return got + ("?" if got == "줘" else " 줘?")
return got if got else m.group(0) return got if got else m.group(0)
t = rx.sub(stem, t) t = rx.sub(stem, t)
else: else:
@@ -536,7 +571,7 @@ def norm(text, names=()):
"""Lower case, whisper's slips (ASR_SLIPS), Konglish directions (KONGLISH), numbers first ("point five meters" is """Lower case, whisper's slips (ASR_SLIPS), Konglish directions (KONGLISH), numbers first ("point five meters" is
a distance), then marker names (names: the map's).""" a distance), then marker names (names: the map's)."""
t = " " + (text or "").lower().replace("’", "'") + " " t = " " + (text or "").lower().replace("’", "'") + " "
t = re.sub(r"(\S+)[—–-]+\s*(?=\1)", "", t) # a stutter: "육십 센— 센티", "go ah— ahead" t = re.sub(r"(?<!\S)(\S+)[—–-]+\s*(?=\1)", "", t) # a stutter: "육십 센— 센티", "go ah— ahead"
t = re.sub(r"(?<=[가-힣])(?=\d+(?:\.\d+)?\s*(?:미터|센티|센치|cm|m\b|도))", " ", t) # "오른쪽으로80센티미터" t = re.sub(r"(?<=[가-힣])(?=\d+(?:\.\d+)?\s*(?:미터|센티|센치|cm|m\b|도))", " ", t) # "오른쪽으로80센티미터"
for slip, said in ASR_SLIPS + KONGLISH: for slip, said in ASR_SLIPS + KONGLISH:
t = re.sub(slip, said, t) t = re.sub(slip, said, t)
+80
View File
@@ -338,3 +338,83 @@ notation, regexes, no rounds 1–6 train text, no case in both splits, and print
All r8 files after `_h`: 34754 train / 34196 held cases, 1923 train / 1965 held dialogues; unique text 96.8 % over All r8 files after `_h`: 34754 train / 34196 held cases, 1923 train / 1965 held dialogues; unique text 96.8 % over
~99,700 texts; Korean ~79 %; `logs/w3_gen/check_r8.py` 0 problems. ~99,700 texts; Korean ~79 %; `logs/w3_gen/check_r8.py` 0 problems.
## r9 (round 9, 2026-10-24/26 nights: Korean / English parity, writer W4)
`r9/train/` and `r9/held/` (train seed 91, held seed 92; growth files seeds 93 / 94), written blind from docs/14,
docs/16, docs/17 and knowledge/. The owner's goal: Korean as good as English. Every meaning of a set is said at
**every level**; every case (sing: the list `LEVELS`, missions: the value, dialogues: every turn) carries NEW field
`level`: `en_native`, `en_nonnative`, `ko_banmal` (반말), `ko_haeyo` (해요체), `ko_hasipsio` (하십시오체), `ko_honorific`
(-시-, 께서, 드리다, 여쭤보다), `ko_hage` (하게체, elderly), `ko_friendly` (친구끼리: ~, ㅎㅎ, ㅋㅋ, ~임?, ㄱㄱ), `ko_dialect`
(경상 / 전라 / 충청; field `dialect` where known), `konglish` (English words in Hangul), `mixed` (code switching). Near
misses at every level (mix `hard`: negation, ability, condition, later, reported, remark, words to others,
take-back; intents end in `:hard_<kind>`), whisper slips (mix `slip`). Formats are round 6's (r6 commands / r6
dialogues sections), NO new expect tokens. De-duplicated inside a split, held against train and both against every
earlier round's train text (exact; a dialogue's scored say used before gets a filler in front). Load as
`tests.blind.r9.<split>.<name>`.
| File | train / held | Notes |
|---|---|---|
| `commands_go`, `_move`, `_turn`, `_look`, `_lift`, `_waist` | 2842/2814, 2524/2527, 1773/1772, 2304/2290, 1225/1225, 884/884 | r6 conventions; numbers in every form (digits, 일 / 이 / 삼, 한 / 두, English words, 원 / 투 / 쓰리) |
| `commands_wave`, `_reach`, `_hand`, `_give`, `_take`, `_put`, `_bring` | 869/836, 869/864, 1006/896, 761/731, 1182/1175, 768/757, 2042/2038 | handshakes = wave, 손 줘 / give me a hand = reach; hand includes "is your hand open?" (`status \| talk`) |
| `commands_follow`, `_come`, `_point`, `_stop`, `_status`, `_voice` | 585/573, 768/753, 483/478, 812/813, 943/741, 977/959 | stop: every running action as `before`; status `_b`: near misses (don't tell, my phone's battery, words to another person, reported, later) |
| `commands_more`, `_chain`, `_detour` | 703/458, 1499/1492, 1759/1688 | more `_b`: near misses at every level; detour `_b`: "why did you stop?" at every level (`talk \| status`) |
| `commands_missions`, `commands_sing`, `speed_short` | 1495/1485, 698/580, 1263/1093 | sing `_b`: every song and the song list at every level; speed_short (≤ 3 words, `fast: True`) `_b`: every short meaning at every level + short near misses |
| `questions_world` | 6311/3659 | quick / knowledge / unknown / lookup / time meanings (field `q`) at every level; held is smaller: same-text questions were kept only in train |
| `dialogues_mixed` | 440/440 (4569/4539 scored turns) | a fact, really? / a false claim / a follow-up, a command on the dialogue's map, a near miss, status, thanks + a question, goodbye; one level per dialogue |
| `followup_dialogues` | 330/330 (2970/2970) | follow-ups on Lumi's answer, contradictions (AGREE in must_not) |
| `closing_context` | 429/414 | field `closing` end / continue |
| `seeing_dialogues` | 328/324 (1640/1620) | r6 person fields; the scene changes |
| `memory_dialogues` | 207/199 (1242/1194) | r6 memory format |
| `lookup_dialogues` | 154/154 (1279/1289) | r6 lookup format (`lookup` field per turn): weather (city / here, day, ask general / rain / temp / dust / wind), day-only / city-only follow-ups, umbrella / 몇 도 / 미세먼지 for the talk's place and day (`lookup:weather \| none`), climate knowledge (장마철, 황사, 태풍: `none` + must), a remark, near misses (already checked, don't tell me, a friend asked, a plan if it rains, news later: `none`, lookup None), news (topic, more, the second / last one), thanks + a new question, goodbye; one speaker = one dialect; the hello is not scored |
A file `<name>_b.py` is a growth file (`logs/w4_gen/gen_grow9.py`) filling the cells the first write left empty;
published files are never changed. Totals: 37345 train / 33581 held cases, 1888 train / 1861 held dialogues. Per
level (cases + scored turns) 7.5–10.1 % each (en_nonnative lowest, ko_dialect highest); near misses 19–26 % at every
level. Unique text 72 % (the same wording on several maps / states / before-actions is one text).
Generators (seeded, not in the repo): `logs/w4_gen/` on the Thor: `ko.py` (Hangul, request endings per level,
negation / ability / condition / later / reported / remark / others / take-back frames, numbers, slips), `qlib.py`
(question endings per level), `caps.py` (command meanings), `spoken9.py` (marker forms), `render.py`, `gen_cmd.py`,
`questions.py`, `gen_dlg.py`, `gen_all.py` (the first write), `gen_lookup9.py`, `gen_grow9.py`; `check_r9.py` checks
imports, fields, levels, maps / markers, expect tokens, steps, regexes, no earlier train text, no case in both splits,
and parity (every set has every level in both splits, every meaning `intent` / `q` / song at every level in both
splits, near misses at every level in every command set, dialogues_mixed and lookup_dialogues): 0 problems.
## r10 (round 10, 2026-10-26: English half, cup tasks, writer W5)
`r10/train/` and `r10/held/`, written blind from docs/14, docs/16 and docs/17 (no assistant code or bank read). The
owner's complaint: round 9 was only ~17 % English. Here English is **half of every set** (en_native 27 %, en_nonnative
23 %), the nine Korean / Konglish / mixed levels of round 9 share the other half (5.6 % each), and every meaning is said
at every level in both splits. English wordings: plain, polite and indirect ("would you mind …ing", "could you
possibly …", "I was wondering if you could …", "I need you to …"), questions that are requests ("can you …?", "how about
…ing?", "any chance you could …?"), casual, rude, long and rambling ("sorry to bother you, but …", "my hands are full,
so …"), children; non-native English (broken frames "you can …?", "I want that you …", articles dropped); accent and
whisper slips ("tern lef", "pleace", "kup", "tay bull"). Near misses at every level in every command set: negation,
ability questions that are no request ("is it possible for a robot like you to …, in general?"), condition, later,
reported, remark, words to others, take-back, hypothetical, quote (`:hard_<kind>`, expect `talk | ask`; "don't look at
me" = `action:look away | talk | ask`). Field `level` as round 9, `style` on English cases (plain, polite, direct,
question, casual, rude, long, child, nonnative, nn_whole, whole). No text in both splits, none of an earlier round's
train text (rounds 1–4, r6, r8, r9). Formats of round 9; NO new expect tokens. Load as `tests.blind.r10.<split>.<name>`.
| File | train / held | Notes |
|---|---|---|
| `commands_go`, `_move`, `_turn`, `_look`, `_lift`, `_waist` | 1754, 2036, 1372, 1975, 782, 697 (each split) | r6 conventions; amounts new to this round (move 15 / 25 / 40 / 60 / 70 cm, 2.5 / 3 m, 3.5 m refused; turn 20–150°; look 5–50°; lift 3–15 cm; waist 20 / 60 / 90°) |
| `commands_wave`, `_reach`, `_hand`, `_give`, `_take`, `_put`, `_bring` | 826, 712, 724, 526, 730, 526, 1029 | handshakes = wave, "lend me your hand" = reach; give / take / put / bring here are apples, oranges and "it" (the cups are in `commands_cup`) |
| `commands_follow`, `_come`, `_point`, `_stop`, `_status`, `_voice` | 524, 712, 473, 968, 1023 / 965, 922 | stop with every running action as `before`; status includes "what's in your hand?", "where are you taking that cup?" and near misses (my phone's battery, don't tell me) |
| `commands_more`, `_chain`, `_detour` | 853 / 846, 1402, 1282 | chain: 45 % cup chains ("pick up the cup and look at me", holding "put the cup down and give us a wave": `chain \| mission`, `parts` "pick cup", "pick red cup", "put down", "give") |
| `commands_missions` | 1800 | step notation of tests/test_steps.py; cup missions: `pick red cup \| go M \| give`, `pick cup \| go M \| place`, `go M \| receive cup wait \| go here`, `go M \| give Sarah`, `pick cup \| go M \| give \| go here`, `go M \| place \| go here`, `receive hand \| go M`, `pick white cup \| give`, `go M \| pick cup \| go here`, `pick cup \| go M \| place dining table`, plus waits, two places, an instruction wait; `?` for coffee, dancing, later, conditions (field `kind` P1–P14 / hard) |
| `commands_sing`, `speed_short` | 828 / 804, 1024 / 1000 | sing: every song at every level; speed_short ≤ 3 words, `fast: True`, every capability at every level incl. the cup ("hand it over", "set it down") |
| `commands_cup` | 11114 | NEW set, command format (scored like the other command sets). Idle: pick by colour (`action:pick red cup \| mission \| refuse`) or by which one ("the cup on the left", "the smaller cup", "제일 가까운 컵": `action:pick cup \| …`); search ("look for the red cup": `seeing \| action:look \| action:pick red cup \| mission \| action:fetch \| ask \| talk`); take from a hand (`receive \| talk`); "pass me the cup" (`mission \| action:fetch \| action:pick cup`); fetch from a marker, from one marker to another, to a named person at a marker, deliver and come back (`action:fetch \| mission`, `\| ask` for a translated marker name); "wait here until I tell you" (`talk \| stop \| ask`); "give me the cup" idle (`empty_hand \| ask \| talk \| mission \| action:fetch \| action:pick cup`). Holding (state `holding`, 44 %): give to me (`give`), to a described person ("the man in the blue shirt", "her": `give \| ask`), to a name only (`ask \| give`), put here / on a named thing / back, carry to a marker (`mission \| action:fetch \| action:go_to M`), carry and put on the table there; new orders on the way (before `("bring the cup to Sarah at the stage", "ACTION: mission")`): stop, wait here (`stop \| talk \| ask`), "no, the other table" (`place \| ask \| talk`), "give it to her instead" (`give \| ask`), "go to M instead", "never mind, bring it back". Whole-sentence corrections are not wrapped in request frames (style `whole`) |
| `dialogues_mixed` (+ `_b`) | 303 (2121 scored turns), _b 502 (2644 / 2646) | one level per dialogue; mixed: 4 commands in a talk, a near miss, status, goodbye. `_b` cup talks: (A) pick → "what are you holding?" → give (`give \| empty_hand \| none`, the checker keeps the start's hand) → thanks (`action:arm open \| give \| none`); (B) holding: put on a named table → "no, the other table" → give to a described person → a near miss; (C) fetch from a marker → stop → to a named person; (D) take from the hand → carry to a marker → "don't move until I say so" → come here → give |
| `memory_dialogues` | 161 (644 scored turns) | r6 memory format with cup memory: `seen` a cup today (where), `self.holding` a cup or nothing, a talk yesterday with the command "bring the red cup to stage"; turns: where was the cup seen, what are you holding (`status \| none`), what did I ask yesterday (cup + place), "do what we said" (`ask \| none`, the place read back) |
Totals: 36614 train / 36501 held cases, 966 / 966 dialogues; per level (cases + scored turns) English 49.8 %
(en_native 26.9, en_nonnative 22.9), each Korean / Konglish / mixed level 5.6 %. Unique text 89.8 %.
Generators (seeded, not in the repo): `logs/w5_gen/` on the Thor: `en10.py` (English frames, -ing forms, non-native
grammar, accent slips, near-miss frames), `render10.py` (a meaning at a level; Korean endings from W4's
`logs/w4_gen/ko.py` plus indirect ones), `caps10.py` (single commands), `cup10.py` (cup tasks), `gen10.py` (all command
sets, missions, chain, sing, status, more, speed_short; train and held filled cell by cell from one pool of taken
texts), `dlg10.py` (dialogues); `check_r10.py` (round 9's checks plus no held text in train and the English share):
0 problems.
+66 -4
View File
@@ -73,7 +73,7 @@ SETS = ["commands_go", "commands_move", "commands_turn", "commands_look", "comma
"commands_stop", "commands_status", "commands_chain", "commands_detour", "speed_short", "commands_sing", "commands_stop", "commands_status", "commands_chain", "commands_detour", "speed_short", "commands_sing",
"commands_missions", "seeing_dialogues", "followup_dialogues", "dialogues_mixed", "unknowns", "silence_noise", "commands_missions", "seeing_dialogues", "followup_dialogues", "dialogues_mixed", "unknowns", "silence_noise",
"hearing", "questions_world", "memory_dialogues", "commands_come", "commands_hand", "commands_point", "hearing", "questions_world", "memory_dialogues", "commands_come", "commands_hand", "commands_point",
"commands_voice", "commands_waist", "commands_more", "closing_context"] "commands_voice", "commands_waist", "commands_more", "closing_context", "lookup_dialogues"]
# commands_chain, commands_detour, speed_short, dialogues_mixed: round r2 on; # commands_chain, commands_detour, speed_short, dialogues_mixed: round r2 on;
# questions_world, memory_dialogues: r6 on. Any other file in a round's folder # questions_world, memory_dialogues: r6 on. Any other file in a round's folder
# is scored too, by the set its name grows ("commands_go_b" as commands_go) # is scored too, by the set its name grows ("commands_go_b" as commands_go)
@@ -164,6 +164,7 @@ def _persons(frames=None):
scene.snapshot = lambda cameras=None, since=None: [SCENE["now"]] if SCENE["now"] is not None else [] scene.snapshot = lambda cameras=None, since=None: [SCENE["now"]] if SCENE["now"] is not None else []
scene.things, scene.people, scene._persons = _things, _people, _persons scene.things, scene.people, scene._persons = _things, _people, _persons
scene.speaker_key = lambda d, b: 0 # scene._front's stable sort keeps _persons' order: the speaker A first (A6)
VLM_ASKED = [("glasses", r"glass|안경|선글"), ("hat", r"\bhat|\bcap\b|beanie|모자|캡"), ("hair", r"hair|머리"), VLM_ASKED = [("glasses", r"glass|안경|선글"), ("hat", r"\bhat|\bcap\b|beanie|모자|캡"), ("hair", r"hair|머리"),
("bag", r"bag|backpack|가방|배낭"), ("top_pattern", r"pattern|stripe|check|dot|print|무늬|줄무늬|체크|땡땡이"), ("bag", r"bag|backpack|가방|배낭"), ("top_pattern", r"pattern|stripe|check|dot|print|무늬|줄무늬|체크|땡땡이"),
("bottom_kind", r"jeans|trousers|pants|skirt|shorts|바지|청바지|치마|반바지"), ("bottom_kind", r"jeans|trousers|pants|skirt|shorts|바지|청바지|치마|반바지"),
@@ -222,6 +223,8 @@ def turn_route(b, say, lang, mk, state="idle", use_llm=True):
"""One turn the way lumi.answer() goes: command_check.rules (drive words, then lumi.route) with seeing.answer on """One turn the way lumi.answer() goes: command_check.rules (drive words, then lumi.route) with seeing.answer on
the fake scene; what the rules leave through dialogue_check.run_turn with the cameras' facts (and the hand) in the fake scene; what the rules leave through dialogue_check.run_turn with the cameras' facts (and the hand) in
the prompt. (route in dialogue_check's notation, reply, by). A rule's fixed line is "" (not judged).""" the prompt. (route in dialogue_check's notation, reply, by). A rule's fixed line is "" (not judged)."""
if lang not in ("en", "ko"): # r9 "mix" turns: Lumi answers in Korean or English
lang = "ko" if brain.HANGUL.search(say) else "en"
brain.FORCED_LANG["lang"] = lang brain.FORCED_LANG["lang"] = lang
said = {} said = {}
@@ -256,6 +259,9 @@ def turn_route(b, say, lang, mk, state="idle", use_llm=True):
got if got.startswith("action:") else "action:" + got) got if got.startswith("action:") else "action:" + got)
if r.startswith("action:") or r == "mission": if r.startswith("action:") or r == "mission":
b.history.append((say, f"ACTION: {r.split(':', 1)[1] if ':' in r else r}")) b.history.append((say, f"ACTION: {r.split(':', 1)[1] if ':' in r else r}"))
elif r in ("weather", "search"): # lumi.look_up keeps the question (+ WEATHER_ASKED)
b.last_lookup = say + brain.WEATHER_ASKED if r == "weather" else say
b.history.append((b.last_lookup, ""))
return r, "", "rules" return r, "", "rules"
if not use_llm: if not use_llm:
return "llm?", "", "-" return "llm?", "", "-"
@@ -452,6 +458,7 @@ def score_missions(c, old, use_llm):
got=json.loads(json.dumps(got)), unread=unread) got=json.loads(json.dumps(got)), unread=unread)
LOOKUP = {"lookup:weather": "weather", "lookup:news": "search", "lookup:web": "search"} # lookup_dialogues (r9)
FORGOT = set(__import__("assistant.memory", fromlist=["FORGOT"]).FORGOT.values()) FORGOT = set(__import__("assistant.memory", fromlist=["FORGOT"]).FORGOT.values())
@@ -483,6 +490,8 @@ def score_dialogue(d, old, use_llm, judge=False):
r, reply, by = turn_route(b, turn["say"], lang, mk, state, use_llm) r, reply, by = turn_route(b, turn["say"], lang, mk, state, use_llm)
if r == "llm?": if r == "llm?":
rows.append(row(key, "llm?" if scored else "-", "-", "", route="", reply="")) rows.append(row(key, "llm?" if scored else "-", "-", "", route="", reply=""))
if turn.get("closing"):
rows[-1]["closing"] = turn["closing"]
b.history.append((turn["say"], "")) b.history.append((turn["say"], ""))
continue continue
if r.startswith("action:give") or r.startswith("action:place"): if r.startswith("action:give") or r.startswith("action:place"):
@@ -492,7 +501,7 @@ def score_dialogue(d, old, use_llm, judge=False):
if not scored: if not scored:
rows.append(row(key, "-", by, "", route=r, reply=reply)) rows.append(row(key, "-", by, "", route=r, reply=reply))
continue continue
want = dict(turn, expect_action=" | ".join(a.strip().removeprefix("action:") want = dict(turn, expect_action=" | ".join(LOOKUP.get(a.strip(), a.strip()).removeprefix("action:")
for a in turn.get("expect_action", "none").split(" | "))) for a in turn.get("expect_action", "none").split(" | ")))
looked_up = r in ("weather", "search", "search(unsure)") and \ looked_up = r in ("weather", "search", "search(unsure)") and \
not dialogue_check.action_ok(want["expect_action"], r) # a lookup's answer is talk (not checked) not dialogue_check.action_ok(want["expect_action"], r) # a lookup's answer is talk (not checked)
@@ -512,6 +521,8 @@ def score_dialogue(d, old, use_llm, judge=False):
r, reply, by, probs, note, v = "error", repr(e), "-", [repr(e)], "", "error" r, reply, by, probs, note, v = "error", repr(e), "-", [repr(e)], "", "error"
rows.append(row(key, v, by, f"{d['topic']} t{j + 1} {turn['say']!r} -> [{r}] {reply[:120]!r} {probs}{note} " rows.append(row(key, v, by, f"{d['topic']} t{j + 1} {turn['say']!r} -> [{r}] {reply[:120]!r} {probs}{note} "
f"(check: {turn.get('check')})", route=r, reply=reply, judged=judged)) f"(check: {turn.get('check')})", route=r, reply=reply, judged=judged))
if turn.get("closing"):
rows[-1]["closing"] = turn["closing"] # closing_context: "end" / "continue", counted apart
return rows return rows
@@ -743,6 +754,7 @@ def run_set(split, name, old_rows, use_llm, cached, limit, sample=None):
rows.append(row(str(c)[:200], "error", "-", f"{str(c)[:150]} -> {e!r}")) rows.append(row(str(c)[:200], "error", "-", f"{str(c)[:150]} -> {e!r}"))
for r in rows[n:]: for r in rows[n:]:
r["lang"] = lang_of(c, r) r["lang"] = lang_of(c, r)
r["level"] = level_of(c, r)
if r["verdict"] in ("wrong", "motion", "error") and "-v" in sys.argv: if r["verdict"] in ("wrong", "motion", "error") and "-v" in sys.argv:
print(f" {r['verdict'].upper():6} {r['show'][:200]}", flush=True) print(f" {r['verdict'].upper():6} {r['show'][:200]}", flush=True)
return rows return rows
@@ -764,6 +776,56 @@ def lang_of(c, r):
return "mix" if ko and en else "ko" if ko else "en" return "mix" if ko and en else "ko" if ko else "en"
LEVEL_NAME = {"banmal": "ko_banmal", "haeyo": "ko_haeyo", "hapsyo": "ko_hasipsio", "friendly": "ko_friendly",
"honorific": "ko_honorific", "dialect": "ko_dialect"} # W2's names (r6 _i files) -> r9's
LEVEL_GUESS = [("ko_dialect", r"(?:주이소|하이소|하입시더|하이소|데이|카이|라예|랑께|허자잉|줘유|해유|줍서|헙서|마씸|아이가|머꼬|와이라|"
r"하모|맞제|그라제|했노|하노|하나\?|가\?)[.?!~]*$|잉[.?!~]*$|(?:주소|해 ?도)[.?!]*$"),
("ko_hage", r"(?:하게|주게|하네|하세|보게|오게|가게나|하시게)[.?!~]*$|자네"),
("ko_honorific", r"(?:시[어겠었]|으시|하시|주시|가시|보시|께서|드리|드릴|드려|여쭤|여쭙|계세|계십|잡수|주무|말씀)"),
("ko_hasipsio", r"(?:습니다|습니까|[가-힣]니다|[가-힣]니까|십시오|시오|하십시다)[.?!~]*$"),
("ko_friendly", r"ㅋ|ㅎㅎ|~|임\?|ㄱㄱ|ㅇㅇ|ㄹㅇ|당[.?!]*$|용[.?!]*$|쥬[.?!]*$"),
("ko_haeyo", r"요[.?!~,]*(?:\s|$)")]
def level_of(c, r):
"""The speech level of a case or a scored turn: its "level" field (r9; W2's names in r6 _i files read as r9's),
else guessed from the Korean endings (marked "*"); English "en*", mixed "mixed*"."""
turn = {}
if isinstance(c, dict) and "turns" in c and r["key"][:1].isdigit():
j = int(r["key"].split("|", 1)[0]) - 1
turn = c["turns"][j] if 0 <= j < len(c["turns"]) else {}
case = c if isinstance(c, dict) else c[1] if isinstance(c, (list, tuple)) and len(c) > 1 and \
isinstance(c[1], dict) else {}
lv = turn.get("level") or (case.get("level") if not turn or "turns" not in case else None)
if lv:
return LEVEL_NAME.get(lv, lv)
if r.get("lang") == "en":
return "en*"
if r.get("lang") == "mix":
return "mixed*"
text = turn.get("say") or case.get("text") or case.get("heard") or (c[0] if isinstance(c, (list, tuple)) else "")
text = (text or "").strip()
return next((name + "*" for name, rx in LEVEL_GUESS if re.search(rx, text)), "ko_banmal*")
def by_level(saved):
"""right / cases per speech level over every set (r9 / r6 _i: as labelled; "*": guessed from the endings), and the
closing turns (closing_context) by kind."""
lv, cl = collections.defaultdict(collections.Counter), collections.defaultdict(collections.Counter)
for name in ordered(saved):
for r in saved[name]["rows"]:
if r["verdict"] != "-":
lv[r.get("level", "?")][r["verdict"]] += 1
if r.get("closing"):
cl[r["closing"]][r["verdict"]] += 1
lines = ["", "By speech level (right / cases, motions in brackets; * = guessed from the endings):", "",
"| level | right | wrong | motion | llm? |", "|---|---|---|---|---|"]
lines += [f"| {k} | {cell(lv[k])} | {lv[k]['wrong']} | {lv[k]['motion']} | {lv[k]['llm?']} |" for k in sorted(lv)]
if cl:
lines += ["", "Closing turns: " + ", ".join(f"{k} {cell(cl[k])}" for k in sorted(cl))]
return lines
def cell(k): def cell(k):
n = sum(k.values()) n = sum(k.values())
return f"{k['right']}/{n} ({100 * k['right'] // max(1, n)} %)" + (f" [{k['motion']}]" if k["motion"] else "") if n else "-" return f"{k['right']}/{n} ({100 * k['right'] // max(1, n)} %)" + (f" [{k['motion']}]" if k["motion"] else "") if n else "-"
@@ -801,7 +863,7 @@ def report(split, saved, secs):
n = sum(tot.values()) n = sum(tot.values())
lines.append(f"| ALL | | {n} | {tot['right']} | {100 * tot['right'] // max(1, n)} | {tot['wrong']} | " lines.append(f"| ALL | | {n} | {tot['right']} | {100 * tot['right'] // max(1, n)} | {tot['wrong']} | "
f"{tot['motion']} | {tot['llm?']} | {tot['error']} | |") f"{tot['motion']} | {tot['llm?']} | {tot['error']} | |")
lines += by_lang(saved) lines += by_lang(saved) + by_level(saved)
for name in ordered(saved): for name in ordered(saved):
rows = saved[name]["rows"] rows = saved[name]["rows"]
dl = {} dl = {}
@@ -814,7 +876,7 @@ def report(split, saved, secs):
r["show"].replace("\n", "\n ") for r in bad] or ["- none"] r["show"].replace("\n", "\n ") for r in bad] or ["- none"]
out = ROOT / "logs" / f"blind_{split}.md" out = ROOT / "logs" / f"blind_{split}.md"
out.write_text("\n".join(lines) + "\n") out.write_text("\n".join(lines) + "\n")
print("\n".join(lines[:len(saved) + 7] + by_lang(saved))) print("\n".join(lines[:len(saved) + 7] + by_lang(saved) + by_level(saved)))
def main(args): def main(args):
+3 -2
View File
@@ -87,8 +87,9 @@ def rules(text, state, marks, b):
return "refuse" # Lumi.wave refuses with something held (wave.HOLDING) return "refuse" # Lumi.wave refuses with something held (wave.HOLDING)
if data[0] == "put" and not holding: if data[0] == "put" and not holding:
return "empty_hand" # skills.put_down: nothing picked, nothing moves return "empty_hand" # skills.put_down: nothing picked, nothing moves
if data[0] == "fetch" and not holding and {"object", "place"} & set(brain.parse_fetch(text, marks)[1]): if data[0] == "fetch" and (holding or {"object", "place"} & set(brain.parse_fetch(text, marks)[1])):
return "ask" # fetch_dialog asks what is missing before anything moves return "ask" # fetch_dialog asks what is missing before anything moves;
# holding: lumi.fetch_request asks where to put it first
return data[0] if data[0] in ("weather", "search") else f"action:{data[0]} {data[1]}".strip() return data[0] if data[0] in ("weather", "search") else f"action:{data[0]} {data[1]}".strip()
return None return None
+5 -1
View File
@@ -87,7 +87,11 @@ def run_turn(b, text, lang, marks):
bye = b.farewell(text, lang) bye = b.farewell(text, lang)
b.reset() b.reset()
return r, bye, time.time() - t0, time.time() - t0 return r, bye, time.time() - t0, time.time() - t0
if r.startswith("action:") or r in ("weather", "search"): # quick_command keeps it in the history if r in ("weather", "search"): # lumi.look_up: the question (+ WEATHER_ASKED) is kept
asked = text + brain.WEATHER_ASKED if r == "weather" else text # so "도쿄는?" / "how about Daegu?" follow it
b.history.append((asked, by_rule[1] or ""))
b.last_lookup = asked
elif r.startswith("action:"): # quick_command keeps it in the history
a = r.split(":", 1)[-1].split(" ", 1) a = r.split(":", 1)[-1].split(" ", 1)
b.history.append((text, f"ACTION: {a[0]} {a[1] if len(a) > 1 else '-'}")) b.history.append((text, f"ACTION: {a[0]} {a[1] if len(a) > 1 else '-'}"))
return r, by_rule[1], None, time.time() - t0 return r, by_rule[1], None, time.time() - t0
+68 -3
View File
@@ -5,7 +5,8 @@ part?"), "really?" / "are you sure?" right after a motion (about the talk before
number, settled facts after thanks (answered, not looked up), short follow-ups never answered "say it again". number, settled facts after thanks (answered, not looked up), short follow-ups never answered "say it again".
English, Korean (반말 / 해요체 / 하십시오체 / friendly / honorific / dialect) and mixed; Korean replies polite. English, Korean (반말 / 해요체 / 하십시오체 / friendly / honorific / dialect) and mixed; Korean replies polite.
.venv/bin/python tests/dialogues_night4.py [only] # through tests/followup_check.main -> logs/a4n4/night4_check.* .venv/bin/python tests/dialogues_night4.py [only] [--b] # through tests/followup_check.main -> logs/a4n4/night4_check.*
# (--b: round 2 -> night4b_check.*)
""" """
import sys import sys
@@ -81,14 +82,78 @@ DIALOGUES_NIGHT4 = [
T("말씀하신 거 아까랑 좀 다른 것 같은데요?", must=[r"유칼립투스|잎|에너지|6|여섯|개월|18|20"], no=NK + [WHICH], T("말씀하신 거 아까랑 좀 다른 것 같은데요?", must=[r"유칼립투스|잎|에너지|6|여섯|개월|18|20"], no=NK + [WHICH],
check="같은 사실을 다시"), check="같은 사실을 다시"),
T("감사합니다, 많이 배웠어요. 안녕히 계세요.", "end")), T("감사합니다, 많이 배웠어요. 안녕히 계세요.", "end")),
D("grandfather", "owl_ko_dialect", "ko",
T("부엉이 목 그거 을매나 돌아가노?", must=[r"270|이백칠십"], no=NK + [ME], check="270도; Lumi의 고개가 아님"),
T("그래 돌리믄 피는 우째 되노?", must=[r"피|혈관|혈액|핏줄|흐르|막히"], no=NK + [ME], check="혈관이 특별해서 피가 계속 흐름; " + FU),
T("눈은 와 안 움직이노?", must=[r"크|커|뼈|고정|관|원통"], no=NK + [ME], check="눈이 커서 고정; " + FU),
T("어... 그... 뭐였더라...", "-"),
T("참말이가?", must=[r"네|정말|맞|크|고정|270|피"], no=NK + [ME], check="부엉이 얘기를 다시 (못 알아들은 턴 전의 얘기)"),
T("욕봤다, 간데이.", "end")),
D("engineer", "lotte_mixed_konglish", "ko",
T("롯데월드타워 height 몇 m예요?", must=[r"555|오백오십오"], no=NK, check="555m"),
T("floor는 몇 개?", must=[r"123|백이십삼"], no=NK, check="123층; " + FU),
T("uh... what was it... 그...", "-"),
T("are you sure?", must=[r"555|123|yes|네|맞"], no=NK, rl="en", check="롯데월드타워 숫자를 다시 (못 알아들은 턴 전)"),
T("Okay, thanks. Bye!", "end")),
]
# round 2 (10:50): parts named after a world subject ("심장은 몇 개고?", "Why the name?"), lower-case English subjects,
# Lumi's own numbers asked casually and very politely, "really?" after an uncaught turn, a topic taken up again
DIALOGUES_NIGHT4B = [
D("student", "giraffe_en_native", "en",
T("Why do giraffes have such long necks?", must=[r"leaves|tree|reach|food|fight|eat"], no=N + [ME], check="to reach high leaves"),
T("How many bones are in it?", must=[r"seven|7"], no=N + [ME], check="seven, like ours; " + FU),
T("And the heart, is it big?", must=[r"kilo|kg|big|large|pump|blood|11|60 ?cm"], no=N + [ME], check="about 11 kg; " + FU),
T("hmm... the... uh...", "-"),
T("Really?", must=[r"yes|seven|7|kilo|kg|big"], no=N, check="yes, the giraffe facts again (before the uncaught turn)"),
T("Cool, thanks. Bye!", "end")),
D("grandmother", "lumi_specs_ko_honorific", "ko",
T("루미 님 머리에 든 컴퓨터는 메모리가 얼마나 되시는지요?", must=[r"122|백이십이"], no=NK, check="122GB"),
T("팔로는 얼마나 무거운 걸 드실 수 있으세요?", must=[r"2 ?(?:kg|킬로)|1 ?(?:kg|킬로)|이 ?킬로|일 ?킬로"], no=NK,
check="팔 2kg, 손에는 약 1kg"),
T("아이고 그래요? 정말이세요?", must=[r"네|2|1|킬로|맞"], no=NK, check="네, 같은 숫자를 다시"),
T("고마워요. 그럼 키는 어떻게 되세요?", must=[r"146|186|백사십"], no=NK, check="146cm, 올리면 186cm"),
T("잘 들었어요, 수고하세요.", "end")),
D("friend", "octopus_ko_banmal", "ko",
T("문어 피는 무슨 색이야?", must=[r"파란|푸른|청색"], no=NK + [ME], check="파란색"),
T("왜?", must=[r"구리|헤모시아닌|산소"], no=NK + [ME], check="구리가 든 헤모시아닌; " + FU),
T("심장은 몇 개야?", must=[r"3|세 ?개|셋"], no=NK + [ME], check="3개 (문어의 심장)"),
T("아까 피 색깔 뭐라 했지?", must=[r"파란|푸른|청색"], no=NK, check="파란색 (앞의 얘기로 돌아감)"),
T("ㅇㅋ 고마워, 간다~", "end")),
D("tourist", "namsan_mixed_konglish", "ko",
T("남산타워 언제 오픈했어요?", must=[r"1975|1980|칠십|팔십"], no=NK, check="1975년 완공, 1980년 개방"),
T("height는요?", must=[r"236|480|미터"], no=NK, check="약 236m; " + FU),
T("why 이름이 N이에요?", must=[r"남산|new|새|N"], no=NK + [r"제 이름|루미"], check="Namsan / new; 루미의 이름이 아님"),
T("Okay 땡큐!", "end")),
D("engineer", "sound_ko_hasipsio", "ko",
T("빛의 속도는 초속 몇 킬로미터입니까?", must=[r"30만|300,?000|삼십만|299"], no=NK, check="약 30만 km/s"),
T("소리는 어떻습니까?", must=[r"340|343|삼백사십"], no=NK + [ME], check="공기 중 약 340m/s; " + FU),
T("물속에서는 얼마나 빠릅니까?", must=[r"1,?500|1,?480|천오백|4|네 ?배"], no=NK, check="약 1,500m/s"),
T("확실하십니까?", must=[r"네|1,?500|천오백|맞|확실"], no=NK, check="네, 물속 숫자를 다시"),
T("수고하십시오.", "end")),
D("parent", "lumi_battery_en_nonnative", "en",
T("your battery, how many hour it go?", must=[r"10|ten"], no=N, check="about 10 hours"),
T("and when it is empty, you go charging alone?", must=[r"yes|myself|by myself|on my own|dock|charg"], no=N,
check="yes, goes to the charger by itself"),
T("hm ok, and the arm can carry how much?", must=[r"2 ?kg|two|1 ?kg|one|kilo"], no=N, check="2 kg with the gripper, ~1 kg in the hand"),
T("Sure?", must=[r"yes|2|two|1|one|kilo"], no=N, check="yes, the same numbers"),
T("Okay, see you.", "end")),
D("grandfather", "palace_ko_dialect", "ko",
T("경복궁 그거 언제 지었노?", must=[r"1395|조선|태조"], no=NK, check="1395년"),
T("이름은 와 그래 지었노?", must=[r"복|큰|하늘|복을|경사|시경|백성|태평"], no=NK + [r"제 이름|루미"],
check="큰 복을 누리라는 뜻; 루미의 이름이 아님"),
T("불은 몇 번 났노?", must=[r"임진왜란|1592|불|탔|화재|여러"], no=NK, check="임진왜란 때 탔고 1867년 다시 지음; " + FU),
T("고맙데이, 수고하그래이.", "end")),
] ]
if __name__ == "__main__": if __name__ == "__main__":
from tests import followup_check as fc from tests import followup_check as fc
from tests import dialogue_check as dc from tests import dialogue_check as dc
fc.DIALOGUES = DIALOGUES_NIGHT4 b = "--b" in sys.argv # round 2: its own report
fc.DIALOGUES = DIALOGUES_NIGHT4B if b else DIALOGUES_NIGHT4
(dc.ROOT / "logs" / "a4n4").mkdir(exist_ok=True) (dc.ROOT / "logs" / "a4n4").mkdir(exist_ok=True)
dc.OUT_JSON, dc.OUT_MD = dc.ROOT / "logs" / "a4n4" / "night4_check.json", dc.ROOT / "logs" / "a4n4" / "night4_check.md" name = "night4b_check" if b else "night4_check"
dc.OUT_JSON, dc.OUT_MD = dc.ROOT / "logs" / "a4n4" / f"{name}.json", dc.ROOT / "logs" / "a4n4" / f"{name}.md"
args = [a for a in sys.argv[1:] if not a.startswith("--")] args = [a for a in sys.argv[1:] if not a.startswith("--")]
fc.main(args[0] if args else None, failed="--failed" in sys.argv) fc.main(args[0] if args else None, failed="--failed" in sys.argv)
+12 -1
View File
@@ -44,6 +44,16 @@ CAPS = {
"sing": ("sing a song", "노래", "부르", "불러", ["노래 싱 해 줘"]), "sing": ("sing a song", "노래", "부르", "불러", ["노래 싱 해 줘"]),
"louder": ("speak louder", "더 크게", "말하", "말해", []), "louder": ("speak louder", "더 크게", "말하", "말해", []),
"slower": ("speak slower", "좀 천천히", "말하", "말해", []), "slower": ("speak slower", "좀 천천히", "말하", "말해", []),
"quieter": ("speak more quietly", "좀 작게", "말하", "말해", []),
"look_dn": ("look down", "아래를", "보", "봐", ["다운 봐 줘", "look down 해 주세요"]),
"look_me": ("look at me", "저를", "보", "봐", ["룩 앳 미 해 줘"]),
"around": ("turn around", "뒤로", "돌", "돌아", ["유턴 해 줘", "turn around 해 주세요"]),
"come_back": ("come back", "", "돌아오", "돌아와", ["컴백 해 줘"]),
"waist": ("turn your waist left", "허리를 왼쪽으로", "돌리", "돌려", ["웨이스트 레프트로 돌려 줘"]),
"body_up": ("raise your body", "몸을", "올리", "올려", ["리프트 업 해 줘", "바디 업 해 줘"]),
"open": ("open your hand", "손", "펴", "펴", ["핸드 오픈 해 줘"]),
"put": ("put the cup down", "컵 내려", "놓", "놔", []),
"charge": ("go charge", "충전하러", "가", "가", ["차지하러 가 줘"]),
} }
EN_FORMS = ["{}", "please {}", "{}, please", "could you {}?", "can you {} for me?", "would you {}, please?", EN_FORMS = ["{}", "please {}", "{}, please", "could you {}?", "can you {} for me?", "would you {}, please?",
"I'd like you to {}", "I'd love it if you could {}", "{}, if you don't mind", "lumi, {}", "I'd like you to {}", "I'd love it if you could {}", "{}, if you don't mind", "lumi, {}",
@@ -138,7 +148,8 @@ def check(names=None):
"missed" if got is None or got.split()[0] in command_check.NO_MOTION else "wrong")) "missed" if got is None or got.split()[0] in command_check.NO_MOTION else "wrong"))
for t in not_now(pre, stem, a): for t in not_now(pre, stem, a):
got = read(t) got = read(t)
moves = got is not None and got.split()[0] not in command_check.NO_MOTION moves = got is not None and got.split()[0] not in command_check.NO_MOTION and \
not (got == "action:look away" and "지 마" in t) # "저를 보지 마세요": looking away is asked
rows.append((name, "not_now", t, got, "no motion", "right" if not moves else rows.append((name, "not_now", t, got, "no motion", "right" if not moves else
"wrong" if got in ("stop", "sing") else "motion")) # a stop or a song moves nothing "wrong" if got in ("stop", "sing") else "motion")) # a stop or a song moves nothing
return rows return rows
+151
View File
@@ -0,0 +1,151 @@
"""Self-check of cup-task wordings (night 4, F1), no robot, no LLM: python tests/test_fetch_words.py
1. brain.parse_fetch: where the thing is (source), where it goes (dest), which one (prefer), at every speech level.
2. steps.rules: cup tasks of several parts (fetch then more, deliver and come back, put it at a place, wait until
someone takes it, Korean calls / endings of every level, Korean written without spaces).
Notation of tests/test_steps.py."""
from assistant import brain, steps
def short(s):
"""The notation of tests/test_steps.py, the kinds used here."""
w = s.split()
if w[0] == "go":
return {"do": "go", "to": w[1]}
if w[0] == "pick":
return {"do": "pick", "object": w[-1], "colour": w[1] if len(w) == 3 else None}
if w[0] == "receive":
return {"do": "receive", "object": w[1], **({"wait_s": steps.WAIT_GIVE_S} if w[-1] == "wait" else {})}
if w[0] == "wait":
if w[1:2] == ["order"]:
return {"do": "wait", "s": steps.WAIT_ORDER_S, "until": "instruction"}
return {"do": "wait", "s": float(w[1]) if len(w) > 1 else None}
if w[0] == "turn":
return {"do": "turn", "deg": float(w[1])}
if w[0] == "place":
return {"do": "place", "on": {"name": "dining table", "colour": None, "side": None} if len(w) > 1 else None}
if w[0] == "give" and len(w) > 1:
return {"do": "give", "person": s[5:]}
return {"do": w[0]}
M = ["home", "p1", "p2", "p3", "p4", "p5", "Registration", "Main_Stage", "Coffee_Bar"]
P = lambda n: {"marker": n}
# ---- 1. one fetch: (object, colour, source, dest, finish[, prefer]); None = asked ----
FETCH = {
"bring me the red cup from p3": ("cup", "red", P("p3"), "here", "hold"),
"could you grab me the cup that's on p2?": ("cup", None, P("p2"), "here", "hold"),
"get me the cup on the left from p1": ("cup", None, P("p1"), "here", "hold", "left"),
"fetch the white cup from the coffee bar": ("cup", "white", P("Coffee_Bar"), "here", "hold"),
"would you mind bringing the cup over from p5": ("cup", None, P("p5"), "here", "hold"),
"p1 red cup bring me please": ("cup", "red", P("p1"), "here", "hold"),
"bring the cup on p1 to p4": ("cup", None, P("p1"), P("p4"), "hold"),
"take the cup from p1 to p4": ("cup", None, P("p1"), P("p4"), "hold"),
"bring the cup to p1": ("cup", None, "here", P("p1"), "hold"),
"p3에서 빨간 컵 가져와": ("cup", "red", P("p3"), "here", "hold"),
"피삼에 있는 컵 좀 가져다줄래?": ("cup", None, P("p3"), "here", "hold"),
"피투에 있는 왼쪽 컵 가져와 줘": ("cup", None, P("p2"), "here", "hold", "left"),
"피원 컵 가져와": ("cup", None, P("p1"), "here", "hold"),
"p1의 컵 가져와": ("cup", None, P("p1"), "here", "hold"),
"커피 바에서 하얀 컵 갖다 주시겠어요?": ("cup", "white", P("Coffee_Bar"), "here", "hold"),
"피오에서 작은 컵 좀 가져다 주십시오": ("cup", None, P("p5"), "here", "hold", "small"),
"일 번 포인트에 있는 컵 좀 갖다 줘": ("cup", None, P("p1"), "here", "hold"),
"피원에서 컵 가져다가 피사에 있는 테이블에 놔": ("cup", None, P("p1"), P("p4"), "place"),
"컵을 p1에 갖다 놔": ("cup", None, "here", P("p1"), "place"),
# a person, not a place: asked
"bring the cup from p2 to Minsu": ("cup", None, P("p2"), None, "hold"),
"p2에서 컵 가져다가 민수한테 줘": ("cup", None, P("p2"), None, "hold"),
"빨간 옷 입은 여자분께 컵 갖다 드려": ("cup", None, "here", None, "hold"),
}
bad = []
for text, want in FETCH.items():
task, _ = brain.parse_fetch(text, M)
got = (task["object"], task["colour"], task["source"], task["dest"], task["finish"]) + \
((task["prefer"],) if task.get("prefer") else ())
if got != want:
bad.append(f"FAIL fetch {text!r}\n want {want}\n got {got}")
# ---- 2. several parts ----
STEPS = {
"deliver the cup to p5 and come back": "pick cup | go p5 | give | go here",
"take the cup to p5, leave it there and come back": "pick cup | go p5 | place | go here",
"컵을 p5에 갖다 주고 돌아와": "pick cup | go p5 | give | go here",
"컵 피오에 갖다 놓고 돌아와 주세요": "pick cup | go p5 | place | go here",
"컵을 피오에 갖다 드리고 돌아오십시오": "pick cup | go p5 | give | go here",
"bring me the cup from p2 and then go back home": "go p2 | pick cup | go here | give | go home",
"p2에서 컵 가져다 주고 충전기로 가": "go p2 | pick cup | go here | give | go home",
"p1에서 병 가져다 p2에 놔 주고 여기로 돌아와": "go p1 | pick bottle | go p2 | place | go here",
"p1에 있는 컵을 p4로 가져다 놔": "go p1 | pick cup | go p4 | place",
"go to p3 and wait until someone takes the cup": "go p3 | give",
"피삼에 가서 누가 가져갈 때까지 기다려": "go p3 | give",
"피삼에 가서 누가 받을 때까지 기다려 주세요": "go p3 | give",
"p3에 가서 민수한테 컵 받아서 가져와": "go p3 | receive cup | go here",
"go to p3, take the cup from Minsu and bring it to me": "go p3 | receive cup | go here | give",
"컵 들고 p2로 가서 거기 있는 사람한테 줘": "pick cup | go p2 | give",
"빨간 컵을 p4에 있는 민수한테 갖다 줘": "pick red cup | go p4 | give 민수",
"fetch the cup from p1, then wait here": "go p1 | pick cup | go here | wait",
"피원에서 빨간 컵 가져다가 피삼에 놔 줘": "go p1 | pick red cup | go p3 | place",
"피일에서 컵 가져다 주시고 홈으로 가십시오": "go p1 | pick cup | go here | give | go home",
"take the bottle to p2 and wait there until someone takes it, then come back": "pick bottle | go p2 | give | go here",
"병 들고 피투로 가서 누가 가져갈 때까지 기다렸다가 돌아와": "pick bottle | go p2 | give | go here",
"컵 피삼에 갖다 주고 10초 기다렸다가 홈으로 가": "pick cup | go p3 | give | wait 10 | go home",
"빨간 컵을 피사에 갖다 놓으시고 돌아오세요": "pick red cup | go p4 | place | go here",
"take the cup to the main stage and hand it to whoever is there": "pick cup | go Main_Stage | give",
"find the red cup and bring it to me": "pick red cup | go here | give",
"빨간 컵 찾아서 나한테 가져다 줘": "pick red cup | go here | give",
"point one에서 빨간 컵 가져와서 P5에 있는 사람한테 줘": "go p1 | pick red cup | go p5 | give",
"take the banana to the main stage and give it too Mr. Kim": "pick banana | go Main_Stage | give Mr. Kim",
"에구 하얀 컵 집어서 p4로 가져가서 테이블에 놔, 응": "pick white cup | go p4 | place dining table",
"p4에 가서 누가 빨간 컵 주면 받아 가지고 와": "go p4 | receive cup wait | go here",
"p4 가서 십 초 wait 하고 와": "go p4 | wait 10 | go here",
# a new order on the way (lumi.mission_talk reads it with steps.read)
"no, bring it to p4 instead": "go p4",
"아니야 피사로 가져가 줘": "go p4",
"change of plan, go to p4 and put it down": "go p4 | place",
"그거 저 사람한테 줘": "give",
# calls and endings of every level, Konglish, no spaces
"이보게 루미, 피삼에 가서 30초 기다렸다가 돌아오게나": "go p3 | wait 30 | go here",
"루미 님께서 피삼으로 가서 30초 기다렸다가 돌아와 주시길 부탁드립니다": "go p3 | wait 30 | go here",
"아야 루미, 피투로 가서 1분 기다렸다가 돌아와 주시겄슈": "go p2 | wait 60 | go here",
"우리 루미, 피투로 가서 한 바퀴 돌고 돌아와 주라~": "go p2 | turn 360 | go here",
"자네, 피투로 가서 오더 받고 컴백해 주게나": "go p2 | wait order | go here",
"피사에가서5분있다가다시오세요": "go p4 | wait 300 | go here",
"홈 포지션에 들렀다가 피투로 가게나": "go home | go p2",
}
for text, want in STEPS.items():
got, unread = steps.rules(text, M)
if unread or got != [short(s.strip()) for s in want.split(" | ")]:
bad.append(f"FAIL steps {text!r}\n want {want}\n got {got}\n unread {unread}")
# ---- 3. holding: put it at a place = a drive there and a put-down ----
for text in ("put it on p3", "p3에 갖다 놔", "피삼에 놔 줘", "leave it at the registration"):
got, unread = steps.rules(text, M)
if unread or [s["do"] for s in got] != ["go", "place"]:
bad.append(f"FAIL put at {text!r}: {got} {unread}")
# ---- near misses: nothing is read as a task part ----
NEAR = ["did you bring the cup from p1 and go home?", "don't bring the cup from p1, go home", "I'll bring the cup from p1 myself",
"tomorrow bring me the cup from p1 and go to p2", "my friend brought the cup from p1 and went home",
"p1에서 컵 가져오지 마", "내가 p1에서 컵 가져올게", "어제 p1에서 컵 가져왔지?", "컵을 p5에 갖다 줬어?",
"p3에 갖다 놓지 마", "did you deliver the cup to p5?"]
for text in NEAR:
got, unread = steps.rules(text, M)
if not unread and got:
bad.append(f"FAIL near miss {text!r}: {got}")
# ---- 4. a correction after the read-back (fetch_dialog): what changes ----
T = {"object": "cup", "colour": "red", "source": P("p1"), "dest": "here", "finish": "hold"}
FIX = {"no, the blue one": {"colour": "blue"}, "아니 파란 거": {"colour": "blue"}, "not p1, p2": {"source": P("p2")},
"피원 말고 피투": {"source": P("p2")}, "the one on the left": {"prefer": "left"}, "왼쪽 거": {"prefer": "left"},
"the smaller one": {"prefer": "small"}, "아니 작은 거": {"prefer": "small"}, "no, from p2": {"source": P("p2")},
"아니 피사로": {"dest": P("p4")}, "no, the bottle": {"object": "bottle", "colour": None},
"the other one": {}, "아니 다른 거": {}} # not said which: nothing changes, Lumi asks what to change
for text, want in FIX.items():
task, changed = brain.parse_correction(text, T, M)
if {k: task.get(k) for k in changed} != want:
bad.append(f"FAIL correction {text!r}: want {want}, got {({k: task.get(k) for k in changed})}")
print("\n".join(bad))
print(f"{len(FETCH) + len(STEPS) + len(FIX) + len(NEAR) + 4 - len(bad)}/{len(FETCH) + len(STEPS) + len(FIX) + len(NEAR) + 4} right")
assert not bad
print("fetch words ok")
+23
View File
@@ -203,4 +203,27 @@ if __name__ == "__main__":
assert brain._follow_examples(t, h), t assert brain._follow_examples(t, h), t
for t in ("Where is p3?", "세종대왕이 누구예요?", "oh cool", "What's your name?", "Tell me about the Korean War."): for t in ("Where is p3?", "세종대왕이 누구예요?", "oh cool", "What's your name?", "Tell me about the Korean War."):
assert not brain._follow_examples(t, h), t assert not brain._follow_examples(t, h), t
# a world subject keeps Lumi's notes out (also lower-case English and a part named after it); Lumi's own things keep them
b = brain.Brain()
for h, t, want in (([], "Why do whales sing?", ["whales"]), ([], "부엉이는 고개를 몇 도까지 돌려요?", ["부엉이"]),
([("Why do whales sing?", "ACTION: none -\nTo find mates.")], "How far can the song go?", ["whales"]),
([("문어는 다리가 몇 개고?", "ACTION: none -\n여덟 개예요.")], "심장은 몇 개고?", ["문어", "다리", "심장"]),
([], "속도는 얼마예요?", []), ([], "How fast can you go?", []), ([], "Is the song yours?", []),
([], "Can the arm lift 2 kg?", [])):
b.history = list(h)
assert b.world_talk(t) == want, (t, b.world_talk(t))
# "really?" after a turn Lumi did not catch asks about the answer before it
h = [("롯데월드타워 높이 몇 m예요?", "ACTION: none -\n555미터예요."),
("uh... what was it... 그...", "ACTION: unclear -\n죄송해요, 다시 말씀해 주시겠어요?")]
assert brain.topic_turn(h)[0].startswith("롯데월드타워"), brain.topic_turn(h)
# the model's "search" with its answer after it: said (none); a lookup promise or "don't know" keeps the search
s = {"action": "search", "target": "x"}
q = "윤초는 뭐예요?"
for w in ("윤초는 지구 자전과 시계를 맞추는 1초예요.", "Mount Fuji is 3,776 metres high."):
assert brain.Brain._settled(s, w, q)["action"] == "none", w
for w in ("확인해 볼게요.", "Let me check.", "search whale song distance", "잘 모르겠어요.", "", "윤초는 뭐예요?",
"윤초가 궁금하시군요. 잠시만요.", "What exactly do you mean?"):
assert brain.Brain._settled(s, w, q) is s, w
assert brain.CHANGES.search("지금 비트코인 얼마야?") and brain.CHANGES.search("Who won the game yesterday?")
assert not brain.CHANGES.search("윤초는 뭐예요?") and not brain.CHANGES.search("How do bees dance?")
print("followup ok") print("followup ok")
+17
View File
@@ -0,0 +1,17 @@
"""Korean speech levels read as the English request (a fixed part of tests/ko_levels_check.py): every level of a few
capabilities gives the same action, and the same phrase said as a past, a negation, a later time or a condition
gives no motion. No robot; the embedding server answers the bank.
.venv/bin/python tests/test_ko_levels.py
"""
from tests import ko_levels_check
CAPS = {"wave", "turn45", "head_up", "follow", "fetch", "go_to"}
rows = ko_levels_check.check(CAPS)
bad = [r for r in rows if r[-1] != "right"]
for name, level, text, got, want, v in bad:
print(f"FAIL {name} [{level}] {text!r} -> {got} (want {want}, {v})")
assert not bad, f"{len(bad)} of {len(rows)} not right"
assert len(rows) > 400, len(rows)
print(f"ok: {len(rows)} forms")
+142
View File
@@ -0,0 +1,142 @@
"""Commands, questions and asides through the voice / Command box route (command_check.rules = lumi.route without the
LLM), night 4: tag questions, take-backs at every Korean level, other people addressed, polite stops, chains that are
one order, amounts not read. A wrong motion is the worst error: None (the LLM reads it) is right for the no-motion
cases. No robot.
.venv/bin/python tests/test_route_words.py
"""
from assistant import brain, detour
from tests import command_check
M = ["p1", "p2", "p3", "p5", "p6", "home", "dock2"]
CASES = [ # (text, state, route)
# a statement with a tag, an ability said back: asked
("you went to P5 earlier, right?", "idle", None), ("you can lift your arm, right?", "idle", None),
("너 팔 접을 수 있지, 그치?", "idle", None), ("너 팔 접을 수 있지?", "idle", None), ("wave, right?", "idle", "action:wave"),
("손 흔들고 나 봐, 알았지?", "idle", "chain:wave+look_me"), ("팔 접어, 알겠죠?", "idle", "action:arm fold"),
("팔 뻗을 줄 아세요?", "idle", None), ("팔을 뻗을 줄 압니까?", "idle", None), ("robot, you know how reach out to me?", "idle", None),
("robot can say hi with your hand or not? I just ask", "idle", None), ("멸 센티까지 잡아?", "idle", None),
("Back to your arm, what did you say?", "idle", None),
# one order, not a chain
("손 흔들어서 작별 인사 해 주시겠어요?", "idle", "action:wave"), ("손 흔들어서 인사해", "idle", "action:wave"),
("컵 들고 몇으로 가?", "idle", None), ("잔 들고 천천히 가는 속도가 얼마야?", "idle", None),
("하객분들 앞에서 손 거둬!, 아 거두시겠어요?", "idle", "action:arm fold"),
("로봇아, 좌측으로 10 센티미터 움직여라, 아 움직여 주실래요?", "idle", "action:move left 0.1"),
("이장이 말하는디, 팔 제자리로 해", "idle", "action:arm fold"), ("take your hand back, da?", "idle", "action:arm fold"),
("so, robot, head to p6, da?", "idle", "action:go_to p6"), ("could you possibly hand it over?, eh?", "holding", "give"),
("exactly please I'll hold it, give it here", "holding", "give"),
("pick up the cup, how fast do you go?", "idle", "chain:steps+talk"), ("고개 들고 몇 시야?", "idle", "chain:look_up+talk"),
("치수 불러 줄게, 내 머리 무슨 색이야?", "idle", "seeing"),
# handed over or not
("이거 줄게", "idle", "receive"), ("컵 줄게요", "idle", "receive cup"), ("사진 찍어 줄게", "idle", None),
("자 그럼 Lumi, wave your hand 해 봐요", "holding", "refuse"), ("give 해 줘", "holding", "give"),
("it'd be cool if you could give me the cup someday", "holding", None),
# polite stops, calls, Konglish
("멈춰 주시겠어요?", "idle", "stop"), ("멈춰 주실래요?", "idle", "stop"), ("정지해 주시겠습니까?", "idle", "stop"),
("can you stop for me?", "idle", "stop"), ("루미 씨, 잠깐 멈춰 주실 수 있나요?", "idle", "stop"),
("can you stop for coffee?", "idle", None), ("루미 씨, 팔 접어 주세요", "idle", "action:arm fold"),
("컴 히어 해 줘", "idle", "action:come"), ("이리 컴", "idle", "action:come"), ("컴퓨터 꺼 줘", "idle", None),
# other people addressed
("쉿 아기 자니까 엄마 그거 나 줘", "holding", None), ("질문을 바꿔서, 엄마 그거 나 줘", "holding", None),
("이륙 전 점검, 할머니 이제 팔 접어 좀", "idle", None), ("어머님, 컵을 들어 보세요, 저기 로봇 있어요", "idle", None),
("김 군, 자네도 팔 뻗어 보게", "idle", None), ("우리 아들, 빠빠이 해 봐 봐~", "idle", None),
("shh, Sarah, make your way to p2", "idle", None), ("우리 p3 갈까 여보", "idle", None),
("루미야 할머니한테 손 흔들어 줘", "idle", "action:wave"), ("okay, Lumi, go to p5", "idle", "action:go_to p5"),
# taken back, later, negated: every level
("로봇 씨, 손 흔들어 주시길 바랍니다, 아, 하지 않으셔도 됩니다", "idle", "talk"), ("저기유, 손 흔들어 줘유, 아녀, 됐슈", "idle", None),
("악수해 주십시오, 아닙니다, 취소하겠습니다", "idle", "talk"), ("루미야~ 나랑 악수해~, 장난이야~", "idle", "talk"),
("wave 해 줄 수 있지?, 아냐 아냐 됐어 ㅋㅋ", "idle", "talk"), ("음악 나오믄 악수해 보이소", "idle", None),
("나중에~ 손 wave 해~", "idle", None), ("행사가 끝난 후에 나한테 손 흔드십시오", "idle", None),
("robot, if I say go, then reach out to me", "idle", None), ("you not give me the cup", "holding", None),
("no hold out your hand, please", "idle", None),
("no need to return it to where it was", "holding", None), ("put down 하지 않으셔도 됩니다", "holding", None),
("파란 컵 좀 들지 마이소", "idle", None), ("자네 컵 잡는 거 제법이더군", "idle", None),
# 하게체 / dialect requests to Lumi, floor, status
("자네, 손을 흔들어 주게나", "idle", "action:wave"), ("이보게 루미, 악수하게", "idle", "action:wave"),
("나한테 손 흔들어 줄 수 있지?", "idle", "action:wave"), ("어이 로봇아, 손 흔들어 주드라고", "idle", "action:wave"),
("바닥에 내려놔 주이소", "holding", "refuse"), ("의자 밑에 놔", "holding", "refuse"), ("의자 위에 놔", "holding", "place chair"),
("그리퍼 오픈 상태야?", "idle", "status"), ("is it possible for you to open your fingers, in general?", "idle", None),
("can you look up for me?", "idle", "action:look up"), ("would you stop, please?", "idle", "stop"),
("흰색 머그컵 잡아!, 아 잡아 줄 수 있어요?", "idle", "action:pick white cup"),
("제자리에, 루미, 손 앞으로 내밀어 봐", "idle", "action:arm reach"), ("Lumi, I heard you can put that back", "holding", None),
# gives at every level, self-corrections said again, head / body / base words
("로봇아, 선생님께 드려라", "holding", "give"), ("자네, 할머니께 드리시게", "holding", "give"),
("grandma한테주십시오", "holding", "give"), ("루미, 이리 좀 조", "holding", "give"), ("루미야, 기브 미 해 주세여", "holding", "give"),
("로봇아, 그거 주세요", "idle", "empty_hand"), ("좌측으로 20센티 움직여 줘, 아니 움직이실래요?", "idle", "action:move left 0.2"),
("루미야 우측으로 15도 돌아 봐, 아니 돌아 봐요 허허", "idle", "action:turn right 15"), ("p6로 가, 아니지 p2로 가", "idle", "action:go_to p2"),
("이제 팔 접어 좀. 아니야 그냥 있어", "idle", "talk"), ("두 걸음 뒤로 물러서 줘, 부탁해", "idle", "action:move back 1"),
("어이로봇아,상체오른쪽으로십오도쫌돌려줘유", "idle", None), ("저기 루미야, 웨이스트 레프트로 좀 돌리세요", "idle", "action:waist left"),
("몸통째 왼쪽으로 돌려", "idle", "action:turn left 90"), ("실례합니다. 왼쪽을 돌아봐 주시겠습니까?", "idle", "action:look left"),
("look right at me 해 하하", "idle", "action:look me"), ("Lumi go ahead and look down at the ground", "idle", "action:look down"),
("루미 씨, 발 밑 바라보지 마세요", "idle", None), ("쳐다보지 마", "idle", "action:look away"),
("prove you're smart: come on back", "idle", "action:come_back"), ("루미 360 돌아 봐", "idle", "action:turn right 360"),
("dude, stick your hand out", "idle", None), ("dude, halt", "idle", "stop"), ("손님상에 여보 후진 2미터 반 움직여 봐", "idle", None),
("이따가 멈춰 주세요", "idle", None),
# amounts
("루미,앞으로삼십센티미터가", "idle", "ask"), ("뒤로1미터50이동해부러", "idle", "action:move back 1.5"),
("앞으로 30센티 가", "idle", "action:move forward 0.3"),
# a stop for later or reported (night 4, round 3)
("행사가 끝난 후에 멈춰 주시길 바랍니다", "idle", None), ("내일 그만하시게", "idle", None),
("아까 직원분이 그만하라고 지시했습니다", "idle", None), ("루미 군, 그만하시게", "idle", "stop"),
("저기요, 당장 멈춰 주시길 바랍니다", "idle", "stop"),
# turn (try turning) or look round; a correction said as a new order in full
("왼쪽으로 돌아 봐", "idle", "action:turn left 90"), ("오른쪽으로 돌아봐 줄래요?", "idle", "action:look right"),
("왼쪽으로 돌아보시게", "idle", "action:look left"), ("레프트 턴 해 봐", "idle", "action:turn left 90"),
("루미 오른편으로 135도 돌아— 아니 왼편으로 백이십 도 돌아 주세요~", "idle", "action:turn left 120"),
("우리 루미, 오른쪽으로 백삼십오 도 돌아... 아 잘못 말했다, 몸통째 왼쪽으로 돌려 주세요", "idle", "action:turn left 90"),
("go forward half a metre, no wait, back up 10 cm", "idle", "action:move back 0.1"),
("turn left 45 degrees, no, right", "idle", "action:turn right 45"),
("좌측으로 20센티 움직여 줘, 아니 움직이실래요?", "idle", "action:move left 0.2"),
("부스 B로 가서 왼쪽으로 돌아요", "idle", "talk"), ("hello robot, please come back for me, thank you", "idle", "action:come_back"),
("애플 그랩 해", "idle", "action:pick apple"), ("실례합니다. 제자리에 지금 갖다 놓으십시오", "holding", "action:put back"),
# round 4: new wordings
("back to your arm. what was it again?", "idle", None), ("now face the other way", "idle", "action:turn around 180"),
("do a 180, please", "idle", "action:turn around 180"), ("룩 다운 해 주세요", "idle", "action:look down"),
("룩 앳 미 해 줘", "idle", "action:look me"), ("룩 업 할 수 있어?", "idle", None),
("바이바이 좀 하세요", "idle", "action:wave"), ("어이 로봇, 빠빠이 하시게", "idle", "action:wave"),
("멈추시게", "idle", "stop"), ("hold it right there", "idle", "stop"), ("내일 멈추시게", "idle", None),
("you put down arm please", "idle", "action:arm fold"), ("어이 로봇아, 손 쪼까 내려 줘", "idle", "action:arm fold"),
("Lumi, may I ask you to stretch your arm out?", "idle", "action:arm reach"), ("is your arm out?", "idle", "status"),
("Lumi, robot, put it down ok?", "holding", "place"), ("I put it down, now?", "holding", "seeing"),
("할머니 드려라", "holding", "give"), ("우리 할머니 드리십시오", "holding", "give"), ("전화 드려", "holding", None),
("인사 드려", "holding", None), ("연락 줘", "holding", None),
("손 흔들면서 인사하고 고개 숙여", "idle", "chain:wave+look_down"),
("왔던 길로 돌아가", "idle", "action:come_back"), ("원래 있던 자리로 가 주세요", "idle", "action:come_back"),
("go back the way you came", "idle", "action:come_back"), ("원래 있던 자리로 가지 마", "idle", None),
("어제 왔던 길로 가면 돼요", "idle", None), ("knock it off, Lumi", "idle", "stop"), ("whoa there", "idle", "stop"),
("whoa, that's cool", "idle", None), ("lemme have it", "holding", "give"),
# "would you mind …ing", polite conditions and "-주시면 안 될까요" (lead, 11:30)
("would you mind shaking hands", "idle", "action:wave"), ("would you mind coming here?", "idle", "action:come"),
("do you mind waving at the kids?", "idle", "action:wave"), ("would you mind stopping here, please", "idle", "stop"),
("would you mind if I took a photo?", "idle", None), ("would you mind not moving?", "idle", None),
("손 흔들어 주시면 안 될까요?", "idle", "action:wave"), ("괜찮으시면 악수해 주실래요?", "idle", "action:wave"),
("p3로 가 주시면 안 될까요?", "idle", "action:go_to p3"), ("실례가 안 된다면 이리 와 주시겠어요?", "idle", "action:come"),
("혹시 괜찮으시면 컵 좀 집어 주실 수 있을까요?", "idle", "action:pick cup"), ("if you don't mind, wave at me", "idle", "action:wave"),
("괜찮으시면 손 흔들지 마세요", "idle", None), ("괜찮으시면 내일 p3로 가 주세요", "idle", None),
("괜찮으시면 저한테 주시면 안 될까요?", "holding", "give"), ("hello robot", "idle", None),
("hello robot, wave", "idle", "action:wave"),
]
DETOUR = [ # right after a blocked drive to p2: (text, detour.read)
("아까 저 아저씨가 루미한테 다시 가라고 했어", None), ("아까 재시도하는 거 정말 신기했어요", None),
("다른 루트로 가시겠어요?, 아, 아닙니다, 괜찮습니다", None), ("얘 뒤로 조금 갔다가 다시 가는 거 봤냐?", None),
("지가 말하믄 재시도해부러", None), ("다시 시도할 줄은 알아?", None), ("그냥 돌아올 줄 아는가?", None),
("다시 시도해 줘", "retry"), ("다른 길로 가 주세요", "around"), ("루미야 포기하지 마", "retry"),
("never mind that, just try again", "retry"),
("루미야, 다른 길 있나 민수야?", None), ("여러분, 모두 포기하고 돌아와 보시기 바랍니다", None),
]
def main():
detour.recent = lambda: None # no blocked drive just now (whatever the live state says)
bad = [f"detour {t!r} -> {detour.read(t, M, 'p2')!r} (want {w!r})" for t, w in DETOUR if detour.read(t, M, "p2") != w]
for text, state, want in CASES:
got = command_check.rules(text, state, M, brain.Brain())
if got != want:
bad.append(f"{text!r} [{state}] -> {got!r} (want {want!r})")
print("\n".join(bad) or f"route words ok ({len(CASES)} cases)")
assert not bad
if __name__ == "__main__":
main()
+3 -1
View File
@@ -118,7 +118,8 @@ said = lambda: [d[1] for d in done if isinstance(d, tuple) and d[0] == "say"]
# ---- the calls that wake Lumi (EN + KO + whisper slips) and what does not ---- # ---- the calls that wake Lumi (EN + KO + whisper slips) and what does not ----
for call in ("Lumi.", "Hi Lumi.", "Hi.", "Hello Lumi!", "Hello.", "Hey Lumi", "How are you?", "Hi, how are you?", for call in ("Lumi.", "Hi Lumi.", "Hi.", "Hello Lumi!", "Hello.", "Hey Lumi", "How are you?", "Hi, how are you?",
"루미야.", "루미.", "안녕.", "안녕하세요.", "하이.", "하이 루미!", "Hi, Loomi.", "Hello, Rumi.", "Hai.", "루미야.", "루미.", "안녕.", "안녕하세요.", "하이.", "하이 루미!", "Hi, Loomi.", "Hello, Rumi.", "Hai.",
"Lummy?", "누미야", "안녕하십니까."): "Lummy?", "누미야", "안녕하십니까.", "Wake up.", "Wake up, Lumi!", "Hey Lumi.", "Lumi, wake up.",
"헤이 루미", "루미야 일어나", "루미 일어나세요.", "일어나세요.", "깨어나 루미야"):
L = fresh() L = fresh()
L.mic = Mic(U(call)) L.mic = Mic(U(call))
assert L.check_wake(), call assert L.check_wake(), call
@@ -128,6 +129,7 @@ for heard in ("Let's make music.", "What is that?", "We make it.", "Let's.", "It
L.mic = Mic(U(heard)) L.mic = Mic(U(heard))
assert not L.check_wake(), heard # 16:57:00, 17:05:03 live: "(no wake word)" assert not L.check_wake(), heard # 16:57:00, 17:05:03 live: "(no wake word)"
assert not lumi.call_only("Lumi, what time is it?") and not lumi.call_only("루미야 노래 불러줘") assert not lumi.call_only("Lumi, what time is it?") and not lumi.call_only("루미야 노래 불러줘")
assert not lumi.WAKE.search("I wake up at 7 every day") and not lumi.WAKE.search("일어나서 밥 먹었어") # no call
L = fresh() # "How are you?" is answered, not "Yes? How can I help?" L = fresh() # "How are you?" is answered, not "Yes? How can I help?"
L.mic = Mic(U("How are you?")) L.mic = Mic(U("How are you?"))
L.check_wake() L.check_wake()