Fix Command box actions while holding, improve side reaches and quick answers

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
2026-10-27 05:03:46 +09:00
co-authored by Claude Opus 5.5
parent ac13ced892
commit 5d1422bb38
21 changed files with 566 additions and 87 deletions
+132
View File
@@ -500,5 +500,137 @@ NO += [
"wave hello to my friend on the phone, no wait, never mind", "pick it up? no, leave it",
]
# ---------- a reason before or after the order ("…, my mom wants a picture", "리허설 중이에요, …"), train-set gaps ----------
EN_CORE = {
"WAVE": ["wave", "say bye with your hand", "shake my hand", "wave at the kids"],
"ARM_REACH": ["hold your hand out to me", "give me your hand", "reach out your arm"],
"ARM_FOLD": ["put your arm down", "rest your arm", "fold your arm"],
"ARM_OPEN": ["open your hand", "hand open"],
"ARM_CLOSE": ["close your hand", "make a fist"],
"PICK": ["pick up the <obj>", "pick the <obj> up"],
}
KO_CORE = {
"WAVE": ["손 흔들어 줘", "악수해요", "손으로 인사해 줘"],
"ARM_REACH": ["손 줘 봐", "팔 뻗어 줘", "손 내밀어 줘"],
"ARM_FOLD": ["팔 접어 줘", "손 내려 줘"],
"ARM_OPEN": ["손 펴 줘", "그리퍼 열어 줘"],
"ARM_CLOSE": ["주먹 꽉 쥐어 줘", "손 쥐어 줘"],
"PICK": ["<obj> 집어 줘", "<obj> 잡아 주세요"],
}
EN_AFTER = ["{}, my mom wants a picture", "{}, we're making a video", "{} for the photo",
"{}, it's for a video", "{}, i'm filming"]
EN_BEFORE = ["we're filming, {}", "for the video, {}", "ok so my friend dared me, {}", "smile for the camera and {}",
"one, two, three, {}", "3, 2, 1, {}", "let's see you {}", "i'd love to see you {}", "i want you {}"]
KO_AFTER = ["{}, 사진 찍게", "{}, 애들이 좋아해", "{}, 영상 찍고 있어", "{} 기념으로", "{}, 할머니가 보고 싶대"]
KO_BEFORE = ["리허설 중이에요, {}", "촬영 중인데 {}", "녹음 중인데, {}", "하나 둘 셋, {}", "자 이제 {}", "기념 사진 찍을게, {}"]
_REASON = {}
for k, cores in EN_CORE.items():
_REASON[k] = [f.format(c) for c in cores for f in EN_AFTER + EN_BEFORE]
for k, cores in KO_CORE.items():
_REASON[k] += [f.format(c) for c in cores for f in KO_AFTER + KO_BEFORE]
WAVE += _REASON["WAVE"]
ARM_REACH += _REASON["ARM_REACH"]
ARM_FOLD += _REASON["ARM_FOLD"]
ARM_OPEN += _REASON["ARM_OPEN"]
ARM_CLOSE += _REASON["ARM_CLOSE"]
PICK += _REASON["PICK"]
ARM_OPEN += ["let go", "let go now", "okay, let go", "let go of it", "release", "release now", "손 놔", "손 놓아",
"그리퍼 놔", "hand open 해 줄래", "손 오픈 해 줄래"]
ARM_CLOSE += ["꽉 쥐어", "꽉 쥐어 줘", "꽉 쥐어 주면 좋겠어", "주먹 꽉 쥐어 주게", "손 꽉 쥐시게"]
ARM_REACH += ["give me 손", "give me 손 해 줘", "손 give me", "your hand to me, robot", "robot, your hand to me",
"손 줘 봐 손", "손 손 줘", "할머니한테 손 줘 봐", "애기한테 손 줘", "손님한테 손 줘 봐요"]
WAVE += ["악수하세", "악수하세나", "에구 악수하세", "악수 한번 하세나", "let's see you wave like a queen", "wave like a king",
"wave like a princess", "wave like a superstar", "wave like a pro", "핸드 웨이브 해", "손 웨이브"]
ARM_FOLD += ["rest your arn", "fold your arn", "put your arn down", "back to look position please",
"look position please", "go back to the look position", "팔 룩 포지션"]
PICK += ["<obj> 좀 들게", "<obj> 잡게나", "<obj> 들어부러", "<obj> 집어부러", "<obj> 좀 쪼까 집어 줘",
"<obj> 집어 주시기 바랍니다", "<obj> 잡아 주시기 바랍니다", "<obj> 들어 주시기 바랍니다", "<obj>좀들어주시기바랍니다",
"you have to take the <obj>", "you must pick up the <obj>", "you are can take the <obj>",
"i am tourist, please lift the <obj>", "<obj> 픽업해", "<obj> 픽업해 줘요"]
FETCH += ["<obj> 브링해 줘", "<obj> 브링해", "<obj> 브링해 주시겠습니까", "<place>에서 <obj> 브링해", "<place>에서 <obj> 브링해 줘",
"<obj> 가져와 주시기 바랍니다", "<obj> 갖다 주시기 바랍니다", "<place>에서 <obj> 가져와 주시기 바랍니다",
"<place>에서 <obj> 가져와 주시기 부탁드립니다", "<place>에 있는 <obj> 갖다 주시겠어요", "<place>에서 <obj>갖다주게나",
"<obj> 갖다 줘 ㅎㅎ", "you bring <obj> please", "you bring <obj> from <place> please"]
# ---------- hard negatives for every capability: negation, past, ability, condition, later, remarks ----------
NEG_EN = {"wave": ("wave", "waved", "waving"), "shake hands": ("shake hands", "shook hands", "shaking hands"),
"hold out your hand": ("hold out your hand", "held out your hand", "holding out your hand"),
"fold your arm": ("fold your arm", "folded your arm", "folding your arm"),
"open your hand": ("open your hand", "opened your hand", "opening your hand"),
"close your hand": ("close your hand", "closed your hand", "closing your hand"),
"pick up the cup": ("pick up the cup", "picked up the cup", "picking up the cup"),
"bring me the cup": ("bring me the cup", "brought me the cup", "bringing me the cup")}
NEG_KO = {"손 흔들어": ("손 흔들", "손 흔들었", "손 흔드는", "손 흔들"), "악수해": ("악수하", "악수했", "악수하는", "악수할"),
"손 내밀어": ("손 내밀", "손 내밀었", "손 내미는", "손 내밀"), "팔 접어": ("팔 접", "팔 접었", "팔 접는", "팔 접을"),
"손 펴": ("손 펴", "손 폈", "손 펴는", "손 펼"), "주먹 쥐어": ("주먹 쥐", "주먹 쥐었", "주먹 쥐는", "주먹 쥘"),
"컵 집어": ("컵 집", "컵 집었", "컵 집는", "컵 집을"), "컵 가져와": ("컵 가져오", "컵 가져왔", "컵 가져오는", "컵 가져올")}
_neg = []
for base, past, ing in NEG_EN.values():
_neg += [f"don't {base}", f"please don't {base}", f"never {base} again", f"you don't have to {base}", f"no need to {base}",
f"you {past} earlier", f"you {past} yesterday", f"did you {base}?", f"can you really {base}?", f"have you ever {past}?",
f"if the guests come, {base}", f"{base} when i say so", f"{base} later", f"{base} tomorrow", f"minsu, {base}",
f"mom, {base}", f"i saw you {base}", f"stop {ing}", f"i love {ing}", f"{ing} is fun", f"you're good at {ing}",
f"why did you {base}?", f"who told you to {base}?", f"robots can {base}", f"i wonder if you can {base}",
f"do you know how to {base}?", f"i'd rather you didn't {base}", f"you shouldn't {base} now", f"wait, don't {base}"]
for imp, (stem, past, adn, fut) in NEG_KO.items():
_neg += [f"{stem}지 마", f"{stem}지 마세요", f"{stem}지 마십시오", f"{stem}지 마시게", f"{stem}지 마이소", f"{stem}지 말아 주세요",
f"{past}어?", f"{past}잖아", f"아까 {past}어요", f"어제 {past}습니다", f"{fut} 수 있어?", f"{fut} 줄 알아?",
f"{adn} 거 봤어", f"{adn} 거 멋있다", f"{adn} 거 신기하네요", f"{adn} 로봇이네", f"손님 오면 {imp}", f"나중에 {imp}",
f"내일 {imp}", f"민수야 {imp}", f"엄마 {imp} 봐", f"{imp} 달라고 누가 그랬어?", f"왜 {past}어?", f"{imp} 안 해도 돼",
f"{imp} 필요 없어", f"{imp}도 돼?", f"{adn} 게 좋아", f"{imp} 그만", f"{adn} 건 나중에 하자"]
NO += [t for t in _neg if not t.startswith(("minsu,", "mom,", "민수야", "엄마", "can you really"))] # a name or "can you" is
# also how a real request starts: those stay with the guards (For B2)
# ---------- Korean kids / elderly / non-native / chat slang ----------
WAVE += ["로봇아 손 흔들어 흔들어", "손 흔들어 흔들어", "안녕 안녕 손 흔들어", "빠빠이 해 빠빠이", "로봇 빠이빠이", "로봇 안녕 해 손으로",
"어이 로봇 양반 손 좀 흔들어 보게", "이 사람아 악수나 하세", "젊은이 악수 한번 하세", "로봇 양반 손 한번 흔들어 보시게",
"손 흔들어 주세요 로봇 씨", "로봇 손 흔들어요 제발", "악수 해요 우리", "손 흔들어 주세요 부탁", "손 흔들어 ㄱㄱ", "악수 ㄱ",
"웨이브 ㄱㄱ", "손 흔들어 ㅇㅇ", "손인사 ㄱㄱ", "악수 ㄱㄱ해", "손 흔들어줘 ㅎㅎ", "악수하자 ㅋㅋ", "손 흔들어 주세용 ㅎㅎ",
"로봇아 우리 애한테 손 흔들어 줘라", "애기한테 빠빠이 해 줘", "우리 손주한테 손 좀 흔들어 주게"]
ARM_REACH += ["로봇 손 줘 손", "손 손 손 줘", "손 줘 손", "로봇아 손", "손 내밀어 내밀어", "젊은이 손 좀 내밀어 보게",
"로봇 양반 손 좀 줘 보게", "이 사람아 손 좀 내밀어 보게나", "손 주세요 부탁", "로봇 씨 손 주세요", "팔 뻗어 ㄱ",
"손 내밀어 ㅇㅇ", "손 줘 ㅎㅎ", "팔 쭉 ㄱㄱ", "우리 애가 손 잡게 손 좀 내밀어 줘", "애기 손 잡게 손 내밀어 줘"]
ARM_FOLD += ["팔 접어 접어", "팔 넣어 넣어", "로봇 팔 접어", "로봇 양반 팔 좀 접게", "이 사람아 팔 거두게", "팔 접어 주세요 부탁",
"로봇 씨 팔 접어요", "팔 접어 ㄱㄱ", "팔 ㄴㄴ 접어", "팔 넣어 ㅇㅇ", "팔 접어줘 ㅎㅎ", "팔 원위치 ㄱ"]
ARM_OPEN += ["손 펴 펴", "로봇 손 펴", "손 펴 보게 젊은이", "손 펴 주세요 부탁", "손 펴 ㄱㄱ", "손 쫙 펴 ㅎㅎ", "그리퍼 오픈 ㄱ"]
ARM_CLOSE += ["주먹 쥐어 쥐어", "주먹 좀 쥐어 보게 젊은이", "주먹 쥐어 주세요 부탁", "주먹 ㄱㄱ", "손 꽉 ㅎㅎ",
"그리퍼 클로즈 ㄱ"]
PICK += ["<obj> 집어 집어", "로봇 <obj> 집어", "<obj> 좀 집어 보게 젊은이", "로봇 양반 <obj> 좀 집어 주게", "<obj> 집어 주세요 부탁",
"<obj> 잡아 ㄱㄱ", "<obj> 집어 ㅇㅇ", "<obj> 들어 봐 ㅎㅎ", "<obj> 픽 ㄱ"]
FETCH += ["<obj> 가져와 가져와", "로봇 <obj> 가져와", "<obj> 좀 가져오게 젊은이", "로봇 양반 <obj> 좀 가져다 주게", "<obj> 가져와 주세요 부탁",
"<obj> 갖다 줘 ㄱㄱ", "<obj> 가져와 ㅇㅇ", "<obj> 갖다 줘 ㅋㅋ"]
# ---------- whisper slips from the train sets (송 = 손, 해져 = 해 줘, hend, weib, gib) and more frames ----------
SLIP_FRAMES = ["any chance you could {}", "{}, chop chop", "{}, there's a good robot", "let's have you {}", "{}, test one",
"hey you, {}", "{}, can?", "{}, ok?"]
SLIP_CORES = {"wave": ["wave", "shake hands", "wave hello"], "arm_reach": ["hold out your hand", "reach toward me", "offer me your hand"],
"arm_fold": ["fold your arm", "put your arm down"], "arm_open": ["open your hand"], "arm_close": ["close your hand"],
"pick": ["pick up the <obj>", "pick the <obj> up"]}
for _k, _v in SLIP_CORES.items():
{"wave": WAVE, "arm_reach": ARM_REACH, "arm_fold": ARM_FOLD, "arm_open": ARM_OPEN, "arm_close": ARM_CLOSE,
"pick": PICK}[_k].extend(f.format(c) for c in _v for f in SLIP_FRAMES)
WAVE += ["gib me a shake", "pliz gib me a shake", "give me a shek", "give everyone a wave", "give everyone weib",
"weib please", "give weib", "wayve like a queen", "wave one more itme", "하이 웨이브 해", "하이 웨이브",
"나랑 악수", "나랑악수", "저랑 악수", "우리 악수", "안녕 해져 손으로", "웨이브 해져", "손 흔들어 져", "악수 해져",
"손 흔드러 주소", "악수 shake 해 줄래", "hello wave 해 줄래", "손 wave 한번 해 봐"]
ARM_REACH += ["송 줘", "송 이리 줘", "송 한번 줘요", "저한테 송 줘", "송 이리 주면 안 돼?", "송 내밀어", "송 좀 내밀어 줘",
"손 내밀어 져", "손 줘 져", "reach for me for mi", "reach for mi", "giv hand", "gib hand", "gib me hand",
"손!", "손 쫌 주이소", "앞으로 팔 내밀어 주실래요", "reach 해 봐"]
ARM_FOLD += ["기본 pose 로 해", "기본 포즈로 해", "기본 포즈로 돌아가", "기본 자세로 돌아가", "기본 자세", "기본 pose",
"팔 기본 포즈", "팔 접어 져", "손 다시 넣어 져", "팔 넣어 져", "folf your arm", "fold yuor arm", "put yor arm down"]
ARM_OPEN += ["송 좀 펴 줄래요", "송 펴", "송 펴 줘", "손 펴 져", "opeen your hand", "open yor hand", "open hend",
"release ㄱㄱ", "release 해", "release 해 줘", "릴리즈 해 줘"]
ARM_CLOSE += ["clench your hend", "cllose hand", "close hend", "close yor hand", "clos hend", "손 쥐어 져",
"주먹 쥐어 져", "손가락 쥐어", "손가락 쥐어 줘", "손가락 쥐어 주겠나", "꽉 쥐세요", "그리퍼 오므리시겠어요",
"집게 꽉 닫아 봐", "그리퍼 클로즈 해 줘"]
PICK += ["<obj> 픽업 해", "<obj> 픽업 해 줘", "<obj> grab 해 줄 수 있어", "take <obj> 해 주이소", "grab the <obj> 가능?",
"<obj> 집어 져", "<obj> 잡아 져", "<obj> 집어! 가즈아", "<obj> 들어라", "<obj> 잡아 봐요"]
NO += ["송 불러 줘", "송 하나 불러", "송 틀어 줘", "생일 송 불러 줘", "노래 송 틀어", "손 송 노래", "drop the beat", "drop the mic",
"let it go 불러 줘", "sing let it go", "release the song", "give everyone a break", "give everyone a minute"]
INTENT = {"wave": WAVE, "arm_reach": ARM_REACH, "arm_fold": ARM_FOLD, "arm_open": ARM_OPEN, "arm_close": ARM_CLOSE,
"pick": PICK, "fetch": FETCH, "put": PUT, "give": GIVE, "receive": RECEIVE, "no": NO}
+6
View File
@@ -316,3 +316,9 @@ QUICK["no"] += [
"엔비디아 대표 누구야", "테슬라 대표 누구예요", "삼성 회장 누구야", "who's the boss of openai", "who runs google",
"1달러에 원화로 얼마야", "1달러 원화로 얼만가", "환율 얼마예요", "달러 환율 알려 줘", "엔화 얼마야", "how much is a dollar in won",
"what's the exchange rate", "배터리 얼만가", "배터리 얼마예요", "배터리 얼마야", "배터리 얼마 남았는가"]
QUICK["co_what"] = QUICK.get("co_what", []) + ["tell me a bit about cutshion", "tell me a little about cutshion", "a few words about cutshion",
"what is cutshion like", "cutshion 소개 좀", "쿳션 소개 부탁해요", "쿳션 얘기 좀 해 줘"]
QUICK["co_founded"] += _ko(["쿳션 창업한 지 얼마나 됐", "회사 창업한 지 얼마나 됐", "쿳션 설립된 지 얼마나 됐", "쿳션 세워진 지 몇 년 됐"],
["어", "어요", "니", "습니까", "나요", "노", "어유", "는가"])
QUICK["co_hq"] += ["where is cutshion's office", "where's cutshion's office", "where is the cutshion office", "cutshion office location",
"where is your company's office", "쿳션 오피스 어디예요"]
+39
View File
@@ -738,3 +738,42 @@ QUICK["no"] += ["한 번에 몇 초 걸려", "몇 초 걸려", "몇 초나 걸
"how long does it take", "얼마나 걸려요", "시간 얼마나 걸려"]
QUICK["mics"] += ["clip mic 있어요", "클립 마이크 있어요", "무선 마이크 있어요", "시끄러우면 마이크 써", "시끄러우면 마이크 씀", "do you have a clip mic",
"is there a wireless microphone", "can i use a microphone", "마이크 따로 있어요"]
# what Lumi can do is assistant/abilities.py's: "기능" asked is never what it is used for (used_where)
QUICK["no"] += _ko(["기능 ", "너 기능 ", "기능이 ", "루미 기능 ", "할 수 있는 기능 ", "니 기능 "], _WHAT) + [
"what are your functions", "what functions do you have", "your functions what", "what features do you have", "기능 뭐 있어",
"무슨 기능 있어요", "어떤 기능 있어요", "기능 좀 알려 줘", "function 뭐 있어"]
QUICK["battery_life"] += _ko(["배터리 타임 ", "배터리 time ", "battery 타임 "], ["얼마나 돼", "얼마나 돼요", "얼마나 되세요", "얼마야", "얼마예요",
"몇 시간이야", "몇 시간이에요", "얼마나 가요", "어떻게 돼요"])
# round 5 (first-words sweep): commands and status questions that came out as fact kinds
QUICK["no"] += [
"손", "손!", "손 다시 넣어", "손 넣어", "팔 넣어", "집게 열어", "집게 닫아", "손가락 펴", "손가락 여시면 좋겠어요", "손 펴 주시겠어요", "손 펴",
"open your fingers", "could you open your fingers", "close your gripper", "please you can grip", "you can grip", "grip it", "grip please",
"바닥에 놔", "바닥에 놓으시겠어요", "바닥 체크", "바닥 봐", "바닥에 내려놔", "put it on the floor",
"where is your arm", "where's your arm now", "팔 지금 어디야", "팔 지금 어디예요", "팔 어디 있어", "arm where now",
"고개 원위치로 돌려 주세요", "고개 돌려 주세요", "머리 원위치", "허리 왼쪽으로 틀어 주세요", "turn your head ten degrees down",
"가까이 오시게", "이리 오시게", "가까이 와", "가까이 와 주세요", "come closer", "홀로 가시지요", "홈으로 가", "go plug yourself in",
"go charge yourself", "충전하러 가", "lumi what's your battery", "what's your battery level", "배터리 몇이야",
"would you raise your height", "raise your height a little", "키 좀 높여 주시겠어요", "make yourself taller", "키 높여 줘"]
# round 6 (own new phrasings, 135 written apart from the bank)
QUICK["maker"] += _ko(["너 누구 작품", "누구 작품", "이 로봇 누구 작품", "어디 작품"], ["이야", "이에요", "이니", "입니까", "인가요", "이고", "인교", "이여"]) + [
"whose work are you", "who's your creator", "who is behind this robot", "which company is behind you"]
QUICK["height"] += ["are you taller than a person", "are you as tall as a man", "are you taller than me", "사람보다 커", "사람보다 키 커요",
"어른만 해요", "사람만 해", "are you bigger than a person"]
QUICK["weight"] += _ko(["몸무게 몇 ", "무게 몇 ", "너 몇 "], ["키로예요", "키로야", "키로", "키로입니까", "키로고", "킬로예요", "킬로야", "kg이에요", "kg이야"])
QUICK["battery_life"] += ["how long can you run before charging", "how long before you need to charge", "how long can you go without charging",
"how long until your battery is empty", "충전 안 하고 얼마나 버텨", "충전 없이 몇 시간 가요"]
QUICK["model"] += ["what brain do you use to talk", "what's your brain", "what thinks for you", "what ai thinks for you", "which ai do you have inside",
"무슨 두뇌로 말해", "어떤 머리로 생각해요"]
QUICK["robot"] += ["are you a person in a costume", "is someone wearing you", "are you a costume", "is there a person in there",
"사람이 들어가 있는 거야", "탈 쓴 사람이에요", "사람이 인형 옷 입은 거예요"]
QUICK["time_now"] += ["time check", "time check please", "현재 시각 알려 줘", "현재 시각이 어떻게 돼요", "현재 시각 좀", "시각 좀 알려 주세요",
"do you know what time it is", "can you tell me what time it is"]
QUICK["how_are_you"] += _ko(["오늘 기분 좋", "기분 좋", "기분 괜찮", "오늘 컨디션 좋"], ["아", "아요", "니", "으세요", "습니까", "나", "노"])
QUICK["no"] += ["이거 몇 살짜리 장난감이야", "몇 살짜리가 쓰는 거야", "몇 살부터 탈 수 있어", "몇 살 이상 이용 가능해요", "what age is this toy for"]
QUICK["hello"] = QUICK.get("hello", []) + ["hi there lumi", "hello there lumi", "hey there lumi", "hi there robot", "hello there robot",
"hi lumi nice to meet you", "안녕 로봇아", "안녕하세요 로봇님", "루미 반가워요", "하이 로봇"]
QUICK["safety"] += _ko(["너 위험한 로봇", "위험한 로봇", "이 로봇 위험한 거"], ["이야", "이에요", "이니", "입니까", "인가요", "이고", "임"])
QUICK["tts"] += ["what speech synthesis do you use", "what voice synthesis do you use", "which speech synthesizer do you use", "음성 합성 엔진 뭐예요"]
QUICK["no"] += ["can you open the window", "open the window", "창문 열어 줘", "창문 열 수 있어", "turn on the internet", "인터넷 켜 줘",
"connect to the wifi", "와이파이 연결해 줘", "여기 안전해", "is it safe here", "이 동네 안전해요", "is this area safe",
"바닥 안전해", "is the floor safe"]
+67 -14
View File
@@ -677,7 +677,7 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
("follow", r"\b(?:follow|following|come with|come along with|come together with|walk with|tag along with)\s+(?:me|us)\b(?!\s+(?:on|at)\b)|" # not "follow
r"\bcome along\b|(?<!말 )(?<!말을 )따라\s?(?:와|오세요|오십시오|올래)|(?<!로 )(?:같이|함께)\s?(?:가자|가요|갑시다|걸어|가(?=\W*$))|" # me on instagram"
r"\b(?:and|then) follow(?: me| along)?\W*(?:(?:please|plz|thanks|bro|now|okay|ok)\W*)*$|"
r"\b(?:keep|stay|walk|go) (?:right )?behind me\b|\bi(?:'?ll| will) walk,? (?:and )?you follow\b|"
r"\b(?:keep|stay|walk|go|come) (?:right )?behind me\b|\bi(?:'?ll| will) walk,? (?:and )?you follow\b|"
r"^\W*(?:\w+\W+){0,2}(?:you )?follow\W*(?:(?:please|plz|thanks|bro|now|okay|ok)\W*)*$|\bfolow me\b|"
r"\bafter me\b(?! (?:please )?(?:say|repeat))|(?:나|저) ?(?:를|을)? ?따라서? (?:walk|와|걸어)"),
# ^ "keep behind me and follow", "I'll walk, you follow", "Lumi, after me walk please", "나 따라서 walk 해"
@@ -846,7 +846,7 @@ COME_BACK = re.compile( # the whole sentence asks Lumi back to where it stood
r"(?:come (?:on )?back|return|(?:go|head|drive) back(?= ))(?: to)?(?: (?:where you (?:were|was|started|came from|were standing)"
r"(?: before)?|the way you came|(?:your|the) (?:start(?:ing)? (?:point|place|spot|position)|start|original (?:spot|place|position)|"
r"old (?:spot|place)|spot|place)))?(?: (?:now|please|lumi|again|for me))*|"
r"(?:(?:다시|이제|좀|얼른|어서)\s*)*(?:(?:원래|아까|처음)\s*(?:있던|있었던|서 ?있던)?\s*(?:자리|곳|데|위치|장소)\s*(?:으로|로|에)\s*|"
r"(?:(?:다시|이제|좀|얼른|어서)\s*)*(?:(?:(?:원래|아까|처음|그)\s*)+(?:있던|있었던|서 ?있던)?\s*(?:자리|곳|데|위치|장소)\s*(?:으로|로|에)\s*|"
r"제자리로\s*)?(?:다시\s*)?(?:되)?돌아\s?(?:와|가|오세요|가세요|와요|가요|와라|가라|올래|갈래)"
r"(?:\s*(?:줘요?|주세요|줄래요?|봐))?|"
r"(?:(?:다시|이제|좀|얼른|어서)\s*)*(?:원래\s*(?:있던|있었던|서 ?있던)\s*(?:자리|곳|데|위치)|왔던\s*(?:길|곳|데|자리))\s*(?:으로|로)\s*"
@@ -1121,6 +1121,7 @@ def direct_order(text):
short fragment command ("booth A", "faster", "left a bit", "회전"). Only then may a keyword rule act; anything else
(a statement, a story, a plan between people, a question about ability or habit) is read by the LLM with the talk
before it. Each sentence / clause is checked; one order in it is enough (not_an_order weeds out the rest)."""
text = re.sub(r"\b(can|could|would|will) (?:ya|yah|yu)\b", r"\1 you", text or "", flags=re.I) # "could ya grab it"
t = re.sub(_LEAD, "", unfill(wording.ko_plain(_MAY_NOT.sub(" 줘", text or ""))).strip(), flags=re.I) # every
# speech level as 반말
t = re.sub(r"[\s~]*(?:[ㅋㅎ]{2,}|ㅠ+|ㅜ+)[\s~]*$|~+(?=\s*[?!.]*\s*$)", "", t) # "가 줄래~?", "고개 내려 ㅎㅎ"
@@ -1285,6 +1286,11 @@ def intent(text, markers=()):
plain = re.sub(r"줘\s*\?+\s*$", "줘", wording.ko_plain(_MAY_NOT.sub(" 줘", text))) # "놔 줘?": a request asked
if plain != text:
rule = _intent(plain, markers)
if rule is None:
prefer, cut = pick_prefer(text or "")
if prefer and cut != text:
rule = _intent(cut, markers) # "grab the smaller cup": the pick (which one: the reader's prefer)
rule = rule if rule and rule[0] in ("pick", "fetch") else None
return rule
@@ -1534,7 +1540,7 @@ def _intent(text, markers=()):
if action == "put":
return ("put", "back" if re.search(r"\bback\b|\breturn\b|\bwhere (?:it was|you)\b|\bits (?:spot|place)\b|제자리|다시|원래|원위치|있던|도로", t)
else "down")
if action == "pick" and re.search(r"\b(?:grab|get|fetch|pick up|take) me\b", t):
if action == "pick" and re.search(r"\b(?:grab|get|fetch|pick up|take) me\b|\bgimme\b", t):
return ("fetch", text) # "go grab me a cup": brought to me, not only picked
if action in ("pick", "move_object") and far:
return ("fetch", text) # "get me an orange at gate one": a trip there, not a pick here
@@ -1762,8 +1768,8 @@ def unfill(t):
KO_SLIPS = [ # Konglish, dialect and whisper's spellings of the cup / delivery verbs, as the readers know them
(r"(?:테이크|픽업|그랩|(?<![가-힣])픽)\s?해서", "집어서"), (r"(?:테이크|픽업|그랩|(?<![가-힣])픽)\s?하고", "집고"),
(r"(?:드랍|드롭)\s?해", "놔"), (r"기달려", "기다려"), (r"기달리", "기다리"), (r"(?<![가-힣])들구(?=\s|$)", "들고"),
(r"가저(?=와|다|가|오)", "가져"), (r"(?<![가-힣])날라(?=\s*(?:줘|주|다|$))", "옮겨"), (r"((?:갖다|가져다)\s?)도(?=\W*$)", r"\1줘"), (r"놓(?:그라|거라)", "놔"),
(r"(?:드랍|드롭)\s?해", "놔"), (r"기달려", "기다려"), (r"기달리", "기다리"), (r"기다리(?=\W*$)", "기다려"), (r"(?<![가-힣])들구(?=\s|$)", "들고"),
(r"가저(?=와|다|가|오)", "가져"), (r"((?:몸|손|팔|고개)(?:을|를)? )내러(?=\s|$)", r"\1내려"), (r"(?<![가-힣])날라(?=\s*(?:줘|주|다|$))", "옮겨"), (r"((?:갖다|가져다)\s?)도(?=\W*$)", r"\1줘"), (r"놓(?:그라|거라)", "놔"),
]
@@ -1854,6 +1860,8 @@ def _mentions(text, markers):
# ^ "and go exit point", "exit 가서", "exit 까지 가 줘": a drive there, said without "to" / 로
out["dest"] = _as_place(place)
for m in re.finditer(r"\bfrom (?:the )?([a-z]+)", t): # "from the kitchen": a place not on the map
if m.group(1) in ("left", "right", "table", "desk", "front", "back", "top", "side", "middle", "center", "shelf"):
continue # "from the right table": a side here, no place
if not re.match(_place_re(markers), t[m.start(1):]) and "source" not in out:
out["source"] = None
for m in re.finditer(r"(?:^|\s)([가-힣a-z0-9]+?)\s?에서(?![가-힣])", t): # "2층에서", "주방에서": not on the map
@@ -2006,7 +2014,9 @@ ASKS_AGAIN = re.compile(r"\bdidn'?t (?:quite )?(?:catch|understand|get)\b|\b(?:c
r"(?:that|it|them)\b|\bsay (?:that|it) again\b|\bnot sure what you(?:'re| are)? (?:mean|referring)|"
r"\bplease clarify\b|\bcould you (?:please )?clarify\b|잘 ?못 알아들|다시 (?:한 ?번 ?)?말씀해|"
r"\bwhat do you mean by\b|\bwhich \w+ do you mean\b|이해하지 못했|무슨 말씀이신지|무슨 뜻인지 (?:잘 )?모르|"
r"(?:어떤|무슨|어느) \S+(?:을|를)? 말씀하시는|불분명", re.I)
r"(?:어떤|무슨|어느) \S+(?:을|를)? 말씀하시는|불분명|말씀하시는 (?:건|것)(?:가요|인가요|이죠)|"
r"\bare you (?:referring|asking) (?:to|about)\b|궁금하신가요\W*$", re.I)
# (also "무엇이 걸리는 시간을 말씀하시는 건가요?", "Are you referring to the book ...?")
# a reply that asks to hear the words again
UNSURE_ANSWER = re.compile(r"^\W*(?:maybe|perhaps|not really|kind of|sort of|i don'?t know|글쎄요?|아마(?:도)?|몰라요?|모르겠어요?)\W*$",
re.I) # an answer to Lumi's question, not filler
@@ -2031,7 +2041,8 @@ def spoken(sentence, lang):
return sentence
HELD_GIVE = re.compile(r"\b(give|hand)\b|\bbring it\b|줘|주세요|건네", re.I)
HELD_GIVE = re.compile(r"\b(give|hand|pass)\b|\bbring it\b|\b(?:can|could|may) i (?:have|get|take)\b|\b(?:lemme|let me) have\b|"
r"\bgimme\b|줘|주세요|주십시오|주시|주면|주실|드려|드리|건네|내놔|내놓|이리 내", re.I)
HELD_PLACE = re.compile(r"\b(put|place|set)\b|\b(?:drop|leave) (?:it|that|this|the \w+)(?: off| down)? (?:at|on|by)\b|놔|놓|둬", re.I)
@@ -2110,6 +2121,13 @@ def pick_prefer(text):
rf"(?!\s+(?:{_SUP_WORDS})\b)", t)
if m:
return m.group(2), t[:m.end(1)] + t[m.end():]
m = re.search(rf"(?<![a-z])((?:{_OBJ})s?|ones?)\s+(?:on|from|off)\s+the\s+(left|right)\s+(?:table|desk)s?\b|"
rf"(왼쪽|오른쪽)\s*(?:테이블|탁자|책상)(?:\s*위)?(?:에|에서)\s*(?:있는\s*)?(?=(?:(?:{_COL})\s*)?(?:{_OBJ}))", t)
if m and m.group(1) and re.search(r"\b(?:put|place|set|leave|drop)\b", t[:m.start()]):
m = None # "put the cup on the left table": where it goes
if m: # "the cup on the left table", "왼쪽 테이블에 있는 컵": that side
side = m.group(2) or {"왼쪽": "left", "오른쪽": "right"}[m.group(3)]
return side, (t[:m.end(1)] + t[m.end():]) if m.group(1) else t[:m.start()] + t[m.end():]
m = re.search(rf"(?:(?:제일|가장|더)\s*)?(작은|큰|왼쪽(?:에\s*있는|의)?|오른쪽(?:에\s*있는|의)?|가까운|가까이\s*있는|먼|"
rf"멀리\s*있는)\s*(?=(?:(?:{_COL})\s*)?(?:{_OBJ})|(?:거|것|걸)(?![가-힣]))", t)
if m:
@@ -2150,6 +2168,10 @@ def place_on(text):
def held_command(text):
"""While holding: 'give' / 'place' for "give it to me", "put it on the table", "줘", "테이블에 놔". A thing to put
it on wins ("bring it to p5 and put it on the table" is a place)."""
if re.search(r"들고\s*(?:계속\s*)?있|\bkeep (?:holding|it|hold of it)\b|\b(?:just )?hold (?:it|on to it|onto it)\b", text, re.I):
return None # "계속 들고 있어 주세요", "keep holding it": nothing to do with it
if re.search(r"내놔|내놓(?:아|으)|이리 내", text):
return "give" # "내놔": hand it over, not a put
if HELD_PLACE.search(text) and place_on(text):
return "place"
if HELD_GIVE.search(re.sub(r"(?:놔|놓아|둬|올려|내려|(?<![갖다])가|가져가|들고 가|옮겨|와|이동해)\s*(?:좀\s*|쫌\s*)?(?:줘|주|드려|드리)", "놔", text)): # "그거 놔 줘": 줘 helps the put
@@ -2173,7 +2195,7 @@ RECEIVE_EN = re.compile(
rf"|\b(?:take|grab|get|accept|receive)\s+(?:(?:the|this|that|a|an|my)\s+)?(?:\w+\s+)?\w+\s+(?:from (?:me|my hands?)|out of my hands?|i'?m holding|in my hand)\b"
rf"|\b(?:take|grab)\s+my\s+(?:(?:{_COL})\s+)?(?:{_OBJ})s?\b|\b(?:take|hold|catch)\s+this\s+(?:(?:{_COL})\s+)?(?:{_OBJ})s?\b(?!\s+(?:on|from|off|over)\b)"
rf"|(?:^|[\s,.!])hold\s+(?:{_IT}|this \w+|my \w+)\b(?!\s+(?:up|out|on|thought)\b)(?! for me while)"
rf"|\bhang on to (?:{_IT})\b|\bhere(?: you go| it is|'?s (?:the|a|my|your) \w+(?: \w+)?)\b|^\W*here\W+(?:take|hold|catch)\b"
rf"|\bhang on to (?:{_IT})\b|\bhere(?: you go| it is|'?s (?:the|a|my|your) (?!(?:task|job|order|plan|question|answer|chance|turn|problem|deal|thing:)\b)\w+(?: \w+)?)\b|^\W*here\W+(?:take|hold|catch)\b"
rf"|\bi(?:'ll| will|'m going to| want to| wanna|'d like to| would like to)\s+(?:give|hand)\s+you\b"
r"(?!\s+(?:a|an|some) (?:tip|hint|call|ring|ride|hand|hug|break|second|minute|chance|clue|idea)\b)"
rf"|\bi(?:'m| am)\s+(?:giving|handing)\s+you\b|\bi (?:have|got|brought) (?:something|a \w+|this|it) for you\b", re.I)
@@ -2189,7 +2211,8 @@ PAID_Q = re.compile(r"(?<![가-힣])(?:월급|연봉|급여|보너스|월세|세
r"훈련|충전|수리|검사|업데이트)(?:을|를|은|는|도|이|가)?\s*(?:많이 |잘 |자주 |얼마나 )?받|"
r"^\W*(?:너|넌|너는|루미는?|당신은?)\s.*받(?:아|아요|니|나요|냐|았어|으세요)?\s*\?\s*$") # a question about Lumi
GIVE_EN = re.compile(
rf"\b(?:give|hand|pass|bring|deliver)\s+(?:{_IT}|the \w+|that \w+|this \w+)(?:\s+(?:back|over))?(?:\s+(?:to|for)\s+{_WHO})?(?:\s+(?:here|over here|over there|there|back))*{_TAIL}"
rf"\b(?:give|hand|pass|bring|deliver)\s+(?:{_IT}|the \w+|that \w+|this \w+)(?:\s+(?:back|over))?(?:\s+(?:to|for)\s+(?:{_WHO}|"
rf"(?!(?:the|a|an|my|your|his|her|their|our|table|floor|ground|it|that|this)\b)[a-z][a-z'-]+))?(?:\s+(?:here|over here|over there|there|back))*{_TAIL}"
rf"|\b(?:give|hand|pass)\s+(?:{_WHO})\s+(?:{_IT}|the \w+|that \w+|that|this \w+|what you(?:'re| are) holding)\b"
rf"|\bhand (?:{_IT} )?over\b|\bpass (?:{_IT} )?over\b|\bcan i (?:have|get|take) (?:{_IT}|the \w+)\b|\bi'?ll take (?:{_IT}|(?:that|the|this) \w+)\b(?! from here)|"
rf"\blet me (?:have|take) (?:{_IT})\b|^\W*(?:okay,? )?give (?:{_IT})\W*$|^\W*gimme(?: (?:{_IT}))?{_TAIL}", re.I)
@@ -2248,7 +2271,7 @@ GIVE_LOOSE = re.compile( # with something in the hand, the whole sentence asks
rf"{_POL}\W*|\W*(?:me|to me)\W+(?:please\W+)?give{_POL}\W*|\W*i want (?:it|that|this|that one)(?: back)?{_POL}\W*|"
rf"\W*(?:that'?s|it'?s) mine{_POL}\W*|\W*could i trouble you to (?:hand|give|pass) (?:it|that|this)(?: over| to me)?\W*|"
rf"\W*(?:(?:나|저|우리|나한테|저한테|우리한테|이리|그거|이거|그것|이것|저거|내 거야|내 거|제 거예요|그|이|좀|빨리|어서|얼른|"
rf"(?:그|이|저) \S+)\W*)*(?:줘|주게|주세요|주라|줄래요?|줘요|내놔|내놓으세요|건네 ?줘|건네 ?주세요)(?:\W+(?:줘|주세요))*{_POL}\W*",
rf"(?:그|이|저) \S+)\W*)*(?:줘|주게|주세요|주라|줄래요?|줘요|내놔|내놓으세요|건네 ?줘|건네 ?주세요|(?<=이리 )내)(?:\W+(?:줘|주세요))*{_POL}\W*",
re.I)
IN_MY_HAND = re.compile(r"\b(?:in|into|on) my (?:hands?|palm)\b|(?:제|내|나의|저의) 손(?:에|위에|바닥에|으로)", re.I)
REFUSE_PICK = ("I'm holding something already. Tell me where to put it first.",
@@ -2417,7 +2440,8 @@ def held_place(text, markers=()):
CARRY_HELD = re.compile(r"\b(?:take|bring|carry|move|get) (?:it|that|this|them|the \w+)(?: over| along)? (?:to|towards?) |"
r"\b(?:drop|leave|put|set) (?:it|that|this|them|the \w+)(?: off| down)? (?:at|by|near|on) |"
r"(?:으로|로|에|까지)\s*(?:좀\s*)?(?:가져가|가지고 ?가|갖고 ?가|들고 ?가|옮겨|가져다 ?놔|가 ?줘|가)", re.I)
r"(?:으로|로|에|까지)\s*(?:좀\s*)?(?:가져가|가지고 ?가|갖고 ?가|들고 ?가|옮겨|가져다 ?놔|가 ?줘|가)|"
r"(?:테이블|탁자|책상)?\s*(?:위)?\s*에\s*(?:좀\s*)?(?:놔|놓아|둬|올려)", re.I) # "p5 테이블에 놔"
def object_ko(name):
@@ -2471,9 +2495,10 @@ def held_give(text, markers=()):
return False
if any(_resolve(m, markers) not in (None, "here") for m in re.finditer(_place_re(markers), t)):
return False # a marker named: a carry there (the mission reader's)
if re.search(r"\b(?:give|hand|pass|bring)\s+(?:it|that|this)\s+to\s+(?!me\b|him\b|her\b|them\b|us\b|my\b|his\b|our\b|"
if re.search(r"\bbring\s+(?:it|that|this)\s+to\s+(?!me\b|him\b|her\b|them\b|us\b|my\b|his\b|our\b|"
r"your\b|that\b|the\b|this\b|whoever\b|someone\b|a\b|an\b)[a-z]+\s*[.!?]*$", t):
return False # "give it to Mina": a named person, the mission reader's
return False # "bring it to Mina": a trip to her, the mission reader's; "give /
# hand it to Mina" is given here, as "민수한테 줘"
if GIVE_HELD_EN.search(t):
return True
for m in GIVE_HELD_KO.finditer(t):
@@ -2987,6 +3012,11 @@ _PRONOUN_KO = r"그거|이거|저거|그것|이것|저것|거기|여기|저기|
OWN_SUBJECT = re.compile(rf"(?<=\S )(?!I\b|Lumi\b|OK\b|Okay\b)[A-Z][a-z]+|(?<![가-힣A-Za-z])(?!(?:{_PRONOUN_KO})(?:은|는|이|가)(?![가-힣]))"
r"[가-힣A-Za-z]{2,}(?:은|는|이|가)(?=[\s?!.~,]|요|$)")
# a short question that names its own subject ("BTS는 언제 데뷔했어요?", "Who was Sejong?")
BACK_TO = re.compile(r"\b(?:back to|go(?:ing)? back to|return(?:ing)? to|again about)\b|돌아가서|돌아와서|돌아가면|"
r"(?:다시|아까) \S+ ?(?:얘기|이야기|토크|말씀)", re.I) # a return to an earlier topic
BACK_TO_STOP = re.compile(r"(?i:back|go|going|return|returning|again|about|what|you|your|said|say|the|did|tell|"
r"me|that|this|talk|topic|part)$|다시|아까|얘기|이야기|말씀|돌아|뭐라|했지|했죠|하셨|토크|루미|그거|그건")
KO_PARTICLE_END = r"(?<=[가-힣])(?:으로|로|이라는|라는|에|은|는|이|가|을|를|의)(?=\s|$|[,.?!])"
NOT_SUBJECT_KO = re.compile(r"(?:으로|적으로|에서|에|까지|부터|보다|한테|에게)는$")
# "공식적으로는", "옛날에는", "서울에서는": a time / place / manner, not the subject
WHAT_IS = re.compile(r"(?:뭐|무엇|뭔|머)(?:예요|에요|야|이야|입니까|인가요|이에요|가요|죠|지|냐|고|여|임|래요|래)?\W*$|"
@@ -2996,6 +3026,10 @@ THAT_ONE_KO = re.compile(rf"(?<![가-힣A-Za-z])(?!(?:{_PRONOUN_KO})\s)([가-힣
OF_THING_KO = re.compile(rf"(?<![가-힣A-Za-z])(?!(?:{_PRONOUN_KO})(?:의)?\s)([가-힣A-Za-z]{{2,}}?)(?:의)?\s+"
r"(?:이름|나이|키|높이|무게|속도|가격|크기|색|색깔|모양|뜻)(?:은|는|이|가|도)?(?![가-힣])")
# "블루투스 이름은 왜 그렇게 지었나?": Bluetooth's name, not Lumi's
TOPIC_OF_TALK = re.compile(rf"(?<![가-힣A-Za-z])(?!(?:{_PRONOUN_KO}|아까|그런|이런|저런|무슨|다른|재밌는|재미있는|옛날|"
r"딴|그|이|저|제|내|네|니)\s)([가-힣A-Za-z]{2,})\s*(?:얘기|이야기|토크)|"
r"\b(?i:tell me about|talk about|talking about|back to)\s+(?:the\s+|an?\s+)?([a-z]{3,})")
# "emoji 얘기 좀 해 줘요", "tell me about mirrors": the talk's subject
EN_SUBJECT = re.compile(r"\b(?i:do|does|did|can|could|are|is|were|was|will|would)\s+(?:the\s+|an?\s+)?"
r"(?!(?:you|i|we|they|he|she|it|people|there|this|that|these|those|your|my|our|me|not|so|very)\b)"
r"([a-z]{3,})\b") # "Why do whales sing?": the whales (world_talk; lower case, so not OWN_SUBJECT)
@@ -3277,7 +3311,8 @@ class Brain:
def named(t): # "공식적으로는 언제로 쳐요?" names no subject (an adverb + 는)
return [m.group(0) for m in OWN_SUBJECT.finditer(core(t)) if not NOT_SUBJECT_KO.search(m.group(0))] + \
[m.group(1) for m in EN_SUBJECT.finditer(core(t))] + [m.group(1) for m in THAT_ONE_KO.finditer(core(t))] + \
[m.group(1) for m in OF_THING_KO.finditer(core(t))]
[m.group(1) for m in OF_THING_KO.finditer(core(t))] + \
[m.group(1) or m.group(2) for m in TOPIC_OF_TALK.finditer(core(t))]
qs = [topic_turn(self.history)[0]] + [h[0] for h in reversed(self.history[-3:])] if self.history else [""]
q = next((x for x in qs if named(x)), qs[0]) # "문어 피는?" "왜?" "심장은?": the octopus, two turns back
if named(text) and WHAT_IS.search(core(text)):
@@ -3289,9 +3324,27 @@ class Brain:
return list(dict.fromkeys(re.sub(r"[은는가]$", "", w) for w in subjects # "부엉이" keeps its 이
if not SELF_THINGS.match(w[:-1] if HANGUL.search(w) else w)))
def _back_to(self, text):
""" "Back to the hydrogen: what did you say?", "다시 페트라 얘기로 돌아가서, 뭐라고 했지?": the earlier turn of this
talk that named that topic, as a hint, else "". Late in a talk that turn is out of the window and the model
answered the topic just before (r13 train, 2026-10-27)."""
if not BACK_TO.search(text) or len(self.history) < 2:
return ""
words = {w for w in re.findall(r"[가-힣]{2,}|[A-Za-z]{3,}", re.sub(KO_PARTICLE_END, "", text))
if not BACK_TO_STOP.match(w)}
for q, a in reversed(self.history):
said = " ".join(ln for ln in a.splitlines() if not re.match(r"\s*\**ACTION", ln)).strip()
if said and any(w.lower() in f"{q} {said}".lower() for w in words):
return (f"(They go back to an earlier topic: to \"{q[:80]}\" you said \"{said[:FRAGMENT_CHARS * 2]}\". "
f"Answer about that topic, with those facts.)\n")
return ""
def _fragment_hint(self, text):
"""For a bare fragment ("얼마?", "Which one?", "Where is it used?"): what it follows, so the model reads it
as about the last answer's subject, not about itself or a price."""
back = self._back_to(text)
if back:
return back
last = self._last_said() if self.history else ""
done = self._redo(text)
if done: # "do it again" / "한 번 더" after a wave, "more" after a look
+2
View File
@@ -88,6 +88,8 @@ def parts(text):
text = re.sub(r"(?<![\w가-힣])([\w가-힣]+)[—–-]+\s*(?=\1)", "", text) # a stutter: "go ah— ahead", "센— 센티"
cut, says = steps._cut_says(text)
cut = re.sub(r"(?<=[가-힣])고\s*나서(?=[\s,]|$)", "고", cut) # "-고 나서" = "-고"
cut = re.sub(r"(?<=[가-힣]{2}고)(?=(?:오른쪽|왼쪽|앞으로|뒤로|위로|아래로|손|고개|몸|팔|허리|나를?|저를?|이리|여기|저기|"
r"p\d|[a-z]{3}))", " ", cut) # whisper's run-together "몸내리고오른쪽으로돌아주라": the next order apart
out = []
for p in _SPLIT.split(cut):
out += [q for q in steps._SPLIT_KO.split(p) if q.strip()]
+25 -9
View File
@@ -33,7 +33,7 @@ FILLS = 3 # place / object fills made of each template (the same e
# ---------- 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|"
r"never ?mind|scratch that|cancel that)\b|취소|아니다|됐다|"
r"never ?mind|scratch that|cancel that|cancel)\b|취소|아니다|됐다|"
r"[가-힣]지 ?마(?:세요|요|라|십시오|쇼|소|이소|시오|셔)?(?:잉|요)?(?![가-힣])|하지 ?말|말고|[가-힣]지 ?(?:말아|말라|마시|마셔|말게)|필요 ?없|안 ?(?:해|돼|가|와)(?:도)?\b|그만", re.I)
LATER = re.compile(r"\b(?:when|whenever|if|unless|after|before|once|until|till|as soon as|later|tomorrow|tonight|"
r"next time|some ?day|one day|in (?:\w+ ){0,2}(?:minute|hour|second|min|sec)s?|in a (?:while|bit)|soon)\b|분 ?(?:뒤|후|있다)|"
@@ -83,7 +83,7 @@ REPEAT = re.compile(r"^\W*(?:(?:\w+\W+){0,2})?(?:again|one more time|once more|d
r"^\W*(?:[가-힣]+\s+)?(?:한 ?번(?:만)? 더|다시|또)\s*(?:해|해 ?줘|해 ?봐|해 ?주세요|하자)?\W*$", re.I)
# "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|"
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|oops|first)\b|;|"
r"(?!갖고|고고|에서)(?<!가)[가-힣](?:서|고)(?:[\s,.…]|$)|(?:으로|로|에) ?가서|"
r"(?:흔들|흔드시|보시|돌|내리|올리|집어|내밀|숙이|들|봐 ?주시)고(?=[가-힣])|(?:쪽|나|날|위|아래|앞)보고(?=[가-힣])|(?:집어|와|가져와)서(?=[가-힣])|하고|셔서|면서|다가(?![와오])|갔다|다녀|아니|기다|대기|(?:가|와) ?있어|계세요|"
r"계십시오", re.I)
@@ -92,7 +92,7 @@ HAND_WORDS = re.compile(r"\byou(?:'re| are) holding\b|\b(?:in|from) my hand\b|\b
r"\bhold this\b|\bfrom me\b|\bmy hand\b|\bhand ?에|\bhand it (?:over|to me)\b|\bhand over\b|내 손|제 손|손에 ?(?:줘|놔|주세요|쥐어)|\bi'?m holding\b|\bi am holding\b|들고 있는|손에 있는|받아|드릴게|줄게|가져가세요", re.I) # the hand reader's (brain.hand_request)
GROUP_CALL = re.compile(r"(?:^|[,:;.!?]\s*)(?:(?:hey|ok|okay|alright|so|come on)\s+)?(?:(?:you )?guys|folks|y'?all|"
r"you all|everyone|everybody|team|kids|people|ladies|gentlemen)\s*(?:[,:;!.]|$)|"
r"얘들아|애들아|친구들아|여러분[,\s]", re.I) # "guys, get me the bottle": said to the people around
r"얘들아|애들아|친구들아|여러분[,\s]|(?<![가-힣])(?!로봇|루미)[가-힣]{1,4}님(?:[,!\s]|$)", re.I) # "guys, get me the bottle": said to the people around
NAME_CALL = re.compile(r"^\W*(?:(?:ah|oh|hey|hi|okay|ok|so|um|uh|look|and)\W+)?([A-Z][a-z]+)\s*,") # "Jake, follow me": said to Jake
NOT_A_NAME = {"lumi", "loomi", "rumi", "okay", "ok", "please", "hey", "hi", "hello", "so", "well", "now", "alright",
"yes", "yeah", "no", "sorry", "um", "uh", "oh", "wait", "look", "then", "first", "also", "and", "but",
@@ -863,7 +863,9 @@ CARRY = (r"\b(?:bring(?! yourself)|fetch|deliver|carry)\b|\bget me\b|\b(?:to|for
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"(?<![가-힣])컴(?= ?히어|(?![가-힣]))") # Konglish "컴 히어 해 줘", "이리 컴"
HOME_SAID = r"\b(?:home|dock|charger|charging)\b|집|충전|도크|홈" # brain.named_place also reads a bare "go back" as home
PREV_SPOT = r"원래|아까|처음|출발|원위치|\bwhere you (?:were|started|came from|stood)\b|\b(?:original|previous|starting|old) " # where
HOME_SAID = r"\b(?:home|dock|charger|charging)\b|집|충전|도크|홈" # it stood before; brain.named_place reads a bare "go back"
# / "돌아가" as home (and the test sets read "go back to your spot" as home), so home counts only when said
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|"
r"shrink|come down|go up|go down|move up|move down|raise up|lower down|come up|sink down|elevate|squat|height|"
@@ -1031,7 +1033,7 @@ def _slot(kind, text, markers, holding):
return ("move", f"forward {n:g}") if exact and driving.MOVE_MIN_M <= n <= brain.MOVE_MAX_M else None
if kind == "come_back" and (re.search(r"\bpose\b|\barm\b|\bhead\b|팔|고개|\bpick|\bput\b|\bit\b|그거|놓|놔", t) or
any(brain.named_place(text, m, markers) for m in markers
if m != "home" or re.search(HOME_SAID, t))):
if m != "home" or not re.search(PREV_SPOT, t) or re.search(HOME_SAID, t))):
return None # "go back to your dock", "go back to your look pose": not here
if kind == "come_back" and re.search(r"\b(?:back|over|right|come|get) here\b|\bto me\b|이리|여기|나한테|저한테", t):
return ("come", "") # "come back here": to the person, not to the old spot
@@ -1049,7 +1051,7 @@ def _slot(kind, text, markers, holding):
return None # "turn left a bit", "왼쪽으로 도세요": a turn, not a drive
if re.search(r"\b(?:some|more than|less than|few|several|couple)\b|\b(?:to|too) (?:meters?|metres?|m)\b", t):
return None # "move back some", "forward to meters": how far? asked
d = _dirs(t)
d = _dirs(re.sub(r"\bright\s*,", " ", t))
n = said_amount(text)[0]
n = driving.amount(re.sub(r"(?:^|\s)좀(?=\s)", " ", t))[0] if n is None else n # "뒤로 좀 가": 좀 is "please"
if re.search(r"\b(?:third|fourth)\b", t) or n is None and re.search(r"\b(?:half|meters?|metres?|cm|centimet\w*|inch\w*|feet|foot|yards?)\b|미터|"
@@ -1065,7 +1067,7 @@ def _slot(kind, text, markers, holding):
return None # "look the other way", "twist your torso": not the base
if re.search(r"\bquarter\b|\bhalf\b|반 ?바퀴", t) and not re.search(r"\d", t):
return None # "spin left a bit, like a quarter": not a full turn (A2)
if re.search(r"\bspin\b|\ball the way (?:a)?round\b|\b360\b|한 ?바퀴", t) and \
if re.search(r"\bspin\b|\ball (?:the|teh|da) way (?:a)?round\b|\b360\b|한 ?바퀴", t) 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):
return ("turn", ("right" if re.search(r"\bright\b|오른쪽", t) else "left") + " 360")
@@ -1101,7 +1103,7 @@ def _slot(kind, text, markers, holding):
target = "me"
return ("look", target) if target else None
if kind == "lift":
if not re.search(LIFT_BODY, t):
if not re.search(LIFT_BODY, t) or re.search(r"\bto me\b|나한테|저한테", t): # "come up to me": come
return None # "go upstairs": no word about Lumi's own height
down = re.search(r"\b(?:down|lower|shorter|smaller|small|sink|shrink|squat)\b|낮|줄여|작게|작아|내려|아래|다운", t)
up = re.search(r"\b(?:up|higher|taller|tall|high|bigger|raise|rise|grow|elevate|stretch)\b|높(?:여|게|아|혀)|키워|올려|늘려|"
@@ -1199,7 +1201,10 @@ def _verb_conflict(kind, text, holding):
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)):
if kind == "come_back" and (POINTED.search(text) or not BACK_VERB.search(text) or not RETURN_WORD.search(text) or
re.search(r"제자리에서|바퀴|자세|포즈", text)):
return True # "다시 가 주세요" (go again), "제자리에서 한 바퀴", "원래 자세로"
if kind == "come_back" and not TRAVEL.search(re.sub(r"\bback\s+해", "", 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
@@ -1216,6 +1221,10 @@ def _verb_conflict(kind, text, holding):
return True # "you must straighten your waist": the waist, not the arm
if kind == "arm_open" and not OPEN_WORD.search(text) or kind == "arm_close" and not CLOSE_WORD.search(text):
return True # "grip immediately": no open word, no gripper opening
if kind in ("pick", "fetch") and not TAKE_WORD.search(text):
return True # "컵을 바 주라" (봐 heard as 바): no take verb
if kind == "arm_reach" and not ARM_WORD.search(text) and not REACH_WORD.search(text):
return True # "그거 주시게", "건네시겠어요": a hand-over, not the arm out
if kind == "wave" and not WAVE_VERB.search(text):
return True # "손 벌려 줘", "손 쥐어 빨리", "손 좀 주이소"
return holding and kind in ("arm_open", "arm_fold", "arm_reach", "arm_close")
@@ -1229,6 +1238,13 @@ COME_VERB = re.compile(r"(?<![가-힣])와(?![가-힣])|와 ?(?:줘|주)|오세
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|"
r"handshake|shaking|goodbye", re.I)
TAKE_WORD = re.compile(r"집|잡|들어|들고|가져|갖|가지고|가저|가 ?온나|챙|쥐|픽|그랩|브링|겟|캐치|홀드|지버|테이크|옮겨|"
r"\b(?:pick|grab|take|took|get|fetch|bring|brin|brung|hold|snatch|lift|nab|seize|collect|snag|"
r"scoop|pluck|grasp|grip|carry|deliver|hand|pass|gimme|obtain|retrieve|go for|pic|grap|pik|peek up|reach for|"
r"fech|need the|like the|taking|move the)|자바", re.I)
RETURN_WORD = re.compile(r"(?:다시|도로) ?와|도라|돌아|복귀|원래|제자리|원위치|아까|처음|출발|컴백|리턴|\b(?:back|return|comeback|bak)\b", re.I)
TRAVEL = re.compile(r"돌아|도라|복귀|원위치|가|와|오|컴백|리턴|\bback to\b|\bcoming\b|\b(?:come|go|return|head|drive|move|get|cum|comeback|roll)\b", re.I)
REACH_WORD = re.compile(r"내밀|뻗|리치|핸드|(?<![가-힣])암(?![가-힣])|아웃|\bpaw\b|\b(?:reach|extend|stretch|out)\b", re.I)
OPEN_WORD = re.compile(r"펴|펼|벌려|벌리|열|오픈|풀어|놔|놓|\b(?:open|release|let go|loosen|unclench|spread|relax|widen|"
r"opn|apart)", re.I)
CLOSE_WORD = re.compile(r"쥐|닫|오므|모아|모으|주먹|클로즈|꽉|잡|\b(?:close|clos|shut|grip|clench|fist|squeeze|tighten|grasp|curl|"
+12 -6
View File
@@ -1789,7 +1789,10 @@ class Lumi:
target = f"{colour} {name}" if colour else name
if action == "pick":
said, done = (f"Okay, I'll pick up the {target}.", "네, 집어 볼게요."), ("I've got it.", "잡았어요.")
run = lambda: skills.pick(name, colour)
def run(): # the held name for the dashboard and the replies
from tasks import fetch
skills.pick(name, colour)
fetch.held_by_skill({"object": name, "colour": colour})
else:
said, done = (f"Okay, I'll move the {target}.", "네, 옮겨 볼게요."), ("Done.", "다 옮겼어요.")
run = lambda: skills.move_object(name, colour)
@@ -3345,8 +3348,8 @@ def status_question(text):
def says_goodbye(text):
"""A goodbye whatever was said before: "okay, bye", "I have to go", "수고하세요", "you can go" alone (not "bye, but
where is...?", not an order with it, not said to a child nearby)."""
if brain_mod.to_someone_else(text):
return False # "Okay kids, say bye to the robot."
if brain_mod.to_someone_else(text) or re.search(r"\b(?:let me|lemme|wanna|want to|like to|love to|let'?s) see you\b", text, re.I):
return False # "Okay kids, say bye to the robot."; "lemme see you go charge"
return bool(RELEASE.match(text) or CLEAR_BYE.search(text) and not ASKS_MORE.search(text)
and len(text.split()) <= 10 and not brain_mod.intent(text) and not brain_mod.hand_request(text, False)
and not COMMAND_START.search(brain_mod.CALLING.sub("", text))) # "grab the cup, bye": an order
@@ -3409,8 +3412,11 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
return "detour", how
plan = chain_ok and not brain_mod.not_an_order(text, asked=False) and brain_mod.direct_order(text) and \
chain.plan(text, markers, NOT_A_STEP) # not "when the show starts, go to the stage", "Jake, wave"
if plan and any(k == "steps" and any(st.get("do") == "pick" for st in w) or k == "quick" and w[0] in ("pick", "move_object")
for k, _, w in plan) and (holding() if callable(holding) else holding):
picks = [i for i, (k, _, w) in enumerate(plan or []) if k == "steps" and any(st.get("do") == "pick" for st in w) or
k == "quick" and w[0] in ("pick", "move_object")]
frees = [i for i, (k, _, w) in enumerate(plan or []) if k == "steps" and any(st.get("do") in ("place", "give") for st in w)
or k == "quick" and w[0] in ("put", "give")] # "왼쪽에 내려놓고 오른편 컵 잡아 줘": the hand is free first
if picks and not (frees and frees[0] < picks[0]) and (holding() if callable(holding) else holding):
plan = None # "그 cup 들고 wave 해" with a cup in the hand: no second pick; the LLM
if plan:
return "chain", plan
@@ -3419,7 +3425,7 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
got = seen(text) if seen and not held_order else None # the hand, not "I put it down, now?"
if got:
return "seeing", got
if status_question(text):
if status_question(text) and not brain_mod.to_someone_else(text): # not "Mina, what are you doing over there?"
return "status", None
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):
+36 -14
View File
@@ -277,14 +277,15 @@ ABOUT_ME = re.compile(r"\b(?:(?<!can )(?<!could )(?<!may )i(?! (?:call|address)
r"(?<!tell )(?<!give )(?<!let )(?<!show )me|mine)\b|(?:^|\s)(?:나|내|제|저|난|전)(?:는|가|를|의)?\s", re.I)
FRAGMENT = re.compile(r"^\W*(?:and|so|but|then|or|also|why|really|seriously|wait|what about|how about|how come|are you sure)\b|"
r"^\W*(?:그럼|그러면|그리고|근데|그런데|그래서|아니|왜|진짜|정말|확실|설마|또)|"
r"\b(?:that|(?<!is )(?<!was )(?<!is it )(?<!how's )(?<!how is )it(?! is (?:now|today))|they|them|"
r"\b(?:that|(?<!is )(?<!was )(?<!is it )(?<!how's )(?<!how is )(?<!time )(?<!day )it(?! is (?:now|today))|they|them|"
r"(?<!hello )(?<!hi )(?<!hey )(?<!is )(?<!are )there(?! (?:is|are)\b)|this one)\b|"
r"그거|그건|거기|그분|그 회사|걔", re.I) # not the clock's "it": "what day is it?"
OTHER = re.compile(r"\b(?:lift|carry|hold|items?|(?<!this )things?|stuff|price|cost)\b|들 ?수|(?<!만)(?<!알아)(?<!뭐 )들어(?! ?있)|물건|"
r"^(?!.*(?:키|무게|체중|신장|속도|시간|나이|높이|길이|크기|수명|배터리|하이트|웨이트|스피드|에이지|height|weight|speed|age|battery|life))"
r"^(?!.*(?:키|무게|체중|신장|속도|시간|나이|높이|길이|크기|수명|배터리|하이트|웨이트|스피드|에이지|속력|하중|정밀도|오차|height|weight|speed|age|battery|life))"
r".*얼마(?:야|예요)|"
r"맞(?:아|지|죠|나|습니까)|아니(?:야|에요|죠)", re.I) # what it can hold, the price, a check: the LLM
SEVERAL = re.compile(r"\band\b(?!\s+(?:built|made|\w+ed)\s+(?:you|lumi|this robot)\b)|\bthen\b|그리고|[??].+\S|하고\s|랑\s|"
r"(?:가|와|돌아|들어|내려|올라|가져와|가지고 와|하고 나)서\s|"
r"[가-힣](?<![최광참사창공경재원라])(?<!그리)고\s+(?!싶|있|계)", re.I) # "고개 숙이고 몇 시야?", "보고 시간 알려 줘"
EVENT_TIME = re.compile(r"\b(?:what time|what day|which day|what date) (?:does|do|did|will|is|are|was|were|should|can)\b"
r"(?!\s+(?:it|today)\b)|몇 ?시(?:에|부터|까지|쯤에)|며칠(?:에|까지|부터)|무슨 요일(?:에|까지|부터)|"
@@ -304,7 +305,9 @@ _exact_kinds = None
def _squeezed(t):
return re.sub(r"[\s,.!?~]", "", t).lower()
"""The words without spaces, marks, a calling word or "너" first: "실례지만너무게얼마예요" = "무게 얼마예요"."""
t = re.sub(r"[\s,.!?~]", "", t).lower()
return re.sub(r"^(?:실례지만|실례합니다|저기요|저기|어이|이보게|우리|야|하나여쭤봐도될까요)?(?:루미야|루미|로봇아|로봇)?(?:너|니|네|당신)?", "", t)
def _exact():
@@ -350,7 +353,7 @@ OPENER = re.compile(r"^\W*(?:(?:hello|hi|hllo|helo|hey|excuse me|well|okay|ok|oh
r"(?:야|아야|우리|이보게|어이|야야) ?(?:루미야|루미|로봇아|로봇)|실례합니다|실례지만|실례할게요|하나 묻겠습니다|하나 물을게(?:요)?|루미루미|누미야|"
r"루미 ?(?:님|군|상|씨|언니|오빠|누나|형)|루미야|루미|로봇(?:아|님|씨)?|robot|lumi)(?![\w가-힣])[\s,.!?~:-]*)+", re.I)
# calling words before the question ("hello robot, ...", "루미 님, ...", "실례합니다. ..."): left out of the meaning
REMARK = re.compile(r"(?:quick question|just (?:curious|wondering|asking)|(?:i'?m )?curious|i want to know|i'd like to know|"
REMARK = re.compile(r"(?:(?:어+|아+|음+|um+|uh+)\s+)?(?:quick question|just (?:curious|wondering|asking)|(?:i'?m )?curious|i want to know|i'd like to know|"
r"please|thanks?|thank you|tell me(?: please)?|any idea|ㅎ+|ㅋ+|\^+|그냥 궁금해서(?:요)?|궁금하다|궁금해(?:요)?|"
r"궁금하네(?:요)?|궁금합니다|알고 싶어(?:요)?|알고 싶습니다|(?:좀 )?(?:알려|말해|가르쳐) ?(?:줘|줄래|줄래요|주세요|"
r"주실래요|주시겠어요|주시겠습니까|주십시오|봐)|진짜 궁금해(?:요)?|"
@@ -373,7 +376,8 @@ def _core(text):
from assistant import brain
t = brain.unfill(text or "")
rest = OPENER.sub("", t)
if len(rest.split()) >= 2 or re.search(r"[가-힣]{4}", rest): # "hello there", "hi lumi" stay whole
words = re.sub(r"\b(?:there|lumi|robot)\b|[^\w\s]", " ", rest, flags=re.I).split()
if len(words) >= 2 or re.search(r"[가-힣]{4}", rest): # "hello there", "hi there, Lumi!" stay whole
t = rest
t = ASKING.sub("", brain.CALLING.sub("", t).strip()).strip() or text or ""
if not re.search(r"\b(?:is|was|name|named|called)\s+lumi\W*$|이름(?:이|은|을)?\s*루미", t, re.I): # "How wide is Lumi?",
@@ -386,8 +390,12 @@ def _core(text):
lambda m: m.group(1) + ("이에요" if (ord(m.group(1)) - 0xAC00) % 28 else "예요"), t)
t = re.sub(r"(?<=[가-힣])는지 (?:궁금|알고 싶|알려|말해|알 수 있|여쭤)\S*(?: \S+)?$", "나요", t) # "몇 살인지 궁금해요"
t = re.sub(r"(?:뭔가|무엇인가)$", "뭐예요", re.sub(r"(?<=[가-힣])(?:는교|남유|는감)$", "나요", t)) # 하게체, dialect
t = re.sub(r"(?<=[가-힣])인교$", "인가요", t)
t = re.sub(r"얼만가$", "얼마예요", re.sub(r"(?<=[가-힣])는가$", "나요", re.sub(r"(?<=[가-힣])인가$", "인가요", t)))
return t or (text or "").strip(" ,.!?~") # 하게체 questions ("키 얼만가", "얼마나 되는가") as 해요체
# 하게체 questions ("키 얼만가", "얼마나 되는가") as 해요체
if re.fullmatch(r"(?:there|all|everyone|everybody)\W*", t, re.I):
t = "" # "Hi there, Lumi!": a hello, said whole
return t or (text or "").strip(" ,.!?~")
def guarded(text, history=()):
@@ -418,12 +426,16 @@ def guarded(text, history=()):
return "event time"
if re.search(r"타워|빌딩|건물|(?<![가-힣])탑|에펠|남산|한라산|백두산|\b(?:tower|building|mountain|bridge|skyscraper)\b", t, re.I):
return "another thing" # "롯데타워 하이트 얼마야?": not Lumi's height
if re.search(r"날씨|날시|비 ?(?:와|오|올|온)|눈 ?(?:와|오|올)|미세 ?먼지|황사|우산|기온|덥|춥|\b(?:weather|rain|raining|snow|"
r"forecast|temperature|umbrella|sunny|cloudy)\b", t, re.I):
return "weather" # "오늘 미세먼지 어때?": the weather lookup, never how Lumi is
if re.search(r"날씨|날시|웨더|뉴스|소식|비 ?(?:와|오|올|온)|눈 ?(?:와|오|올)|미세 ?먼지|황사|우산|기온|덥|춥|\b(?:weather|rain|raining|snow|"
r"forecast|temperature|umbrella|sunny|cloudy|news|headlines?)\b", t, re.I):
return "weather or news" # "오늘 미세먼지 어때?", "투데이 뉴스 뭐야?": the lookups
if re.search(r"충전\S*\s*(?:\S+\s+)?(?:얼마나|몇\s*시간|몇\s*분)\s*(?:\S+\s+)?걸|완충|충전\s*시간|"
r"\b(?:how long|how many hours)\b.*\b(?:to charge|charging|recharge|full charge take)\b|\bcharg\w* time\b", t, re.I):
r"\bhow long\b.*\b(?:to (?:re)?charge|(?:charging|recharging|a (?:full )?charge) takes?)\b|\bcharg\w* time\b", t, re.I):
return "charging time" # "충전하는 데 얼마나 걸려?": not known (the LLM says so), not the battery life
if REQUEST.search(t) or re.search(r"(?:시지요|시죠|십시오|하시오|가시게|오시게|하시게|라 마|원위치)\W*$", t):
return "a command" # the rules' (or the LLM's), never a fact
if re.search(r"살짜리|살 짜리|살용|살 이상", t):
return "for an age" # "이거 몇 살짜리 장난감이야?": not Lumi's age
if OTHER_DAY.search(t):
return "another day" # "내일 며칠이야?", "크리스마스가 무슨 요일이야?": the LLM
if OTHER_ROBOT.search(t):
@@ -444,9 +456,17 @@ ASKS = re.compile(r"[??]\W*$|\b(?:what|who|whom|whose|how|where|when|why|which
r"(?:까|니|냐|나요|가요|래|죠)\W*$", re.I) # words that ask something
ORDER = re.compile(r"^\W*(?:please\s+)?(?:go|come|turn|take|bring|pick|put|give|follow|wave|look|move|lift|raise|lower|stop|sing|"
r"dance|fold|reach|grab|show|open|close|hold|drive|walk|fly|speak|say|tell|let'?s|wait|stand|sit)\b|"
r"(?:줘|줘요|주세요|주십시오|주시오|주라|해라|하자|가자|와라|봐라|내밀어|흔들어|돌아|돌려|들어|내려|접어|펴|가|와|멈춰|그만)\s*[!.~…]*$", re.I)
r"(?<!알려 )(?<!말해 )(?<!알려)(?<!말해)(?<!가르쳐 )(?:줘|줘요|주세요|주십시오|주시오|주라|해라|하자|가자|와라|봐라|내밀어|흔들어|돌아|돌려|들어|내려|접어|펴|가|와|멈춰|그만|"
r"시지요|시죠|십시오|하시오|가시게|오시게|하시게|라 마|넣어|열어|닫아|놔|잡아|집어|가져와|이동해 좀|틀어|원위치)\s*[!.~…]*$", re.I)
# a command (said before a question, or as one sentence of several): never left out for the question
CORRECTION = re.compile(r"(?:^|[\s,.])(?:아 아니|아니 아니|아니 그러니까|아니다|아니 잠깐|no wait|wait no|i mean|scratch that|sorry i mean)"
REQUEST = re.compile(r"\b(?:would|could|can|will) you (?:please |kindly )?(?:go|come|turn|take|bring|pick|put|give|wave|look|move|lift|"
r"raise|lower|fold|open|close|plug|tilt|spin|rotate)\b(?!.*\b(?:stairs?|steps?|ramps?|slopes?|doors?)\b)"
r".*\b(?:\d+|degrees?|left|right|up|down|in|a (?:little|bit)|higher|lower|please)\b|"
r"(?:돌려|올려|내려|열어|닫아|펴|접어|틀어|넣어|숙여|들어)\s*(?:주세요|줘|주시겠어요|줄래|주실래요|주시면|주십시오|주시겠습니까)|"
r"(?:손|팔)\s*(?:좀|쫌)?\s*(?:주실래요|줄래|주세요|내밀어|원위치)", re.I)
# a request to move put as a question: "could you turn your head ten degrees down?", "허리 왼쪽으로 틀어 주시면"
CORRECTION = re.compile(r"(?:^|[\s,.?])(?:아 아니|아니 아니|아니 그러니까|아니다|아니 잠깐|아 됐고|됐고|아 됐다|아 됐어|no wait|wait no|"
r"i mean|scratch that|sorry i mean|never ?mind|forget (?:it|that))"
r"(?=[\s,.])[\s,.]*", re.I)
ASIDE = re.compile(r"(?<=[가-힣])(?:니까|으니까|는데|인데|라서|이라서|라고 생각하고|동안)\s+|:\s+")
# the end of a remark said before the question, without a comma
@@ -465,10 +485,12 @@ def kind_of(text, history=(), _whole=True):
fix = list(CORRECTION.finditer(text))
if fix and len(text[fix[-1].end():].split()) >= 2:
text = text[fix[-1].end():] # "배터리, 아 아니, 지금 뭐 해?": what is said after the correction
if not ASKS.search(text):
return None # "몇 살이야? 아 됐고, 검정 컵 잡으시지요", "70cm, I mean 150 cm"
parts = [p for p in SENTENCES.split(text) if p.strip() and not REMARK.fullmatch(p.strip(" ,.!??~"))
and OPENER.sub("", p).strip(" ,.!??~")]
if len(parts) > 1:
if any(ORDER.search(p) for p in parts):
if any(ORDER.search(p) or REQUEST.search(p) or re.search(r"봐\W*$", p) for p in parts):
return None # "fold it! your arm!", "손! 손 내밀어!": a command, the rules'
asked = [p for p in parts if ASKS.search(p)]
kinds = {kind_of(p, history) for p in asked}
@@ -487,7 +509,7 @@ def kind_of(text, history=(), _whole=True):
m = list(ASIDE.finditer(rest))
head, comma, tail = (rest[:m[-1].start()], ",", rest[m[-1].end():]) if m else (rest, "", "")
if comma and len(tail.split()) >= (2 if re.search(r"[가-힣]", tail) else 3) and ASKS.search(tail) and \
not ASKS.search(head) and not ORDER.search(head): # "Your voice, what program?": the head is the topic
not ASKS.search(head) and not ORDER.search(head) and not REQUEST.search(head): # "Your voice, what program?": the head is the topic
last = kind_of(tail, history, False)
if got and last and last != got:
return None # "저기 평가 항목, 루미, 오늘 무슨 요일이야?" read whole as another kind
+13 -4
View File
@@ -40,6 +40,7 @@ _FILL = (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|could u|can u|would u|will u|"
r"could ya|can ya|would ya|will ya|"
r"pls|plz|yo|would it be possible to|is it possible to|could i ask you to|would you mind|lumi야|루미야|루미|음|응|어|야 로봇|로봇아|로봇야|"
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|"
@@ -58,6 +59,8 @@ def _norm(text, markers=()):
"0.5 m", "오십 센치" -> "0.5 m", "table front" -> "table_front" on a map with it), titles without their dot."""
t = re.sub(r"\b(mr|mrs|ms|dr|prof)\. ", r"\1 ", wording.durations(brain.unfill(brain.ko_slips(wording.norm(text, markers)))) + " ")
t = re.sub(r"\b(?:take|pick up|pick|grab)\s?(?:해서|하고)", "집어서", t) # "컵 take해서": mixed
t = re.sub(r"(?:(?<=들고)|(?<=집고)|(?<=잡고)|(?<=가서)|(?<=와서)|(?<=챙겨서)|(?<=가지고)|(?<=받아서)|(?<=집어서)|(?<=갔다가))"
r"(?=[가-힣a-z0-9])", " ", t) # "컵들고exit가서기다려" (typed or heard run together): its parts
t = re.sub(r"(?<=[가-힣])고\s*나서(?=[\s,]|$)", "고", t) # "가고 나서" = "가고"
t = re.sub(r"(?<![가-힣])(집었|잡았)다가(?=[\s,]|$)", lambda m: m.group(1)[0] + "고", t) # "컵 집었다가" = "컵 집고"
for said, same in _SAME: # "get yourself to" = "go to"
@@ -77,6 +80,7 @@ _SAME = [ # wordings read as the plain one (the blind mission sets, 2026-10-22
(r"\b((?:take|bring|carry) (?:it|that|this|the \w+|a \w+)) (?:with you|along)\b", r"\1"), # "take the cup with you to p5"
(r"^(?:go|head|drive)(?: over)? to (\S+) with (the|a|this|that) ((?:\w+ )?\w+)\s*$", r"take \2 \3 to \1"), # "go to
# exit with the cup": the cup taken there
(r"^(?:wait|stay)(?: for me)? (?:at|by) (\S+) with (the|a|this|that) ((?:\w+ )?\w+)\s*$", r"take \2 \3 to \1 and wait there"),
(r"\bcome back to where (?:i am|you are|we are)\b", "come back"),
(r"\buntil (?:someone|somebody|they|i|we) (?:says?|tells? you)(?: to)? (?:go on|continue|move on)\b"
r"|\buntil you(?:'re| are) told to (?:go on|continue|move on)\b", "until i tell you to go on"),
@@ -739,7 +743,7 @@ def _clause_steps(c, markers, after=None):
if m and (got := _clause_steps(m.group(1), markers, after)) and got[-1]["do"] == "receive":
return got + [{"do": "go", "to": "here"}] # "사라한테 컵 받아 와": taken from her, then brought back here
c = re.sub(r"^go (?:and )?(?=(?:grab|get) me\b)", "", c) # "go grab me a cup"
m = re.fullmatch(rf"(?:(?:pass|hand|give|get|grab|bring|fetch) me|(?:can|could|may) i (?:have|get|grab|take)|lemme have|let me have|"
m = re.fullmatch(rf"(?:(?:pass|hand|give|get|grab|bring|fetch) me|gimme|(?:can|could|may) i (?:have|get|grab|take)|lemme have|let me have|"
rf"(?:would you )?mind (?:passing|handing|giving) me) (?:the |that |this |a |an |one )?"
rf"(?:({COL}) )?({OBJ})s?(?: (?:on|from|off) the table| over(?: here)?| there| please)?"
rf"|(?:(?:나|저)(?:한테|에게)?\s*)?(?:({COL})\s*)?({OBJ})\s*(?:을|를)?\s*(?:하나만?\s*)?(?:(?:나|저)(?:한테|에게)\s*)?"
@@ -845,9 +849,14 @@ def _place_at(c, markers, after=None):
thing, where = m["a"] or m["b"], m["where"]
verb = "put" if re.fullmatch(_PUT_KO, m["verb"]) else "deliver"
on = None
sup = re.fullmatch(rf"(.+?)\s+((?:(?:{COL})\s*)?(?:{_SUP_KO}))(?:\s*위)?|((?:(?:{COL}) )?(?:{_SUP})s?) (?:at|in|by|near) (?:the )?(.+)", where)
if sup and verb == "put": # "exit 테이블에 놔", "put it on the table at p3": there, on that
where, on = sup.group(1) or sup.group(4), _support("on the " + sup.group(3) if sup.group(3) else sup.group(2))
sup = re.fullmatch(rf"(.+?)\s+((?:(?:왼쪽|오른쪽)\s*)?(?:(?:{COL})\s*)?(?:{_SUP_KO}))(?:\s*위)?|"
rf"((?:(?:left|right) )?(?:(?:{COL}) )?(?:{_SUP})s?) (?:at|in|by|near) (?:the )?(.+)", where)
if sup and verb == "put": # "exit 테이블에 놔", "put it on the left table at p3": there,
side = re.match(r"(왼쪽|오른쪽|left|right)\s*", sup.group(3) or sup.group(2)) # on that (on its side)
what = (sup.group(3) or sup.group(2))[side.end() if side else 0:]
where, on = sup.group(1) or sup.group(4), _support("on the " + what if sup.group(3) else what)
if on and side:
on["side"] = {"왼쪽": "left", "오른쪽": "right"}.get(side.group(1), side.group(1))
to = _places(where, markers)
if not to or len(to) != 1 or to == ["here"]:
return None