diff --git a/api/server.py b/api/server.py index bebc56b..3574b88 100644 --- a/api/server.py +++ b/api/server.py @@ -1247,7 +1247,7 @@ def _held_parse(body, markers, said=None): from assistant import brain, steps from tasks import fetch held, text = fetch.held_name(), brain.give_clause(body.text) # not where the person it is for goes - m, t = brain._mentions(text, markers), brain._norm(text) + m, t = brain._mentions(text, markers), brain._norm(text, markers) # "booth 3" is the map's booth_3 if isinstance(m.get("source"), dict) and not brain.held_command(text): # "take the bottle from p2": a new fetch return {"action": None, "task": None, "sentence": "–", "problems": [ f"I'm holding {held}: give it to you, put it on a table, or say where to bring it first."]} diff --git a/assistant/abilities.py b/assistant/abilities.py index e7b5a76..c56dd5b 100644 --- a/assistant/abilities.py +++ b/assistant/abilities.py @@ -45,7 +45,8 @@ LONG = {"en": "I talk with you in English and Korean, and when I don't know some "따라가요. 그리고 손을 흔들거나 판타스틱 베이비, 러브 어택 같은 제 노래도 불러 드려요."} -NOT_LUMI = re.compile(r"\b(?:cutshion|company|jaka)\b|쿳션|회사|자카|안전", re.I) # "쿳션은 무슨 일 해?", "안전 기능 뭐 있어?" +NOT_LUMI = re.compile(r"\b(?:cutshion|company|jaka|languages?)\b|쿳션|회사|자카|안전|랭귀지|언어|외국어|영어|한국어|일본어|중국어", re.I) + # "쿳션은 무슨 일 해?", "안전 기능 뭐 있어?", "랭귀지 뭐 할 수 있어?" (the languages: quick_answers) def asked(text): diff --git a/assistant/action_examples.py b/assistant/action_examples.py index c2a2489..5f22a83 100644 --- a/assistant/action_examples.py +++ b/assistant/action_examples.py @@ -170,6 +170,7 @@ _BANK = { ("Could you carry my 5 kg backpack?", "none", "No, that's too heavy for me: about 1 kg in my hand."), ("Wave at me while you hold that cup.", "none", "Not while I'm holding the cup: it could fall. Shall I put it down first?"), ("How far away can you hear me?", "none", "From about 3 to 5 metres."), + ("Three hours on one charge, I guess?", "none", "No, about 10 hours on a charge."), ("Rise up so we're face to face.", "lift up", "Sure, going up."), ("Spread those fingers of yours.", "arm open", "Opening my hand."), ], @@ -180,6 +181,7 @@ _BANK = { ("내가 초속 3미터로 뛰면 따라올 수 있어?", "none", "아니요, 제 최고 속도는 초속 1.2미터예요."), ("컵 든 채로 손 흔들어 줘~", "none", "컵을 들고 있어서 지금은 손을 흔들 수 없어요. 먼저 내려놓을까요?"), ("몇 미터 떨어져서 말해도 들리시나요?", "none", "3미터에서 5미터 정도까지 잘 들려요."), + ("배터리 을매나 가노? 세 시간쯤 가나?", "none", "아니요, 한 번 충전하면 10시간쯤 가요."), ("날 좀 똑바로 쳐다봐 주이소.", "look me", "네, 보고 있어요."), ("집게 좀 벌려 보십시오.", "arm open", "네, 손을 벌리겠습니다."), ], diff --git a/assistant/bank_words/arm_more.py b/assistant/bank_words/arm_more.py index d3fb473..ee64b79 100644 --- a/assistant/bank_words/arm_more.py +++ b/assistant/bank_words/arm_more.py @@ -223,6 +223,8 @@ GIVE = [ "i'll take it", "i'll take it from you", "let me take it", "let me take that", "hand it on over", "pass that to me", "give that to me now", "give it to me please", "give me the thing", "give it, please", "hand it", "you give me please", "give me now", "now give me", + "hand me that", "hand me that, thank you", "hand me that, thank you very much", "pass me that, thanks", + "hand that over, thank you", "hand me that one please", "그거 나 줘", "이리 내", "이리 내놔", "내놔", "그거 내놔", "그거 이리 넘겨", "건네 줘", "넘겨 줘", "저한테 넘겨 주세요", "저 주십시오", "나한테 줘", "제게 주시겠어요?", "그거 받을게", "제가 받겠습니다", "주라", "줘 봐라", "그거 주소", "이리 주이소", "그거 주쇼", "이리 도", "그거 나 도", "줘유", "기브 미", "give 해 줘", "그거 이리 주시게", @@ -632,5 +634,158 @@ PICK += [" 픽업 해", " 픽업 해 줘", " grab 해 줄 수 있 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"] + +# ---------- fresh negatives (new frames and slang) and arm things Lumi can't do: all "no" ---------- +NEG2_EN = {"wave": ("wave", "waved", "waving"), "shake": ("shake my hand", "shook my hand", "shaking hands"), + "reach": ("reach out", "reached out", "reaching out"), "fold": ("put your arm down", "put your arm down", "putting your arm down"), + "open": ("open the gripper", "opened the gripper", "opening the gripper"), + "close": ("make a fist", "made a fist", "making a fist"), "pick": ("grab the bottle", "grabbed the bottle", "grabbing the bottle"), + "fetch": ("fetch the cup", "fetched the cup", "fetching the cup")} +_neg2 = [] +for base, past, ing in NEG2_EN.values(): + _neg2 += [f"nah, don't {base}", f"bro don't {base}", f"plz don't {base}", f"u don't gotta {base}", f"no {ing} please", + f"quit {ing}", f"enough {ing}", f"you {past} like five minutes ago", f"you already {past}", + f"remember when you {past}?", f"lol you {past} at me", f"bet you can't {base}", f"i dare you not to {base}", + f"would you {base} if i asked?", f"are you gonna {base}?", f"is it hard to {base}?", f"how do you {base}?", + f"what happens if you {base}?", f"do robots like to {base}?", f"my little brother can {base} too", + f"my robot at home can {base}", f"the other robot {past} at me", f"once the show starts, {base}", + f"only {base} when the music stops", f"after lunch you can {base}", f"{base} in an hour", + f"jiwoo, {base}", f"Sarah, {base}", f"kids, {base}", f"guys, {base}", f"i'm gonna {base} now", f"let me {base} first", + f"{ing} looks easy", f"{ing} must be boring for you", f"love the way you {base}", f"you {base} so smoothly"] +NEG2_KO = {"wave": ("손 흔들", "손 흔들었", "손 흔드는", "손 흔들", "손 흔들어"), "shake": ("악수하", "악수했", "악수하는", "악수할", "악수해"), + "reach": ("팔 뻗", "팔 뻗었", "팔 뻗는", "팔 뻗을", "팔 뻗어"), "fold": ("팔 거두", "팔 거뒀", "팔 거두는", "팔 거둘", "팔 거둬"), + "open": ("그리퍼 열", "그리퍼 열었", "그리퍼 여는", "그리퍼 열", "그리퍼 열어"), + "close": ("주먹 쥐", "주먹 쥐었", "주먹 쥐는", "주먹 쥘", "주먹 쥐어"), "pick": ("병 집", "병 집었", "병 집는", "병 집을", "병 집어"), + "fetch": ("컵 갖다주", "컵 갖다줬", "컵 갖다주는", "컵 갖다줄", "컵 갖다줘")} + +for stem, past, adn, fut, imp in NEG2_KO.values(): + _neg2 += [f"{stem}지 마라", f"{stem}지 마쇼", f"{stem}지 말게", f"{stem}지 마유", f"{stem}지 마 ㅋㅋ", f"{stem}지 않아도 됩니다", + f"{stem}기 싫어", f"{stem}기 전에 물어봐", f"{past}던데?", f"{past}다며?", f"방금 {past}지?", + f"{past}을 때 귀여웠어", f"{adn} 거 또 보고 싶다", f"{adn} 거 어떻게 배웠어?", f"{adn} 게 힘들어?", f"{adn} 로봇 처음 봐", + f"{fut} 수 있으려나", f"{fut} 수 있다고 들었어", f"{fut} 거야?", f"{fut} 때 말해 줘", f"공연 끝나면 {stem}자", + f"점심 먹고 {stem}자", f"한 시간 뒤에 {stem}기", f"지우야 {imp} 봐", f"얘들아 {imp} 봐", f"우리 동생도 {fut} 줄 알아", + f"나도 {fut} 수 있어", f"{adn} 거 별로야", f"{adn} 거 대박", f"{adn} 거 ㄹㅇ 신기"] +ARM_CANT = [ # arm things Lumi can't do: nothing must move (the LLM says why) + "arm wrestle with me", "let's arm wrestle", "팔씨름 한판 하자", "팔씨름 하실래요?", "swing your arm around fast", "팔 막 휘둘러 봐", + "팔 빙빙 돌려 봐", "spin your arm in circles", "make a finger heart", "손가락 하트 해 주세요", "do the flower pose", "꽃받침 해 줘", + "꽃받침 포즈 해 주세요", "make a v sign", "브이 해 줘", "브이 포즈 해 주세요", "give me a thumbs up", "엄지 척 해 주세요", "따봉 해 줘", + "clap for us", "박수 쳐 주세요", "박수 좀 쳐 봐", "count to five on your fingers", "손가락으로 다섯까지 세 봐", "scratch my back", + "등 좀 긁어 줘", "등 긁어 주세요", "tap my friend on the shoulder", "내 친구 어깨 좀 톡톡 쳐 줘", "take a selfie with your arm", + "팔로 셀카 찍어 줘", "hold my umbrella", "우산 좀 들어 줘", "우산 씌워 주세요", "hold my baby", "아기 좀 안아 줘", "애기 좀 잠깐 들고 있어", + "hold this hot pot", "뜨거운 주전자 좀 들어 줘", "stir my coffee", "커피 좀 저어 줘", "pour me some water", "물 좀 따라 줘", + "물 따라 주세요", "wipe the table", "테이블 좀 닦아 줘", "wash my cup", "컵 좀 씻어 주세요", "cut this ribbon", "이 리본 잘라 줘", + "tie my shoes", "신발 끈 묶어 줘", "turn the page", "책장 넘겨 줘", "type on my laptop", "노트북에 타자 쳐 줘", "write my name", + "내 이름 써 줘", "open this bottle", "병뚜껑 따 줘", "이 병 좀 열어 주세요", "open the drawer", "서랍 열어 줘", "open my umbrella", + "우산 펴 줘", "knock on the door", "문 두드려 줘", "press the button", "그 버튼 눌러 줘", "엘리베이터 버튼 눌러 주세요", + "punch the wall", "벽 쳐 봐", "주먹으로 벽 쳐", "toss me the ball", "공 던져 줘", "throw it to me", "던져 줘", "kick the ball", + "공 차 줘", "feed me", "밥 먹여 줘", "carry my suitcase", "캐리어 좀 끌어 줘", "carry this heavy box", "이 무거운 상자 들어 줘", + "hand out these flyers", "전단지 좀 나눠 줘", "give me a tissue", "휴지 한 장 줘", "hold the door", "문 좀 잡아 줘", + "raise the cup over your head", "컵 머리 위로 들어", "shake the cup", "컵 흔들어 봐", "clink cups with me", "건배하자 컵 부딪혀", + "wave with the cup in your hand", "컵 든 채로 손 흔들어", "pick it up off the floor", "바닥에 있는 거 주워 줘", "바닥에 떨어진 컵 주워", +] +NO += [t for t in _neg2 if not t.startswith(("jiwoo,", "Sarah,", "kids,", "guys,", "지우야", "얘들아"))] + ARM_CANT + + +# ---------- very formal Korean frames, cute endings, English frames (r12 gaps); "the moment …", "can your model …" ---------- +KO_END9 = [" 주십사 부탁드립니다", " 주실 것을 요청드립니다", " 주시기를 요청합니다", " 주지 않겠는가", " 주실 수 있으신지요", + " 주실 수 있으신지요? 부탁드려요", " 줘용 응응", " 줘 응응", " 줄래 ㅎ? 응응?", " 주시기를 부탁드립니다", " 줘라 응"] +KO_DO9 = ["{}도록 하게", "{}도록 하세요", "{}도록 하십시오"] +KO_SI9 = ["{}시기 바랍니다", "{}시겠습니까", "{}시지 않겠습니까"] +SI_STEM = {"손 흔들": "손 흔드", "손 내밀": "손 내미", "팔 뻗": "팔 뻗으", "팔 접": "팔 접으", " 집": " 집으"} # + 시 +EN_FR9 = ["your mission, should you accept it: {}", "care to {}", "any time now, {}", "{} for little old me", + "{}, would you be a star", "{}, much obliged", "on the double, {}", "{}, good good", "{} now is ok", + "make for me {}", "lumi dear, {}", "lumi my friend, {}"] +CORES9 = { + "WAVE": (["shake hands with me", "wave goodbye", "wave at us"], ["손 흔들어", "악수해", "잘 가라고 손 흔들어"], ["손 흔들", "악수하"]), + "ARM_REACH": (["hold out your hand", "give me your hand"], ["손 내밀어", "팔 뻗어", "손 줘"], ["손 내밀", "팔 뻗"]), + "ARM_FOLD": (["put your arm back", "fold your arm"], ["팔 접어", "팔 원래대로 돌려놔", "암 원래대로 돌려놔"], ["팔 접", "팔 거두"]), + "ARM_OPEN": (["open your hand"], ["손 펴", "손 벌려"], ["손 펴"]), + "ARM_CLOSE": (["close your hand", "make a fist"], ["손 오므려", "주먹 쥐어"], ["주먹 쥐"]), + "PICK": (["pick up the ", "get hold of the "], [" 집어", " 집어 올려", " 들어"], [" 집"]), + "FETCH": (["bring me the "], [" 가져와", " 갖다"], [" 가져오"]), +} +for k, (en, ko, stems) in CORES9.items(): + _more = [f.format(c) for c in en for f in EN_FR9] + [c + e for c in ko for e in KO_END9] + \ + [f.format(s) for s in stems for f in KO_DO9] + [f.format(SI_STEM.get(s, s)) for s in stems for f in KO_SI9] + {"WAVE": WAVE, "ARM_REACH": ARM_REACH, "ARM_FOLD": ARM_FOLD, "ARM_OPEN": ARM_OPEN, "ARM_CLOSE": ARM_CLOSE, "PICK": PICK, + "FETCH": FETCH}[k].extend(_more) +NO += [ + "the moment the bell rings, bring me the cup", "the moment the music starts, wave", "the second i clap, shake my hand", + "the minute she arrives, hold out your hand", "the instant i say go, pick up the cup", "벨 울리는 순간 컵 가져와", + "음악 시작하는 순간 손 흔들어", "out of curiosity, can your model pick up a cup", "can your model wave", + "can this model shake hands", "does your model have a gripper", "just curious, can your arm reach the table", + "궁금해서 그런데 이 모델도 컵 집을 수 있어?", "이 모델은 악수도 돼?", "컵 흔들어 봐", "컵 들고 흔들어", "컵 든 채로 손 흔들어 봐", + "hold the cup and wave", "wave the cup around", "shake the cup for me", +] + + +# ---------- r13 gaps: arm things said another way, and arm things Lumi can't do said like an order ---------- +ARM_REACH += _ko(["손 가까이 가져와", "손 좀 가까이 가져와", "손 이쪽으로 가져와", "팔 가까이 가져와", "핸드 한 번만 내밀어", + "꼬마한테 핸드 내밀어", "우리 아들한테 손 뻗어"], ["", " 줘", " 주라", " 주시길 바랍니다", " 주시길 부탁드립니다", " 줘, 응?"]) + [ + "bring your hand closer", "bring your hand closer to me", "move your hand closer", "your hand a bit closer please", + "hand closer", "reach your hand closer to me"] +ARM_FOLD += _ko(["팔 좀 쉬게 해", "팔 쉬게 해", "암 다시 접어", "손 거둬라 카이", "팔 접어라 카이", "팔 좀 쉬어"], + ["", " 줘", " 주세요", " 주실 수 있으신가요?", " 주시게"]) + ["let your arm rest", "give your arm a rest", "rest that arm"] +ARM_OPEN += ["spread your claw", "spread your claw all the way", "open your claw all the way", "spread the claw wide", + "claw open", "집게 활짝 펴", "집게 쫙 벌려"] +WAVE += ["give us a big wave from up high", "big wave from up high", "wave high up", "wave up high", "손 높이 들고 흔들어", + "손 위로 높이 흔들어 줘"] +PICK += _ko(["앞에 있는 잔 들어", "그 잔 들어", "잔 집어", "잔 하나 들어"], ["", " 줄래요?", "라", " 주세요"]) +NO += [ + "팔 막 휘둘러", "팔 세게 휘둘러 봐", "팔 미친 듯이 흔들어", "flail your arm", "swing your arm wildly", + "wave your arm like crazy", "pick the bottle up off the floor", "grab the cup down there on the ground", "pick it up from the ground", + "바닥에 있는 병 집어", "땅에 떨어진 컵 주워 줘", "바닥에서 컵 집어 줘", "손가락 세 개 펴", "손가락 두 개만 펴 봐", + "손가락 하나 펴", "show me three fingers", "hold up two fingers", "양손에 컵 하나씩 들 수 있어?", "두 손으로 컵 들 수 있으세요?", + "can you hold a cup in each hand?", "이 컵 2층으로 가져가 줘", "이 컵 위층으로 갖다 줘", "take this cup upstairs", + "carry this cup to the second floor", "꾸벅 인사 해", "꾸벅 인사 해 주라", "고개 숙여 인사해", "bow to the guests", + "hand open이야", "hand open 상태야", "손 open이야", "그리퍼 open이야", "hand close야", "손 오픈 상태야", "your hand is open now", + "경례 해", "거수경례 해 주게나", "salute like a soldier", "손 들어 경례", "put your hand up like a student", "손 들어 질문하는 것처럼", +] + + +# ---------- third negative sweep: quotes, hypotheticals, wishes, permission, how-to, sarcasm, 못 / 안, -거든, tags ---------- +NEG3_EN = [("wave", "waving"), ("shake hands", "shaking hands"), ("hold out your hand", "holding out your hand"), + ("fold your arm", "folding your arm"), ("open your hand", "opening your hand"), ("close your hand", "closing your hand"), + ("pick up the cup", "picking up the cup"), ("bring me the cup", "bringing me the cup")] +_neg3 = [] +for b, ing in NEG3_EN: + _neg3 += [f"he said '{b}'", f"she told you to {b}, didn't she", f"the sign says {b}", f"the manual says {b}", + f"what if you {b}?", f"imagine if you could {b}", f"pretend to {b}", f"i wish you would {b}", f"i hope you {b} someday", + f"how do i make you {b}?", f"teach me how to make you {b}", + f"oh great, now you {b}", f"you can't even {b}", + f"don't you dare {b}", f"next time {b}", f"{ing} again? no", + f"no more {ing} today", f"try not {ing}", f"stop trying to {b}"] +NEG3_KO = [("손 흔들", "손 흔들어", "손 흔드는"), ("악수하", "악수해", "악수하는"), ("손 내밀", "손 내밀어", "손 내미는"), + ("팔 접", "팔 접어", "팔 접는"), ("손 펴", "손 펴", "손 펴는"), ("주먹 쥐", "주먹 쥐어", "주먹 쥐는"), + ("컵 집", "컵 집어", "컵 집는"), ("컵 가져오", "컵 가져와", "컵 가져오는")] +for st, imp, adn in NEG3_KO: + _neg3 += [f"엄마가 '{imp}' 하래", f"선생님이 {imp} 보래", f"{imp} 보라고 했던가?", f"만약에 {imp} 주면 어떨까", f"{imp} 주면 좋을 텐데", + f"{imp} 주는 날이 오겠지", f"{st}는 법 알려 줘", f"어떻게 하면 {imp} 줘?", f"{imp} 달라고 해도 돼?", f"제가 {imp} 달라고 해도 될까요?", + f"{st}지도 못하면서", f"{st}지 못하지?", f"너 {st}지 못하잖아", f"{st}기는 무슨", f"{imp} 주긴 뭘 {imp} 줘", + f"{st}거든 말해", f"손님 오시거든 {imp}", f"내가 신호 주면 {imp}", f"끝날 때 {imp}", f"{imp} 줄 거지?", f"{imp} 주는 거 맞지?", + f"{st}지 마 제발", f"그만 {st}어", f"이제 {st}지 말자", f"{adn} 연습 중이야?"] +NO += _neg3 + + +# ---------- arm-set misses after round 2: "next thing: …", "test one: …", "-해 주면 땡큐", dialect, slips ---------- +WAVE += [ + "악수해 보이소", "악수해 주소", "우리 악수해 주소", "반갑게 악수 해 주쇼", "sake hands", "sake hands now", "shak hands", + "wave, it'll be epic", "yo, wave, it'll be fun", "next thing: wave", "test one: wave", "wave 해 주면 땡큐"] +ARM_REACH += [ + "stick your arm out to me", "stick your arm out to me real quick", "your han, please", "your hand, please robot", + "hand out 해 주면 땡큐", "손 out 해", "지금 손 out 해", "손 reach 부탁드려요", "next thing: hold out your hand", + "test one: reach out"] +ARM_FOLD += [ + "손 이제 내러 주실래요", "손 이제 내려 주소", "팔 원래대로 돌려어 볼래요", "retract 부탁해요", "retract 해 줄래", "팔 제자리로 빨리 가져와라", "팔 제자리로 가져와", + "팔 bakc 해 봐", "팔 백 해 봐", "next thing: fold your arm"] +ARM_OPEN += [ + "you hand open", "you hand open please", "open up! do it!", "open up, do it", "next thing: open your hand", + "next thing: open hand", "test one: spread your fingers", "spread ur fingers", "손 open 해 봐", + "release please 해 줘", "송가락 벌려", "송가락 벌려 주면 좋겠어", "let it go, open your hand"] +ARM_CLOSE += [ + "grip", "grip please", "grip 가능?", "grip 가자", "그리퍼 close 가자", "gripper close 해 주면 땡큐", "close hand, will ya", + "close hand please", "손 지금 닫아 줘", "음주먹쥐어라", "주먹쥐어라", "next thing: make a fist", "test one: close your hand", + "teacher said I can ask you: close the gripper"] + 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} diff --git a/assistant/bank_words/korean_levels.py b/assistant/bank_words/korean_levels.py index cb9def7..fd0e839 100644 --- a/assistant/bank_words/korean_levels.py +++ b/assistant/bank_words/korean_levels.py @@ -33,7 +33,7 @@ VERBS = { # 하게체, dialect (경상 / 전라 / 충청), written slips and suggestions ENDS = [ "{a}", "{a} 줘", "{a} 봐", "{a}라", "{a} 줄래?", "{a} 줄 수 있어?", "{a} 주라", "{a} 줘라", "{a} 봐 봐", "{a}줘", "{a}봐", - "{a} 줄래 응?", "{a} 주지 않을래?", "{a} 줄 수 있겠어?", "{a} 주는 거 어때?", + "{a} 줄래 응?", "{a} 주지 않을래?", "{a} 줄 수 있겠어?", "{a}요", "{a} 줘요", "{a} 주세요", "{a} 봐요", "{a} 줄래요?", "{a} 주실래요?", "{a} 주시겠어요?", "{a} 주실 수 있어요?", "{a} 주셔요", "{a} 주셔", "{a} 주시지 않겠어요?", "{a} 주셨으면 해요", "{a} 주시면 감사하겠습니다", "{s}세요", "{s}시겠어요?", "{s}실래요?", "{s}시죠", @@ -127,3 +127,35 @@ if __name__ == "__main__": for k, v in INTENT.items(): print(f"{k:10} {len(v)}") print("total", sum(map(len, INTENT.values()))) + + +# ---------- Konglish: English words with Korean verbs and endings ("me 봐", "턴 레프트 해 주세요", "p3로 무브해") ---------- +HAE = ["{a} 해", "{a} 해 줘", "{a}해 줘", "{a} 해 주세요", "{a} 해 주십시오", "{a} 해 줄래?", "{a} 해 주실래요?", "{a} 해 봐", + "{a} 해라", "{a} 해 주이소", "{a} 해 줘잉", "{a} 해 주게", "{a} 해 줘유", "{a} 좀 해 줘", "{a} 해 주세여", "{a} 하세요", + "{a} 하십시오", "{a} 해져", "{a} 해 주라", "{a} 해 주시겠어요?"] + + +def _hae(cores): + return list(dict.fromkeys(e.format(a=c) for c in cores for e in HAE)) + + +KONGLISH = { + "look": _make(["me ", "여기 ", "here ", "left ", "right ", "up ", "down ", "front ", "레프트 ", "라이트 ", "업 ", "다운 ", + "프론트 ", "left 쪽 ", "right 쪽 ", "위 쪽 "], ["봐"]) + + _hae(["look 여기", "look me", "look at me", "look up", "look down", "look left", "look right", "head left", + "head right", "head up", "head down", "룩 업", "룩 다운", "룩 레프트", "룩 라이트", "룩 앳 미"]), + "turn": _hae(["턴 레프트", "턴 라이트", "레프트 턴", "라이트 턴", "left로 턴", "right로 턴", "왼쪽으로 턴", "오른쪽으로 턴", + "turn left", "turn right", "left turn", "right turn", "유턴", "u턴", "turn around"]), + "move": _hae(["forward로 무브", "back으로 무브", "앞으로 무브", "뒤로 무브", "go forward", "move back", "move left", + "move right", "레프트로 무브", "라이트로 무브"]) + + _make(["forward로 ", "left로 ", "right로 ", "앞쪽으로 "], ["가"], share=0.1), + "go_to": _hae(["로 무브", "로 move", "go to ", " 고고", "로 고", "로 go"]), + "come": _hae(["컴 히어", "come here", "come 여기", "여기로 come", "이리 컴", "컴온 히어", "come to me", "here로 컴"]), + "follow": _hae(["follow me", "팔로우 미", "follow", "팔로우", "나 follow", "저 팔로우", "follow 모드"]), + "lift": _hae(["바디 업", "바디 다운", "body up", "body down", "lift up", "lift down", "리프트 업", "리프트 다운", "키 업", + "키 다운", "height up", "height down", "몸 업", "몸 다운"]), + "wave": _hae(["wave", "웨이브", "핸드 웨이브", "hand wave", "손 웨이브", "바이 바이", "빠이빠이", "하이", "shake hands", + "악수", "핸드셰이크"]), +} +for _k, _t in KONGLISH.items(): + INTENT[_k] = INTENT.get(_k, []) + [t for t in _t if t not in INTENT.get(_k, [])] diff --git a/assistant/bank_words/levels.py b/assistant/bank_words/levels.py index 5d0ffe3..f6d3820 100644 --- a/assistant/bank_words/levels.py +++ b/assistant/bank_words/levels.py @@ -197,5 +197,6 @@ QUICK["speed"] += ["빨리 달릴 수 있어", "빨리 달릴 수 있어요", " "can you drive fast", "are you fast", "can you run fast"] QUICK.setdefault("obstacles", []).extend([ "팔이 사람 치면 어떡해요", "팔에 사람이 맞으면 어떻게 돼요", "팔이 부딪히면 어떻게 돼", "what if your arm hits someone", "will your arm hit me", - "is it safe to stand next to you", "are you safe around kids", "옆에 서 있어도 안전해", - "가까이 가도 안전합니까", "애들 옆에 둬도 괜찮아요"]) +]) +QUICK.setdefault("safety", []).extend(["is it safe to stand next to you", "are you safe around kids", "옆에 서 있어도 안전해", + "가까이 가도 안전합니까", "애들 옆에 둬도 괜찮아요"]) diff --git a/assistant/bank_words/questions.py b/assistant/bank_words/questions.py index 638def3..beed724 100644 --- a/assistant/bank_words/questions.py +++ b/assistant/bank_words/questions.py @@ -792,3 +792,6 @@ QUICK["teach"] = QUICK.get("teach", []) + ["can i teach you something new", "can QUICK["no"] += ["여기 어느 나라야", "여기 어느 나라예요", "이 나라 어디야", "what country is this", "which country are we in", "where are we", "what does cutshion mean", "쿳션이 무슨 뜻이야", "쿳션 뜻이 뭐예요", "cutshion 이름 뜻", "추석 며칠 남았어", "설날 며칠 남았어요", "how many days until new year", "how many days to chuseok", "생일까지 며칠 남았어"] +QUICK["languages"] += _ko(["랭귀지 뭐 ", "랭귀지 몇 개 ", "language 뭐 ", "언어 뭐 ", "무슨 언어 "], ["할 수 있어", "할 수 있어요", "할 줄 알아", "할 수 이써", + "할 수 있으세요", "할 수 있습니까", "할 줄 아노"]) + [ + "랭귀지뭐할수있어", "랭귀지 뭐 해", "랭귀지 뭐 돼요"] diff --git a/assistant/battery.py b/assistant/battery.py index 53eb577..f6ac663 100644 --- a/assistant/battery.py +++ b/assistant/battery.py @@ -15,11 +15,11 @@ ON_CHARGE = re.compile(r"\b(on|per|with) (a |one |the )?(full |single )?charge\b r"\bgo (back )?(to )?(re)?charg|한 ?번 충전(?:으로|하면)|완충(?:으로|하면|되면)|충전하면 ?(?:얼마나|몇)|" r"충전하러", re.I) # how long it lasts (10 hours), when it goes to charge: the LLM LASTS = re.compile(r"\b(last|life|lifetime|capacity|volt|amp|ah|kind|type|made|hours?)\b|얼마나 ?가|몇 ?시간|오래 ?가|" - r"지속|용량|종류|볼트|수명|뭐\s*들어|무슨\s*배터리|어떤\s*배터리|\bwhat (?:kind of |type of )?battery\b|사용 ?시간|쓸 ?수 ?있는 ?시간|런타임|\bruntime\b|\bhow long\b", re.I) # how long it lasts, what it is: the reference notes + r"지속|용량|종류|볼트|수명|뭐\s*들어|무슨\s*배터리|어떤\s*배터리|\bwhat (?:kind of |type of )?battery\b|사용 ?시간|쓸 ?수 ?있는 ?시간|런타임|\bruntime\b|\bhow long\b|타임|\btime\b", re.I) # how long it lasts, what it is: the reference notes LEVEL = re.compile( r"\bbattery\b.*\b(level|percent(age)?|left|status|charged|full|low|now|remaining|state|at|much|look)\b|" r"\b(level|percent(age)?|how much)\b.*\bbattery\b|^\W*(and |so |what about |how about )?(your |the )?battery\W*$|" - r"배터리.{0,8}(?:몇|남|상태|퍼센트|프로|충분|얼마|어때|괜찮|있어|많|부족|없어)|^\W*(?:그럼 |그리고 )?배터리[는은요]?\W*$", re.I) + r"배터리.{0,8}(?:몇|남|상태|퍼센트|프로|충분|얼마|얼만|어때|괜찮|있어|많|부족|없어)|^\W*(?:그럼 |그리고 )?배터리[는은요]?\W*$", re.I) CHARGING = re.compile( r"\bare you (still |now |currently )?(charging|on (the |your )?charger|plugged in)\b|" r"\bis (it|the battery|your battery) (still |now )?charging\b|^\W*(and |so |what about |how about )?charging\W*$|" diff --git a/assistant/brain.py b/assistant/brain.py index 405e41a..e28675f 100644 --- a/assistant/brain.py +++ b/assistant/brain.py @@ -144,6 +144,8 @@ Rules: - "Can you sing?", "can you wave?", "노래 불러 줄 수 있어?", "손 흔들어 줄래?" ask you to do it; "can you fly / swim / dance / grow taller?", "do you know how to wave?", "손 흔들 줄 알아?" ask whether you can: answer yes or no. A remark ("it's loud here", "I could take you home") is not an order. +- A yes / no question about what you can do or how much (a ramp, a step, a weight, a speed, a width) starts with the + answer word, "No," / "Yes," / "아니요," / "네,", then the fact (15° ramp: "No, at most 8 degrees."). - Asked to talk casually ("말 놓아도 돼?", "반말해"), say kindly that you'll keep speaking politely; stay polite. - "I see", "got it", "okay, I see", "makes sense", "아 그렇구나", "알겠어요", "그렇군요", "아하" mean they understood your answer, not goodbye: acknowledge in a few words or add one short related point; the talk goes on (never @@ -324,7 +326,7 @@ def _follow_examples(text, history): len(c.strip(" ?!.~")) <= (6 if HANGUL.search(c) else 10))): return "" # "where is p3?", "세종대왕이 누구예요?" are new questions from assistant import talk_examples - q, a = history[-1] if asked else topic_turn(history) + q, a = history[-1] if asked else topic_turn(history, text) a = " ".join(ln for ln in a.splitlines() if not re.match(r"\s*\**ACTION", ln)).strip() if not a: return "" @@ -650,6 +652,7 @@ LET_GO = r"^\W*(?:drop it|release(?: it)?)\W*$|^\W*(?:(?:그거|이거|그것| PUT_BACK = ( # the held thing back where it was picked: "put the banana back where you found it", "제자리에 갖다 놓으시게" r"\b(?:put|set|place|return|bring|take)\s+(?:it|that|this|them|the (?:\w+ ){0,2}?\w+)\s+(?:right )?back\b(?! to (?:me|us)\b)" r"|\b(?:put|set|place|leave)\s+(?:it\s+)?(?:back|again)\s+where\b|\bput back\b" + r"|\b(?:the )?(?:cup|it|bottle) go(?:es)? back (?:to )?(?:the )?same (?:place|spot)\b" r"|\b(?:put|set|place|return|leave|bring)\b.*\bwhere (?:it was|you (?:found|got|picked|took) it)\b" r"|\breturn (?:it|that|this|the (?:\w+ )?\w+) to (?:where|its place)" r"|^\W*(?:(?:please|now|okay|ok|lumi|robot)\W+)*back (?:to )?where (?:it was|you (?:found|got|picked|took) it)" @@ -684,7 +687,7 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said ("fetch",rf"\b(fetch|bring|deliver|carry)\b.*\b({_OBJ}|it|that|this)s?\b|\b(take|get|grab)\b.*\b({_OBJ})s?\b.*\b(from|to)\b" rf"|\b(go|drive) to\b.*\b(get|take|grab|pick up|fetch|bring)\b.*\b({_OBJ})s?\b" rf"|\b(pick up|pick|take|grab|get)\b.*\b({_OBJ})s?\b.*\b(go|drive) to\b|({_OBJ}).*(집어서|들고).*가서" - r"|가져와|가져다|갖다|가지고 ?와|갖고 ?(?:와|오)|챙겨 ?오|가져 ?오실|가저 ?(?:와|다)|에서.*\b(?:bring|fetch|brign|fech)\s*해|가져 ?오(?:세요|십시오|시오|너라|거라|게|라|실래요|시겠어요)|가지고 ?오(?:세요|십시오|시오|너라|거라|게|라|실래요|시겠어요)|챙겨 ?와|에서.*(옮겨|가져)" rf"|({_OBJ}).*(집고|들고|가지고).*(와|줘)|({_OBJ})\S*\s.*\S(?:으로|로|까지)\s*(?:좀\s*)?옮겨|({_OBJ})\s*(?:이랑|랑|하고|과|와) (?:같이|함께)\s+\S+?(?:으로|로|까지|에)?\s*(?:좀\s*)?가(?![가-힣])"), + r"|가져와|가져다|갖다|가지고 ?와|갖고 ?(?:와|오)|챙겨 ?오|가져 ?오실|가저 ?(?:와|다)|에서.*\b(?:bring|fetch|brign|fech)\s*해|가져 ?오(?:세요|십시오|시오|너라|거라|게|라|실래요|시겠어요)|가지고 ?오(?:세요|십시오|시오|너라|거라|게|라|실래요|시겠어요)|챙겨 ?와|에서.*(옮겨|가져)" rf"|({_OBJ}).*(집고|들고|가지고).*(와|줘)|({_OBJ})\S*\s.*\S(?:으로|로|까지)\s*(?:좀\s*)?옮겨|(?:으로|로|까지)\s+(?:\S+\s+)?({_OBJ})\S*\s+(?:좀\s*)?(?:가져가|가지고 ?가|갖고 ?가)|({_OBJ})\s*(?:이랑|랑|하고|과|와) (?:같이|함께)\s+\S+?(?:으로|로|까지|에)?\s*(?:좀\s*)?가(?![가-힣])"), ("come", r"\bcome (?:back )?(here|hear|to me|closer|over here|over|this way)\b|\bcome\b(?! back for (?:me|us)\b).*\bme\b|이리 ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오|올래)|" r"(?:여기로|이쪽으로) ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오)|가까이 ?(?:좀 ?)?(?:와|오세요)|" r"나한테 ?(?:돌아 ?)?와"), @@ -837,8 +840,9 @@ LATER = re.compile(r"^\s*(?:after|once|if|as soon as|before|unless|until)\b(?! ( r"please))\b)|\b(?:later|tomorrow|tonight|next time|in an hour)\b|[가-힣](? "go to end", "turn left, I mean right", "앞으로 1미터, 아니 2미터 가" -> "앞으로 2 m 가", "go to the stage, no, pick up the cup" -> "pick up the cup"). "" when the command was taken back ("go to the stage, never mind", "스테이지로 가, 아니 됐어"); None when a correction is there but can't be read for sure (Lumi asks again, nothing moves); the text itself otherwise.""" from assistant import steps text = wording.polite(text) # "wave, if you don't mind" -> "wave" on every path + if re.search(r"\b(?:under|in) no (?:circumstances|case|way)\b|\bno matter\b|\bno need\b|\bno one\b|\bnobody\b", text, re.I): + return text # "under no circumstances close the gripper": no correction if re.search(r"\b(?:say|tell|announce)\b|말해|(? which of several to pick PICK_PREFER_KO = (("작은", "small"), ("큰", "big"), ("왼쪽", "left"), ("오른쪽", "right"), ("가까", "near"), ("먼", "far"), - ("멀리", "far")) # "작은 컵", "왼쪽에 있는 컵", "가까이 있는 컵" + ("멀리", "far"), ("레프트", "left"), ("라이트", "right"), ("옆", "near")) # "작은 컵", "왼쪽에 있는 컵", "가까이 있는 컵" _PICK_EN = "|".join(sorted(PICK_PREFER, key=len, reverse=True)) _THING = rf"(?:(?:{_COL})\s+)?(?:(?:{_OBJ})s?|ones?)(?![a-z])" _SUP_WORDS = "|".join(k for k in SUPPORTS if k.isascii()) @@ -2117,10 +2171,14 @@ def pick_prefer(text): m = re.search(rf"(? + "춤은 못 춰요"): "어이, 진짜?" after it asks about the talk before it; "why not?" asks about the refusal.""" for q, a in reversed(history[-4:]): act = re.match(r"\s*\**ACTION\**\s*:\s*(\w+)", a) if act and (act.group(1) in MOTIONS or act.group(1) == "unclear") or ASKS_AGAIN.search(a) or \ + text is not None and not WHY_WORDS.search(text) and ORDER_WORDS.search(q) and "?" not in q and \ + REFUSED.search(a) or \ CONDITION.search(q) and a.startswith("ACTION: none") and \ re.search(r"\b(?:go|come|follow|turn|move|wave)\b|[가와](?:\s*줘|요|라|주세요)?\W*$|따라", q, re.I): continue @@ -3130,7 +3213,7 @@ class Brain: messages += [{"role": "user", "content": q}, {"role": "assistant", "content": a}] follow = _follow_examples(text, self.history) # with them, fewer plain examples (a shorter prompt) world = self.world_talk(text) - if follow and not LUMI_TOPIC.search("{} {}".format(core(topic_turn(self.history)[0]), topic_turn(self.history)[1])): + if follow and not LUMI_TOPIC.search("{} {}".format(*(lambda t: (core(t[0]), t[1]))(topic_turn(self.history, text)))): notes = "(none needed: the answer is in this talk)" # "when was it built?" after the Eiffel Tower: notes # on Lumi ("When was I built? 2 years") only misled elif follow and about_answer(text) and len(hits) > 1: # "really?" / "why?": the answer is in the talk, its @@ -3359,7 +3442,7 @@ class Brain: f"after a tower: its height), whichever fits; not other facts.)\n") if self.history: # past a back-channel ("헐 대박") to the answer before it, # also past a motion done without words ("are u sure" after a lift) - last = " ".join(ln for ln in topic_turn(self.history)[1].splitlines() if not re.match(r"\s*\**ACTION", ln)).strip() + last = " ".join(ln for ln in topic_turn(self.history, text)[1].splitlines() if not re.match(r"\s*\**ACTION", ln)).strip() c = core(text) # "루미 양반, 언제야?" asks "언제야?", not about Lumi if last and (THANKS_ONLY.match(c) or THANKS_ONLY.match(re.split(r"[,:]\s*", c)[-1])) and \ not self._last_said().rstrip().endswith("?"): # "궁금한 게, 고마워요~", "Then oh thank you." diff --git a/assistant/chain.py b/assistant/chain.py index 39a1641..3376816 100644 --- a/assistant/chain.py +++ b/assistant/chain.py @@ -100,6 +100,9 @@ def parts(text): return [p for p in out if p and not re.fullmatch(rf"(?:{_FILL.pattern}|\W)+", p, re.I)] +TAG_TALK = re.compile(r"\W*(?:(?:is|it'?s) (?:it )?(?:ok|ok+ay|possible|fine|good)(?: for you| with you)?|possible|you can do|can you do|" + r"(?:is )?(?:that|this) (?:ok|okay)|ok(?:ay)?|알긋나|알겠나|알았지|됐지|괜찮지|괜찮아요?|가능해요?|되나요?)\W*", + re.I) # "rotate right 45 degrees, is okay for you?": a check after the order, no part of its own CALL_ONLY = re.compile(r"\W*(?:(?:excuse me|hey|hi|hello|yo|okay|ok|lumi|robot|buddy|루미 ?씨|루미야?|로봇아?|야|어이|저기요?|" r"이보게)\W*)+", re.I) @@ -122,7 +125,8 @@ def plan(text, markers=(), cant=None): return None # "turn around and look": the head looks behind out = [] for p in ps: - if SELF_PROMISE.search(p) or out and _restated(p, out[-1][1]) or brain.GREET_ONLY.match(p) or CALL_ONLY.fullmatch(p): + if SELF_PROMISE.search(p) or out and _restated(p, out[-1][1]) or brain.GREET_ONLY.match(p) or CALL_ONLY.fullmatch(p) or \ + out and TAG_TALK.fullmatch(p): # "hello robot, …", "야 루미, …", "excuse me robot, …": the call, no part continue # "흰색 머그컵 잡아!, 아 잡아 줄 수 있어요?": the order once got, unread = steps.rules(p, markers) diff --git a/assistant/intent_bank.py b/assistant/intent_bank.py index b6a0ab6..6e0eae5 100644 --- a/assistant/intent_bank.py +++ b/assistant/intent_bank.py @@ -33,19 +33,19 @@ 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|cancel)\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|" +LATER = re.compile(r"\b(?:the (?:moment|second|minute|instant) (?:you|i|we|they|he|she)|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|분 ?(?:뒤|후|있다)|" r"[가-힣](? "멈춰 줘?", "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"\W*(?:(?:please|lumi|hey|okay|ok)\W+)*(?:can|could|would|will) (?:you|u) (?:please |just |kindly )?(?:go ahead and )?" + r"(?:stop|halt|freeze|hold it(?: right)? (?:there|here))" 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) +STOP_CALL = re.compile(r"^\W*(?:(?:okay|ok|오케이|hey|yo|야|어이|저기요?|자|lumi|loomi|rumi|robot|buddy|(?:루미)+|누미|류미|로봇)" + r"(?:\s*(?:님|씨|야|아|군))?\W+)+", re.I) # "루미 님, …", "오케이, 야 루미, …", "okay Lumi, …" + + def stop_order(text, markers): + """stop_order_said on the words, and again without the calls in front ("루미 님, 멈춰 주실 수 있겠습니까?").""" + bare = STOP_CALL.sub("", text or "") + if re.fullmatch(r"\W*(?:wait|hold on|hang on|one (?:sec|second|moment)|잠깐(?:만)?(?:요)?|기다려(?:요)?)\W*", bare, re.I): + return stop_order_said(text, markers) # "Lumi, wait": a mission halts for a talk (mission_talk), not ended + return stop_order_said(text, markers) or bool(bare and bare != text and stop_order_said(bare, markers)) + + +def stop_order_said(text, markers): """"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", "계속 해"), talk about stopping ("he said stop", "bus stop", "my laptop freezes", "내 다리도 자주 멈춰"); a short bare @@ -3392,6 +3414,8 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True): 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"(?<=\w)\W+(?:is (?:it )?ok+ay|is ok|is (?:it )?possible|possible|you can do)(?: for you)?\s*\?*\s*$", "", text, + flags=re.I) or text # "look 60 deg to right, is okkay for you?": the order, the check after it is no question text = re.sub(r"(?= PLACE_REFUSALS: # the rest are further / lower: each refused spot costs ~1 s of + log(f"{n} spots refused in a row: no more") # IK (two puts timed out in X1's sweep) + break way = skills.plan_place(x, y, top, yaw=skills._held.get("yaw", 0.0)) # above place, place, release up try: over = _line_rows(way[0][1], f"to ({x:.0f}, {y:.0f})") @@ -1881,16 +1888,18 @@ def _usable(usable, seen): def _place_near(top0, tried): """Put it down on a table in front, going closer to a table seen further ahead up to APPROACH_TRIES times (no whole search). True when it is down.""" + moved = True for i in range(APPROACH_TRIES + 1): got = _look_at(0.0, lambda: _place_view(top0)) if got is True: return True if got is None or i == APPROACH_TRIES or _charging(): return False - _too_low(got) + if not moved: # the base is as near as it gets: a low table stays out of reach + _too_low(got) # (said then, not after 24-31 moves; X1 r11: not earlier either) log(f"a table at {got['table']:.0f} mm further away ({got['camera']} camera), at ({got['x']:.0f}, " f"{got['y']:.0f}): going closer ({i + 1}/{APPROACH_TRIES})") - _go_to(got, PLACE_GOAL, tried, holding=True) + moved = _go_to(got, PLACE_GOAL, tried, holding=True) is not False return False @@ -2041,10 +2050,14 @@ def _put_down(say=None, on=None): if got is not None and arm_yaw() is not None and not _charging(): log(f"a table at {got['table']:.0f} mm further away ({got['camera']} camera), at ({got['x']:.0f}, " f"{got['y']:.0f}): going closer") - _too_low(got) # said at once: going closer can't help (X1: 24-31 moves) - _go_to(got, PLACE_GOAL, tried, holding=True) - if _place_near(top, tried): - return + try: + _go_to(got, PLACE_GOAL, tried, holding=True) + if _place_near(top, tried): + return + except FetchError as e: + _too_low(got, e) + raise + _too_low(got) _lift_to(LIFT_DRIVE_MM) raise FetchError("I can't find a free place on a table around me.", "주변에 내려놓을 빈 자리를 못 찾았어요.") diff --git a/tests/parity_check.py b/tests/parity_check.py index c9c8599..5bc78e6 100644 --- a/tests/parity_check.py +++ b/tests/parity_check.py @@ -156,7 +156,7 @@ def typed_got(r): return (a if a == "give" else "place " + str(((r.get("task") or {}).get("on") or {}).get("name") or "")), None if a == "carry": d = (r.get("task") or {}).get("dest") - return f"action:go_to {d.get('name') if isinstance(d, dict) else d}", None + return f"action:go_to {d.get('marker') or d.get('name') if isinstance(d, dict) else d}", None if a == "command": # Start sends the words to the assistant (/tasks/command): return None, None # heard and done as by voice return ("refuse" if r.get("talk") == "refuse" else "talk"), None @@ -251,7 +251,7 @@ def run_case(rnd, name, c, old, use_llm): lv = c.get("level") or bc.level_of(c, {"lang": c.get("lang")}) return {"round": rnd, "set": name, "text": c["text"], "state": c["state"], "before": c.get("before"), "expect": c["expect"] if not mission else c["steps"], "intent": c.get("intent", ""), "map": c.get("map"), - "level": bc.LEVEL_NAME.get(lv, lv), "lang": c.get("lang"), "voice": vgot, "typed": tgot, "handed": handed, + "level": bc.LEVEL_NAME.get(lv, lv), "lang": c.get("lang"), "channel": c.get("channel") or "-", "voice": vgot, "typed": tgot, "handed": handed, "v_canon": vc, "t_canon": tc, "v": vv, "t": tv, "src": src, "same": vc == tc, "raw": vrow["out"].get("raw", ""), "first": vrow["out"].get("first", "")} @@ -327,6 +327,18 @@ def report(rows, tag, secs, args): pct = lambda j, k: f"{sum(r[k] == 'right' for r in j)}/{len(j)} ({100 * sum(r[k] == 'right' for r in j) / max(1, len(j)):.1f} %)" out.append(f"| {lv} | {pct(jv, 'v')} | {pct(jt, 't')} | {sum(r['v'] == 'motion' for r in rr)} | " f"{sum(r['t'] == 'motion' for r in rr)} |") + chans = sorted({r.get("channel", "-") for r in rows} - {"-"}) + if chans: # r12 / r13: the words as typed or as whisper wrote them + out += ["", "By speech level and written channel (voice path right / judged; typed≠voice):", "", + "| level | " + " | ".join(chans) + " |", "|---|" + "---|" * len(chans)] + for lv in sorted({r["level"] for r in rows if r.get("channel", "-") != "-"}) + ["ALL"]: + cells = [] + for ch in chans: + rr = [r for r in rows if r.get("channel") == ch and lv in ("ALL", r["level"]) and r["v"] != "llm?"] + ok = sum(r["v"] == "right" for r in rr) + cells.append(f"{ok}/{len(rr)} ({100 * ok / max(1, len(rr)):.1f} %); " + f"{sum(not r['same'] and not r['before'] for r in rr)}") + out.append(f"| {lv} | " + " | ".join(cells) + " |") groups = collections.defaultdict(list) for r in rows: groups[meaning(r)].append(r) diff --git a/tests/test_battery.py b/tests/test_battery.py index 8392411..654c4a7 100644 --- a/tests/test_battery.py +++ b/tests/test_battery.py @@ -5,13 +5,13 @@ from assistant import battery NOW = ["And charging?", "charging?", "battery?", "Battery", "what's your battery level?", "How much battery do you have?", "how much battery is left", "what's your battery at", "battery percentage", "are you charging?", "are you charging right now", "is your battery charging", "are you on the charger?", "is your battery low?", - "배터리 몇 프로야?", "충전 중이야?", "배터리 얼마나 남았어?", "배터리 상태 어때?", "지금 충전하고 있어?", "배터리는?", + "배터리 몇 프로야?", "배터리 얼만가?", "충전 중이야?", "배터리 얼마나 남았어?", "배터리 상태 어때?", "지금 충전하고 있어?", "배터리는?", "배터리 충분해?", "충전 중이에요?", "그럼 충전은?", "충전은요?", "배터리 몇 퍼센트예요?"] HOW_LONG = ["how long does charging take?", "How long does it take to charge?", "how long to recharge", "what's the charging time", "충전 시간 얼마나 걸려?", "충전하는 데 얼마나 걸려요?", "충전 몇 시간 걸려?", "완충하는 데 얼마나 걸려?", "완충까지 몇 시간이에요?", "how long does a full charge take?", "완충 시간이 얼마예요?"] OTHER = ["How long does your battery last?", "how long on a charge?", "How long does the battery last on a full charge?", - "what kind of battery do you have", "배터리 얼마나 가요?", "한 번 충전하면 몇 시간 가요?", "배터리 용량이 얼마야?", + "what kind of battery do you have", "배터리 얼마나 가요?", "배터리 타임 얼마나 돼요?", "한 번 충전하면 몇 시간 가요?", "배터리 용량이 얼마야?", "go charge", "충전하러 가", "How long until you need a charge?", "at what battery level do you go back to charge", "배터리 몇 퍼센트에서 충전하러 가요?", "go to the charger", "Do you get tired?", "what time is it?", "배고파?"] for t in NOW: diff --git a/tests/test_command_box.py b/tests/test_command_box.py index 988d90b..bc0af15 100644 --- a/tests/test_command_box.py +++ b/tests/test_command_box.py @@ -339,7 +339,7 @@ READ = [ # the owner's Korean cup / delivery list (2026-10-26 18:40), then mor ("let me see you wave", False, "rule wave"), ("okay see you", False, "talk"), ("you come behind me", False, "rule follow"), ("here's your task: get over here", False, "talk"), ("Mina, what are you doing over there?", False, "talk"), ("민수야, 너 거기서 뭐 하고 있어?", False, "talk"), ("루미야 뭐 하고 있어?", False, "talk:status"), - ("계속 들고 있어 주세요", True, "talk"), ("keep holding it", True, "talk"), ("just hold it", True, "talk"), + ("계속 들고 있어 주세요", True, "talk"), ("keep holding it", True, "talk"), ("just hold it", True, "stop"), # safety first: "hold it" stops (the cup stays held) ("give it back", True, "give"), ("돌려줘", True, "give"), ("hand it back to me", True, "give"), ("그거 다시 줘", True, "give"), ("put it back where you found it", True, "place"), ("원래 있던 데 놔 주세요", True, "place"), ("할머니께 이거 전해 드려", True, "give"), ("이거 저분께 드리세요", True, "give"), ("사장님께 드려 주십시오", True, "give"), @@ -372,7 +372,47 @@ READ = [ # the owner's Korean cup / delivery list (2026-10-26 18:40), then mor ("저한테 주실 수 있으신가요?", True, "give"), ("선생님께 드리세요", True, "give"), ("lower it down", True, "place"), ("you putt dawn that", True, "place"), ("lay it on this table lay it on this table please", True, "place"), ("왼쪽에 내려놓고 오른편 컵 잡아 줘", True, "chain"), ("put it back", True, "place"), ("제자리에 갖다 놔", True, "place"), - ("pick up the cup on the left table", False, "pick cup left"), ("오른쪽 테이블에 있는 빨간 컵 집어 줘", False, "pick cup red right"), + ("pick up the cup on the left table", False, "pick cup left"), + ("pick up the cup over on your left", False, "pick cup left"), ("grab the cup sitting on your right", False, "pick cup right"), + ("grab the cup by your side", False, "pick cup near"), ("옆에 있는 컵 집어", False, "pick cup near"), + ("레프트 컵 집어", False, "pick cup left"), ("라이트 컵 집어 줘", False, "pick cup right"), + ("백팩 집어 줘", False, "ask: The backpack is too big for my hand."), + # asides: said, taken back, for later, reported or read out: no motion now + ("Lumi buddy, shake hands with me... ah, forget I said that", False, "talk"), + ("lumi the moment the bell rings wave goodbye to us", False, "talk"), + ("Lumi dear, my manager wanted you to put it down gently first thing today", True, "talk"), + ("lumi on paper it is writing shake my hand", False, "talk"), ("Rumi robot hand it to me is very funny thing", True, "talk"), + ("루미야 come friday lets shake hands", False, "talk"), ("동생아 너도 잘 가라고 손 흔들어 봐", False, "talk"), + ("no need for you to put it down by the coffee machine today", True, "talk"), + ("우리 루미~ 왼쪽에 있는 사람한테 건네 ㄱㄱ~ 는 장난 ㅋㅋ", True, "talk"), + ("로봇이 하얀 탁자 위에 올려놓는 장면이 인상 깊었습니다", True, "talk"), ("들고 있는 거 나 주쇼", True, "give"), + ("robot, rotate right 45 degrees, is okay for you?", False, "turn -45.0"), + ("Stretch your arm out toward me, is okay for you?", False, "arm reach"), + ("루미 팔 원래대로 돌려놓으실 필요는 전혀 없습니다", False, "talk"), ("루미야 team everyone put your arm down now now", False, "talk"), + ("루미야잉, 담에 오른쪽으로 직각으로 돌아 줍써", False, "talk"), + ("are robots like you built to stretch your arm out toward me?", False, "talk"), + ("로봇 로봇이 팔 접는 걸 보니 세상 좋아졌구먼", False, "talk"), + ("ㅋㅋ 손 내려 저용 이거 밈이잖아", False, "talk"), ("Robot look at me is very funnny thing.", False, "talk"), + ("루미 나한테 손 내밀 수 있대 대박.", False, "talk"), ("이따밤에허리왼쪽으로60도돌려줘ㅋㅋ", False, "talk"), + ("now mister robot, cup go back same place, please", True, "place"), ("허리 오른쪽으로 45도 돌여", False, "rule waist right 45"), + ("lumi buddy hold it", False, "stop"), ("루미야 under no circumstances close the gripper", False, "talk"), + ("Lumi, no no, not scoot left 35 cm", False, "talk"), ("손 open 돼 있어?", False, "talk"), ("그리퍼 오픈돼 있어?", False, "talk"), + ("저기 컵 살포시 내려놓지는 마세요 괜찮아요", True, "talk"), ("look 60 deg to right, is okkay for you?", False, "rule look right 60"), + ("Face forward again for me, possible?", False, "rule look center"), ("너 팔 접을 수 있지?", False, "talk"), + ("팔 접어 줄 수 있지?", False, "arm fold"), + ("죄송한데요, 고개만 돌려서 뒤가 보이십니까?", False, "talk"), ("루미야, 등 좀 보이세요", False, "talk"), + ("윤년 말씀하실 때 저 좀 봐 주시겠어요?", False, "rule look me"), ("편할 때 손 흔들어 줘", False, "rule wave"), + ("when you get to p1, wave", False, "talk"), + ("robot turn forty-five degrees to right ah sorry no need", False, "talk"), + ("루미, please 루미야 turn left — scratch that, yesterday I watched a robot turn right on TV", False, "ask: Taken back: nothing to do."), + ("cup in front you pick oops I meant on paper it is writing pickup that cup by you side", False, "ask: Taken back: nothing to do."), + ("Lumi bring me the cup from the exit before, very good", False, "talk"), + ("mister robot you no need twist your waist 45° to the right okay okay", False, "talk"), + ("go to p1, no, exit", False, "go exit"), ("turn left, I mean right", False, "turn -90.0"), + ("두 시 방향에 있는 컵 집어", False, "pick cup right"), ("열 시 방향 컵 집어 줘", False, "pick cup left"), + ("내 얼굴 기억해", False, "talk"), + ("루미야 under no circumstances close the gripper", False, "talk"), ("go back to where you were before", False, "rule come_back"), ("Rumi dear drop the cup off at exit then come back here much obliged", False, "chain"), + ("pick up the backpack", False, "ask: The backpack is too big for my hand."), ("오른쪽 테이블에 있는 빨간 컵 집어 줘", False, "pick cup red right"), ("컵이랑 같이 p5로 가", False, "fetch cup here>p5 hold"), ("컵 하고 같이 exit 가 줘", False, "fetch cup here>exit hold"), ("컵 가지고 p5에서 기다려", False, "pick cup; go p5; wait"), ("컵 들고 p5에 가 있어", False, "pick cup; go p5; wait"), ("이 컵 p5까지 좀 날라 줘", False, "fetch cup here>p5 hold"), ("컵 좀 p5로 옮겨 줘", False, "fetch cup here>p5 hold"), @@ -433,6 +473,13 @@ for text, want in (("갤러리 투로 가 줘", "go Gallery_2"), ("갤러리 1 if got != want: bad.append(text) print(f"WRONG {text!r}\n want {want}\n got {got}") +server.agv.markers = lambda: ["home", "booth_3", "p5"] +for text, want in (("drop the cup off on the table at booth 3", "carry booth_3 place"), ("drop it off at booth 3", "carry booth_3 place"), + ("부스 3 테이블에 놔", "carry booth_3 place")): # holding: there, never here + got = plan(text, True) + if got != want: + bad.append(text) + print(f"WRONG {text!r} (holding)\n want {want}\n got {got}") server.agv.markers = lambda: M @@ -450,7 +497,14 @@ STOPS = ["멈춰", "멈춰요", "멈추세요", "멈춰 주세요", "멈춰 주 STOPS_INSIDE = ["루미야 그거 말고 멈춰 지금", "아 잠깐만 멈춰 봐 위험해", "okay Lumi stop, there's someone in the way", "wait wait stop it now", "컵 내려놓지 말고 멈춰", "야야 스톱 스톱", "저기 사람 있어 멈춰요", "no no no, stop", "Lumi, stop, you're going to hit the table", "그만, 그만해 이제", "다 됐어 멈춰 주세요", "careful, stop!", - "멈춰버려", "동물을 멈춰버린 거랑 안해", "루미야 지금 바로 멈춰 주세요 위험해요", "stop, where are you going?"] + "멈춰버려", "동물을 멈춰버린 거랑 안해", "루미야 지금 바로 멈춰 주세요 위험해요", "stop, where are you going?", + "루미 님, 멈춰 주실 수 있겠습니까?", "오케이, 야 루미, 당장 얼른 서", "okay Lumi, can you go ahead and hold it right there?", + "야 루미 스톱", "루미야 그만해 주세요", "야 서", "lumi buddy hold it", "루미 씨 정지해 주십시오", "hey robot, freeze!", + "로봇아 움직이지 마세요", "자, 루미 님, 그만하시죠", "루미루미, 당장 멈춰 줄 수 있지?"] +for text in STOPS + STOPS_INSIDE: # the task's own words (lumi.fetch_voice): the same stop + if not lumi.stop_order(text, M): + bad.append(text) + print(f"NO STOP during a task {text!r}") for text in STOPS + STOPS_INSIDE: for held in (False, True): got = plan(text, held) diff --git a/tests/test_fetch.py b/tests/test_fetch.py index 9b0c511..15dc0af 100644 --- a/tests/test_fetch.py +++ b/tests/test_fetch.py @@ -1148,6 +1148,29 @@ skills._held.clear() hand.update(holding=False, closed=False) fetch._set(status="idle") +# the straight line to carry ending on the other wrist branch (the same pose, pick:502) is no carry: carry_up decides +real_rows, real_up = fetch._line_rows, skills.carry_up +wp = [("above", [0.0] * 6)] +fetch._line_rows = lambda target, label, start=None: [["to carry 20", target, [3.0] * 6, None]] +skills.carry_up = lambda above, ja: None +assert fetch._carry_ok(wp, [0.0] * 6) # ends at carry's own joints +fetch._line_rows = lambda target, label, start=None: [["to carry 20", target, [3.0, 3.0, 3.0, 183.0, -3.0, 183.0], None]] +assert not fetch._carry_ok(wp, [0.0] * 6) # the other branch, carry_up refuses +skills.carry_up = lambda above, ja: ([0.0] * 6, [3.0] * 6) +assert fetch._carry_ok(wp, [0.0] * 6) # ... or takes it by a joint move +fetch._line_rows, skills.carry_up = real_rows, real_up + +# a put down gives up after PLACE_REFUSALS refused spots in a row (each costs IK time; two puts timed out, X1) +asked = [] +real_opts = skills.place_options +skills.place_options = lambda x, y, top, start: (asked.append((x, y)), iter(()))[1] +fetch._line_rows = lambda target, label, start=None: (_ for _ in ()).throw(fetch.FetchError("no")) +skills._held.update(top_mm=-260.0) +assert fetch._place_at([(-100.0 - 10 * k, 640.0) for k in range(20)], -260.0) is None +assert len(asked) == fetch.PLACE_REFUSALS, asked +fetch._line_rows, skills.place_options = real_rows, real_opts +skills._held.clear() + # the lift is never asked above its limit (head camera cable, robot/head.py LIFT_MAX_MM) assert max(fetch.LIFT_RANGE + fetch.LIFT_TRIES + (fetch.LIFT_DRIVE_MM,)) <= fetch.head.LIFT_MAX_MM == 105.0 assert fetch.head.AXIS_LIMITS[0] == (0.0, fetch.head.LIFT_MAX_MM) diff --git a/tests/test_quick_answers.py b/tests/test_quick_answers.py index ff187e8..375464c 100644 --- a/tests/test_quick_answers.py +++ b/tests/test_quick_answers.py @@ -39,7 +39,8 @@ KIND = { # words (no talk before) -> kind "아이들 옆에 있어도 안전해?": "safety", "what cameras do you have?": "cameras", "얼굴 인식 돼요?": "faces", "컴퍼니 오픈 언제예요?": "co_founded", "참, 로봇 양반, 이름이 무슨 뜻이야?": "name_meaning", "Your voice, what program?": "tts", "들어 있는 인공지능 무엇인지 알려 주십시오": "model", "실례합니다. 네 이름 무엇인지 알려 주십시오": "name", "바퀴 몇 개야?": "wheels", "do you have eyes?": "cameras", - "스피커 어디 있어요?": "tts", "Is it safe for kids to be near you?": "safety", + "스피커 어디 있어요?": "tts", "배터리 타임 얼마나 돼요?": "battery_life", "랭귀지 뭐 할 수 있어?": "languages", + "Is it safe to stand next to you?": "safety", "Is it safe for kids to be near you?": "safety", } IN_TALK = { # words after TALK -> kind or None "how old are you?": "age", "who made you?": "maker", "what's your name?": "name", diff --git a/tests/test_talk.py b/tests/test_talk.py index 961383b..34fae74 100644 --- a/tests/test_talk.py +++ b/tests/test_talk.py @@ -84,6 +84,12 @@ def main(): ("What is salt for?", "ACTION: none -\nSeasoning."), ("ok", "ACTION: none -\nSure.")] assert "most common" in b._back_to("again about hydrogen, what did you say?") + h = [("남극은 얼마나 추워?", "ACTION: none -\n영하 89도까지 내려가요."), # "really?" after a refused order: + ("춤 좀 춰 봐", "ACTION: none -\n저는 바퀴로 움직여서 춤은 못 춰요.")] # the talk before it; "why not?": the refusal + assert brain.topic_turn(h, "어이, 진짜?")[0] == "남극은 얼마나 추워?" + assert brain.topic_turn(h, "저기 루미 왜 안 돼?")[0] == "춤 좀 춰 봐" + assert brain.topic_turn(h)[0] == "춤 좀 춰 봐" + picked = [] talk_examples.pick = lambda said, lang, k=4, bank=None: picked.append(bank) or [] brain._examples("윤초는 뭐예요?", world=True)