diff --git a/.gitignore b/.gitignore index 246c951..4898ba0 100644 --- a/.gitignore +++ b/.gitignore @@ -61,9 +61,11 @@ docs/night4/ tests/blind/r9/ tests/blind/r10/ docs/night5/ +docs/night6/ tests/blind/r11/ tests/blind/r12/ tests/blind/r13/ +tests/blind/r14/ data/bank_build.lock data/bank_check_queries.npz tests/data/waves/ diff --git a/assistant/action_examples.py b/assistant/action_examples.py index 5f22a83..ad66294 100644 --- a/assistant/action_examples.py +++ b/assistant/action_examples.py @@ -307,6 +307,44 @@ _BANK = { }, } +_BANK["registers"] = { # one order said casually, rudely, politely, formally: the same action; Lumi stays polite + "en": [ + ("Yo, turn left.", "turn left 90", "Okay, turning left."), + ("Would you be so kind as to turn left?", "turn left 90", "Of course, turning left."), + ("Get over here, now.", "come", "Coming."), + ("Could you possibly come over here?", "come", "Sure, I'm coming."), + ("Hey, shake your hand.", "wave", "Sure, waving!"), + ("Shake hand, buddy.", "wave", "Sure, here's a wave!"), + ("Mind following me for a bit?", "follow", "Sure, I'll follow you."), + ("Look at me, will ya?", "look me", "Okay, I'm looking at you."), + ], + "ko": [ + ("야, 왼쪽으로 돌아라.", "turn left 90", "네, 왼쪽으로 돌게요."), + ("좌회전 해.", "turn left 90", "네, 왼쪽으로 돌게요."), + ("왼쪽으로 회전해 주시겠습니까?", "turn left 90", "네, 왼쪽으로 돌겠습니다."), + ("야 빨리 이리 와.", "come", "네, 갈게요."), + ("이쪽으로 와 주시겠어요?", "come", "네, 갈게요."), + ("이리 오십시오.", "come", "네, 가겠습니다."), + ("손 흔들어 봐라.", "wave", "네, 손 흔들게요!"), + ("손 좀 흔들어 주시겠어요?", "wave", "네, 손 흔들게요!"), + ("악수 한번 하자.", "wave", "좋아요, 악수해요!"), + ("저 따라다녀 주세요.", "follow", "네, 따라갈게요."), + ("야 나 따라와라.", "follow", "네, 따라갈게요."), + ("앞으로 1미터 전진해.", "move forward 1", "네, 앞으로 1미터 갈게요."), + ("50센티만 뒤로 물러나 주십시오.", "move back 0.5", "네, 뒤로 50센티 물러나겠습니다."), + ("고개 들어라.", "look up", "네, 위를 볼게요."), + ("고개를 드세요.", "look up", "네, 위를 볼게요."), + ("야 나 좀 봐.", "look me", "네, 보고 있어요."), + ("저를 봐 주시겠습니까?", "look me", "네, 보고 있겠습니다."), + ("손 내밀어 봐.", "arm reach", "네, 손을 내밀게요."), + ("팔 접어라.", "arm fold", "네, 팔을 접을게요."), + ("야 너 손 흔들 줄 아냐?", "none", "네, 흔들 수 있어요. 흔들어 드릴까요?"), + ("아까 너 손 흔들었잖아.", "none", "네, 아까 흔들었어요."), + ("손 흔들지 마라.", "none", "네, 안 흔들게요."), + ("얘, 이리 와 봐.", "none", "아이가 귀엽네요."), + ], +} + EXAMPLES = [(cat, lang, said, reply, action) for cat, langs in _BANK.items() for lang, rows in langs.items() for said, action, reply in rows] diff --git a/assistant/bank_words/en_more.py b/assistant/bank_words/en_more.py new file mode 100644 index 0000000..c36f457 --- /dev/null +++ b/assistant/bank_words/en_more.py @@ -0,0 +1,40 @@ +"""More English sentences of the same meaning: other verbs and idioms for the same order ("face left", "do a u-turn", +"bow your head", "eyes on me", "lend me your hand", "tag along", "stick with me", "go get the cup for me"), each with +the frames people put around it (please, could you, would you mind, I need you to, slang, non-native).""" + +FRAMES = ["{}", "please {}", "{}, please", "could you {}?", "can you {}?", "would you {}?", "can you {} for me?", + "I need you to {}", "I'd like you to {}", "go ahead and {}", "{} now", "yo, {}", "just {}", "lumi, {}", + "you {} please", "{} pls", "can u {}", "would you please {}?", "hey, {} would ya"] + + +def _with(phrases): + return list(dict.fromkeys(f.format(p) for p in phrases for f in FRAMES)) + + +INTENT = { + "turn": _with(["face left", "face right", "face the other way", "turn the other way", "do a u-turn", "make a u-turn", + "rotate one eighty", "turn one eighty", "pivot left", "pivot right", "swing left", "swing right", + "turn your body to the left", "turn your body to the right", "about face", "flip around"]), + "look": _with(["bow your head", "nod your head down", "look at the ceiling", "look at the floor", "eyes on me", + "turn to me", "turn your head to me", "look my way", "look in my direction", "eyes up", + "eyes down", "glance up", "glance down", "peek left", "peek right", "check out the ceiling"]), + "come_back": _with(["go back to your spot", "return to where you started", "come back to where you were", + "go back where you came from", "back to your starting point", "return to your spot", + "head back to where you were"]), + "arm_reach": _with(["lend me your hand", "let me hold your hand", "give me a hand to hold", "stick your hand out", + "put your arm out", "offer me your hand"]), + "arm_open": _with(["release the gripper", "let go with your gripper", "loosen your grip", "unclench your hand", + "open up your fingers", "relax your fingers"]), + "arm_close": _with(["clench your hand", "tighten your grip", "grip tight", "squeeze your fingers shut"]), + "fetch": _with(["go get the for me", "go get me the ", "fetch me the ", "grab me the ", + "bring the my way", "get the and bring it here", "could you bring over the ", + "pass me the "]), + "lift": _with(["get taller", "raise yourself up", "make yourself shorter", "lower yourself", "make yourself taller"]), + # not "go up / down a bit": "move up a smidge" is a drive forward + "follow": _with(["tag along", "stick with me", "come along with me", "walk behind me", "stay on my heels", + "keep up with me", "come with me, buddy"]), + "come": _with(["get over here", "come over to me", "come on over", "come closer to me", "scoot over here", + "roll over here", "make your way over here"]), + "wave": _with(["do you shake your hand", "do you wave", "shake my hand", "give me a handshake", "high five me", + "wave goodbye", "give a little wave", "wave your hand at me"]), +} diff --git a/assistant/bank_words/en_questions.py b/assistant/bank_words/en_questions.py new file mode 100644 index 0000000..dd320dd --- /dev/null +++ b/assistant/bank_words/en_questions.py @@ -0,0 +1,23 @@ +"""More English questions about Lumi in casual / chat / non-native wording ("who put you together?", "you gonna hurt +me?", "u do stairs?"), for the quick answers' kinds.""" + +QUICK = { + "name": ["what do they call you", "what do people call you", "what should i call you", "got a name", "name please", + "what's your name buddy", "what are you called", "how should i address you"], + "age": ["how old is this robot", "are you new", "how long have you existed", "when were you born", + "what year were you made", "how many years old are you"], + "maker": ["who put you together", "who designed you", "who created you", "which company made this", "who's your maker", + "where do you come from, which company", "who invented you"], + "height": ["you're tall, how tall exactly", "how high are you", "what's your height in centimeters", + "how tall is lumi"], + "cameras": ["where are your cameras", "what do you see with", "where are your eyes", + "do you have cameras", "camera how many you have"], + "safety": ["are you going to hurt me", "will you hurt me", "are you dangerous", "can you hurt people", + "is it safe near you", "should i be scared of you"], + "stairs": ["do you do stairs", "can you take the stairs", "can you go upstairs", "can you climb steps", + "can you go up stairs by yourself"], + "how_are_you": ["what's up", "how you doing", "how have you been", "you good", "how's your day", "how's life"], + "can_sing": ["you sing", "can you sing a bit", "do you know any songs", "are you a singer"], + "battery_life": ["how long can you run", "how long do you last", "how long till you need charging", + "how many hours on one charge"], +} diff --git a/assistant/bank_words/ko_more.py b/assistant/bank_words/ko_more.py new file mode 100644 index 0000000..f4841e6 --- /dev/null +++ b/assistant/bank_words/ko_more.py @@ -0,0 +1,69 @@ +"""More Korean sentences of the same meaning for the body moves: other verbs (전진, 후진, 물러나, 좌회전, 따라다녀, +뒤따라와 …), other word orders ("1미터 앞으로" / "앞으로 1미터") and the casual / rude register (명령조: "가라", +"빨리 와", "당장 돌아", "봐라"), on top of korean_levels.py's fronts x verbs x endings.""" +from assistant.bank_words import korean_levels as kl + +kl.VERBS.update({ + "뒤따라와": ("뒤따라와", "뒤따라오"), "따라붙어": ("따라붙어", "따라붙으"), "전진": ("전진해", "전진하"), + "후진": ("후진해", "후진하"), "물러나": ("물러나", "물러나"), "빠져": ("빠져", "빠지"), "나가": ("나가", "나가"), + "좌회전": ("좌회전해", "좌회전하"), "우회전": ("우회전해", "우회전하"), "틀어": ("틀어", "트"), "출발": ("출발해", "출발하"), + "고개들어": ("들어", "드"), "챙겨": ("챙겨", "챙기"), "내려놓아": ("내려놓아", "내려놓으"), +}) + +# the casual / rude register: a bare order with -라, a "hurry", a "now" +RUDE = ["{a}라", "{a} 봐라", "{a}라고", "빨리 {a}", "{a}, 빨리", "{a} 빨리", "당장 {a}", "얼른 {a}", "어서 {a}", "빨리 {a}라", + "{a}라니까", "{a}라 좀", "냉큼 {a}"] + + +def _make(fronts, verbs): + out = kl._make(fronts, verbs) + for f in fronts: + for v in verbs: + for e in RUDE: + t = kl._say(f, v, e) + if t and t not in out: + out.append(t) + return out + + +_FWD = ["앞으로 ", "앞쪽으로 ", "1미터 앞으로 ", "앞으로 1미터 ", "한 걸음 앞으로 ", "두 걸음 앞으로 ", "조금만 앞으로 ", + "1미터만 앞으로 ", "앞으로 조금 ", "30센티 앞으로 "] +_BACK = ["뒤로 ", "뒤쪽으로 ", "50센티 뒤로 ", "뒤로 50센티 ", "한 걸음 뒤로 ", "두 걸음 뒤로 ", "조금만 뒤로 ", + "50센티만 뒤로 ", "뒤로 조금 ", "1미터 뒤로 "] +_SIDE = ["왼쪽으로 ", "오른쪽으로 ", "왼쪽으로 50센티 ", "오른쪽으로 1미터 ", "옆으로 "] + +INTENT = { + "move": _make(_FWD, ["가", "이동", "전진", "나가", "움직"]) + _make(_BACK, ["가", "이동", "후진", "물러나", "빠져"]) + + _make(_SIDE, ["가", "이동"]) + _make(["", "좀 ", "조금 "], ["전진", "후진", "물러나"]), + "turn": _make(["왼쪽으로 ", "오른쪽으로 ", "왼편으로 ", "오른편으로 ", "왼쪽으로 90도 ", "오른쪽으로 45도 ", + "45도 오른쪽으로 ", "90도 왼쪽으로 ", "오른쪽으로 30도 ", "뒤로 ", "뒤쪽으로 ", "반 바퀴 ", "180도 "], + ["돌아", "회전"]) + + _make(["몸을 왼쪽으로 ", "몸을 오른쪽으로 ", "몸 왼쪽으로 ", "몸 오른쪽으로 ", "몸을 뒤로 "], ["돌려"]) + + _make(["왼쪽으로 몸 ", "오른쪽으로 몸 ", "왼쪽으로 몸 좀 ", "오른쪽으로 몸 좀 "], ["틀어", "돌려"]) + + _make(["반대쪽으로 ", "반대로 ", "뒤쪽으로 "], ["돌아서"]) + + _make(["", "살짝 "], ["좌회전", "우회전"]), + "follow": _make(["", "저 ", "나 ", "날 ", "저를 ", "제 뒤 ", "제 뒤를 ", "내 뒤 ", "나 좀 ", "저 좀 ", "졸졸 ", "계속 ", + "끝까지 "], ["따라다녀", "뒤따라와", "따라붙어", "따라와", "쫓아와"]), + "come": _make(["이리 ", "이리로 ", "여기로 ", "이쪽으로 ", "제 쪽으로 ", "가까이 ", "좀 더 가까이 ", "여기까지 ", "제 앞까지 ", + "내 앞으로 ", "나한테 ", "저한테 "], ["와", "다가와"]), + "go_to": _make(["로 ", "까지 ", " 쪽으로 "], ["가", "이동", "움직", "출발"]), + "look": _make(["왼쪽을 ", "오른쪽을 ", "위를 ", "아래를 ", "위쪽을 ", "아래쪽을 ", "천장을 ", "바닥을 ", "앞을 ", "정면을 ", + "저 좀 ", "나 좀 ", "날 ", "저를 ", "여기를 ", "이쪽을 ", "제 얼굴 "], ["봐", "쳐다봐", "바라봐"]) + + _make(["고개 ", "고개를 ", "머리 ", "머리를 ", "고개 좀 "], ["고개들어", "숙여"]) + + _make(["고개를 위로 ", "고개 위로 ", "머리를 위로 "], ["올려"]) + + _make(["고개를 아래로 ", "고개 아래로 ", "머리를 아래로 "], ["내려"]) + + _make(["고개를 왼쪽으로 ", "고개를 오른쪽으로 ", "고개 왼쪽으로 ", "고개 오른쪽으로 "], ["돌려"]), + "wave": _make(["손 ", "손을 ", "손 좀 ", "손 한번 ", "손 크게 ", "손을 좀 "], ["흔들어"]) + + _make(["", "저랑 ", "나랑 ", "악수 한번 "], ["악수"]), + "arm_reach": _make(["손 ", "손을 ", "팔 ", "팔을 ", "손을 앞으로 ", "팔을 앞으로 "], ["내밀어", "뻗어"]), + "arm_fold": _make(["팔 ", "팔을 ", "팔을 몸 쪽으로 "], ["접어", "거둬"]), + "lift": _make(["몸 ", "몸을 ", "키 ", "키를 "], ["올려", "내려", "높여", "낮춰"]) + _make(["몸을 위로 ", "몸 위로 "], ["올려"]) + + _make(["몸을 아래로 ", "몸 아래로 "], ["내려"]), + "pick": _make([" ", " 좀 ", "그 ", "이 ", " 하나 ", "을 ", "테이블 위 "], + ["집", "잡", "챙겨", "들어올려"]), + "fetch": _make([" ", " 좀 ", "나한테 ", "저한테 ", " 하나 ", "여기로 "], + ["가져와", "갖고와", "챙겨와", "가져다", "갖다"]), + "put": _make([" ", "그거 ", "이거 ", "테이블에 ", "테이블 위에 ", "여기 ", "들고 있는 거 "], ["놔", "내려놔", "둬", "내려놓아"]), + "arm_open": _make(["손 ", "손을 ", "그리퍼 ", "집게 ", "손가락 "], ["펴", "벌려", "열어"]), + "arm_close": _make(["손 ", "손을 ", "그리퍼 ", "집게 ", "손가락 "], ["닫아", "오므려"]), +} diff --git a/assistant/bank_words/ko_questions.py b/assistant/bank_words/ko_questions.py new file mode 100644 index 0000000..5f786f0 --- /dev/null +++ b/assistant/bank_words/ko_questions.py @@ -0,0 +1,46 @@ +"""Korean questions about Lumi in the casual / rude register (야 너 몇 살이냐, -냐 / -니 / 대 봐) and the formal and +honorific ones (-습니까, -세요, 성함 / 연세 / 여쭤봐도), for the quick answers' kinds that had them least.""" + +QUICK = { + "name": ["야 너 이름 뭐냐", "니 이름 뭐냐", "이름이 뭐냐고", "너 이름이 뭐니", "이름 뭐냐", "넌 이름이 뭐냐", "이름이 뭡니까", + "이름이 어떻게 되십니까", "이름이 무엇인지 말씀해 주십시오", "성함이 어떻게 되시는지요", "존함이 어떻게 되세요", + "이름 좀 여쭤봐도 될까요", "뭐라고 부르면 되냐", "뭐라고 불러야 됩니까"], + "age": ["야 너 몇 살이냐", "너 몇 살 먹었냐", "나이 몇이냐", "몇 살이냐고", "몇 살이니", "나이가 몇이니", "몇 살입니까", + "나이가 어떻게 됩니까", "연세가 어떻게 되세요", "연세가 어떻게 되십니까", "올해 몇 살이신가요", "몇 살이신지 여쭤봐도 될까요", + "언제 만들어졌냐", "만들어진 지 얼마나 됐냐", "제작된 지 얼마나 되었습니까"], + "maker": ["야 누가 너 만들었냐", "누가 만들었냐고", "어디 회사 거냐", "너 어디 제품이냐", "너 누가 만들었니", "어느 회사 제품입니까", + "제조사가 어디입니까", "누가 개발했습니까", "어느 회사에서 만드셨어요", "어디서 만드신 로봇인가요", "개발하신 곳이 어디세요", + "만든 회사가 어디냐", "어디서 개발했냐"], + "who": ["야 너 뭐냐", "넌 대체 뭐냐", "너 정체가 뭐냐", "너 뭐 하는 놈이냐", "뭐 하는 로봇이에요", "뭐 하는 로봇이냐", + "무슨 일 하는 로봇이에요", "어떤 일을 하는 로봇입니까", "어떤 로봇이신가요", "누구신가요", "누구십니까", "자기소개 좀 해 보세요", + "당신은 누구입니까", "넌 누구니"], + "height": ["너 얼마나 커", "얼마나 크냐", "야 너 키 몇이냐", "키 몇 센티냐", "키가 몇이니", "너 얼마나 커요", "키가 얼마나 됩니까", + "신장이 어떻게 되십니까", "키가 어떻게 되세요", "키는 얼마나 되시나요"], + "weight": ["야 너 몇 킬로냐", "몸무게 몇이냐", "얼마나 무겁냐", "너 무게 얼마니", "무게가 얼마나 나갑니까", "몸무게가 어떻게 되세요", + "무게가 어떻게 되십니까", "몇 킬로그램이나 나가세요"], + "battery_life": ["충전하면 얼마나 버티냐", "배터리 몇 시간 가냐", "한 번 충전하면 얼마나 버텨", "배터리 얼마나 버텨요", + "충전하면 몇 시간 버팁니까", "배터리는 얼마나 가세요", "한 번 충전하시면 몇 시간 가세요", "배터리 몇 시간짜리냐"], + "speed": ["얼마나 빠르냐", "속도 몇이냐", "최고 속도 몇이냐", "얼마나 빠르니", "최고 속도가 어떻게 됩니까", "속도가 어떻게 되세요", + "얼마나 빨리 다니세요", "얼마나 빨리 달리냐"], + "languages": ["무슨 말 하냐", "너 무슨 말 하냐", "몇 개 국어 하냐", "영어 할 줄 아냐", "무슨 언어 하냐", "말은 뭐 뭐 하니", + "어떤 언어를 구사합니까", "어떤 언어를 하세요", "몇 개 국어 하세요", "영어도 하실 줄 아세요", "무슨 말 할 줄 알아"], + "how_are_you": ["잘 지냈냐", "기분 어떠냐", "요즘 어떠냐", "잘 지냈니", "기분 어떠니", "잘 지내셨습니까", "기분이 어떻습니까", + "잘 지내셨어요", "요즘 어떻게 지내세요", "오늘 기분 어떠세요"], + "can_sing": ["노래할 줄 아냐", "노래 부를 줄은 아냐", "노래도 하냐", "노래도 하세요", "노래도 하십니까", "노래 부르실 줄 아세요", + "노래 좀 하냐", "노래 잘하냐"], + "dance": ["춤도 춰", "춤도 춰요", "춤은 추냐", "춤 출 줄 아냐", "춤도 춥니까", "춤도 추세요", "춤 추실 줄 아세요", "춤 잘 추냐", + "춤 좀 추냐"], + "cameras": ["카메라 어디 있냐", "카메라 어디 달려 있어", "카메라는 어디에 있어요", "카메라는 어디에 달려 있습니까", "카메라 몇 개냐", + "카메라가 몇 개 있으세요", "눈은 어디에 있으세요", "눈이 어디냐"], + "country": ["어느 나라 거냐", "너 어디 나라 로봇이냐", "고향이 어디세요", "고향이 어디야", "어디서 왔냐", "어느 나라에서 오셨어요", + "어느 나라 로봇입니까"], + "stairs": ["계단은 타냐", "계단 올라갈 수 있냐", "계단 오를 수 있니", "계단도 올라가세요", "계단을 오를 수 있습니까", "계단 탈 줄 아냐"], + "time_now": ["몇 시냐", "지금 몇 시냐고", "지금 몇 시니", "현재 시각이 어떻게 됩니까", "지금 몇 시인지 여쭤봐도 될까요", + "지금 몇 시예요 혹시"], + "date_today": ["오늘 며칠이냐", "무슨 요일이냐", "오늘 며칠이니", "오늘은 무슨 요일입니까", "오늘 날짜가 어떻게 되나요", + "오늘이 며칠인지 여쭤봐도 될까요"], + "name_meaning": ["루미가 무슨 뜻이에요", "루미가 무슨 뜻이야", "루미라는 이름은 무슨 뜻이에요", "루미 뜻이 뭐냐", "이름이 무슨 뜻입니까", + "이름 뜻이 뭐예요", "루미라는 이름 무슨 의미야", "이름에 무슨 뜻이 있으세요", "왜 이름이 루미예요"], + "software": ["무슨 프로그램으로 움직여요", "무슨 소프트웨어 써", "뭘로 프로그래밍 됐어요", "어떤 프로그램 돌아가요", + "소프트웨어는 뭐로 만들었습니까", "무슨 언어로 코딩됐어", "프로그램은 뭘로 짰냐"], +} diff --git a/assistant/brain.py b/assistant/brain.py index 4d884a2..cd1c4cf 100644 --- a/assistant/brain.py +++ b/assistant/brain.py @@ -920,9 +920,10 @@ NOT_NAME = {"루미", "누미", "류미", "무미", "루비", "루니", "아니" def to_someone_else(text): """"Hey Jake, come see this", "Mom, look!", "민수야 이리 와 봐": said to another person nearby, not an order to Lumi.""" - if ASIDE_EN.search(text) or re.match(r"^\W*(?:야|얘)[\s,!]+(?!.*(?:루미|로봇|lumi))", text, re.I) or \ + if ASIDE_EN.search(text) or re.match(r"^\W*얘[\s,!]+(?!.*(?:루미|로봇|lumi))", text, re.I) or \ re.match(r"^\W*my (?:friend|dear|buddy|son|daughter|boy|girl|kid|baby|love|darling)\s*,", text, re.I): - return True # "야 그 사과 좀 집어 줘", "my friend, you follow me" + return True # "얘 그 사과 좀 집어 줘", "my friend, you follow me" + # (a bare 야 is the casual call to Lumi: "야, 이리 와") for m in re.finditer(r"[,\s]([가-힣]{2})(아|야)(?=[\s,!~.]|$)", text): # "그거 내려놔, 지훈아 깨져" c = m.group(1)[-1] vowel_end = (ord(c) - 0xAC00) % 28 == 0 @@ -1053,11 +1054,23 @@ def not_an_order(text, asked=True): return False # "I'm on your right": said so the head turns there rest = instead_of(t) # "don't put your arm out, my baby will grab it" now = NOW_CLAUSE.sub(" ", WAIT_UNTIL.sub(" ", t)) # "when you're ready", "while you do", "말씀하실 때": now + now = STEP_AFTER.sub(" 그리고 ", now) # "p3로 이동한 다음에 손 흔들어": Lumi's own step first return bool(to_someone_else(t) or CANT_GO.search(t) or DRINK.search(t) or IDIOMS.search(t) or CONDITION.search(now) or REMARK.search(now) or TAKEN_BACK.search(t) or rest != t and REMARK.search(rest) or asked and ASKED.search(t) or NEGATED.search(t) or ko_told(t) or - ABOUT_IT.search(t) or LATER_SAID.search(t) or ASIDE_NOW.search(t)) + ABOUT_IT.search(t) or LATER_SAID.search(t) or ASIDE_NOW.search(t) or DOUBT.search(t)) + + +DOUBT = re.compile(r"\b(?:can|could) (?:you|u) (?:even|really)\b|" + r"\b(?:he|she|they|my (?:son|daughter|kid|kids|friend|wife|husband|mom|dad|boss|brother|sister)) " + r"(?:wants?|wanted|would like|likes?|loves?|tried) to (?!have you\b)", re.I) + # "can you even turn left?": a doubt; "my son wants to fold your arm": what someone else wants to do, no order + + +STEP_AFTER = re.compile(r"(?:이동한|간|돈|돌아선|회전한|본|쳐다본|집은|잡은|든|흔든|내려놓은|놓은|온|돌아온|따라간|움직인|올린|내린|" + r"숙인|편|접은|내민|뻗은|연|닫은|가져온|챙긴) (?:다음에|후에)") + # Lumi's own step, then the next one ("오른쪽 본 다음에 손 흔들어"), not a condition like "회의 끝난 다음에" NOW_CLAUSE = re.compile( # time words that mean now, with the order (T1, 2026-10-27): no later condition @@ -1581,8 +1594,9 @@ def _intent(text, markers=()): if driving.amount(t)[0] is None: return None # "I'll come back later", "come back tomorrow": talk continue # "come back 20 cm": a short drive - if action == "make_way" and driving.direction(driving.clean(t)) not in (None, "back"): - n, exact = driving.amount(t) # "왼쪽으로 20센티미터만 비켜 주게": that way, that far + if action == "make_way" and driving.direction(driving.clean(t)) not in (None, "back") or \ + action == "make_way" and driving.direction(driving.clean(t)) == "back" and driving.amount(t)[0] is not None: + n, exact = driving.amount(t) # "왼쪽으로 20센티미터만 비켜 주게", "뒤로 50센티 비켜": that far n = driving.DEFAULT_M if n is None else n if n == "?" or not driving.MOVE_MIN_M <= n <= MOVE_MAX_M: return None @@ -1629,8 +1643,9 @@ 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|\bgimme\b", t): - return ("fetch", text) # "go grab me a cup": brought to me, not only picked + if action == "pick" and re.search(r"\b(?:grab|get|fetch|pick up|take) me\b|\bgimme\b|" + r"\b(?:go |come )?(?:grab|get|fetch) (?:the |that |this |a |an )?\w+(?: \w+)? for me\b", t): + return ("fetch", text) # "go grab me a cup", "go get the cup for me": brought to me 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 if action in ("pick", "move_object"): @@ -2860,6 +2875,7 @@ UNSURE = re.compile(r"\b(not sure|don't know|do not know|don't have (any )?(info QUESTION_START = re.compile(r"^\s*(where|what|how|why|when|which|who|do you|does|is|are|can i|could i)\b|어디 ?(있|에 있)|" r"(어디|뭐|왜|언제|몇)[^ ]*\s*\?*\s*$", re.I) # a question about a place, not a command ABILITY_Q = re.compile(r"(? "이동하고", "집은 후에" -> "집고"; a noun before 다음에 ("회의 다음에") stays.""" + c = m.group(1) + n = ord(c) - 0xAC00 + if c == "은": + return "고" + if n % 28 == 4: # the -ㄴ form: 한 -> 하, 간 -> 가 + return chr(0xAC00 + n - 4) + "고" + return m.group(0) + + def parts(text): """The sentence cut at and / then / 그리고 / -고 / -서, messages to say kept whole, fillers and the name dropped.""" text = re.sub(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 )?(?:go ahead and )?" - r"(?:stop|halt|freeze|hold it(?: right)? (?:there|here))" + r"\W*(?:(?:좀|지금|당장|잠깐|잠시|거기서?|이제|동작|모든 동작|하던 거|움직임|얼른|빨리)\s*)*(?:멈춰|멈춰 서|정지해|그만해|스톱해|스탑해|서|움직이지 말아|움직이지 마|가만히 있어)" + r"(?: ?(?:줘|도|봐))?(?:\W*(?:부탁(?:드립니다|드려요|해요|해)|제발))?\W*|" + r"\W*(?:(?:please|lumi|hey|okay|ok)\W+)*(?:(?:can|could|would|will) (?:you|u)|you can) (?:please |just |kindly |" + r"be so kind as to )?(?:go ahead and )?" + r"(?:stop(?: it| that| moving| everything)?|halt|freeze|cut it out|knock it off|hold it(?: right)? (?:there|here))" r"(?: (?:right )?(?:now|here|there|please))?(?: for (?:me|us|a (?:second|sec|moment|bit|minute)))?(?:,? please)?\W*|" + r"\W*(?:please |just |c'?mon,? |go ahead and )?(?:cut it out|knock it off)(?:,? (?:please|buddy|now))?\W*|" + r"\W*(?:stop|halt|freeze)(?:,? ok(?:ay)?)\W*|" r"\W*(?:would|do) you mind stopping(?: (?:now|here|there))?(?: for (?:me|us|a (?:second|moment)))?(?:,? please)?\W*", re.I) @@ -3944,7 +3950,18 @@ def stop_order(text, markers): 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)) + return stop_order_said(text, markers) or bool(bare and bare != text and stop_order_said(bare, markers)) or \ + bool(STOP_CORE.fullmatch(EN_FRAME_END.sub("", EN_FRAME_START.sub("", bare or text or "")))) + + +EN_FRAME_START = re.compile(r"^\W*(?:(?:please|hey|yo|c'?mon|okay|ok|lumi|now|just|so|whoa|go ahead and|you|u|" + r"(?:could|would|can|will) (?:you|u)(?: please| kindly| be so kind as to)?|you can|can|" + r"i(?: need| want| would like|'d like) (?:you|u) to)\W+)+", re.I) +EN_FRAME_END = re.compile(r"(?:\W+(?:please|pls|plz|for me|for us|ok|okay|buddy|bro|dude|would ya|will ya|now|right now|" + r"already|if you don'?t mind|thanks))+\W*$|\W+$", re.I) +STOP_CORE = re.compile(r"stop(?: it| that| moving| everything| right there| right now| now| the robot)?|freeze|halt|cut it out|" + r"knock it off|(?:stay|hold|keep) still|that'?s enough|emergency stop|don'?t move", re.I) + # an English stop inside the frames people put around it: "I'd like you to cut it out", "could you stay still?" def order_after_stop(text, markers, b): diff --git a/assistant/quick_answers.py b/assistant/quick_answers.py index cfc6297..d139690 100644 --- a/assistant/quick_answers.py +++ b/assistant/quick_answers.py @@ -268,13 +268,17 @@ NO = [t for t in NO if t not in _said] # a wording CAMERA = re.compile(r"\b(?:see|seeing|saw|look(?:s|ing)?|watch|camera|wearing|holding|in front of|behind|colou?r|" r"recogni[sz]e|remember)\b|보여|보이|보니|(?= 3 and NAMES_LUMI.search(t[lead.end():]): @@ -538,8 +558,9 @@ def _kind(text, history): best, top, margin, agree, _ = intent_bank._top(vecs @ q, _named, k=AGREE_K) sure = top >= SIM_MIN and margin >= MARGIN or agree and top >= SIM_AGREE and margin >= MARGIN_AGREE core = _core(text) - if not sure: # "누가너를만들었습니까": a wording run together (whisper) - best = _exact().get(_squeezed(core)) if re.fullmatch(r"\S*[가-힣]{4}\S*", core) else None + if not sure: # "누가너를만들었습니까": a wording run together (whisper), + best = _exact().get(_squeezed(core)) if re.search(r"[가-힣]", core) else None + # or a Korean bank wording said as it is ("루미가 무슨 뜻이야") if best in (None, "no") or best in NEEDS and not re.search(NEEDS[best], text, re.I): return None if best == "hello" and history: diff --git a/assistant/seeing.py b/assistant/seeing.py index b00a072..d0b0dfa 100644 --- a/assistant/seeing.py +++ b/assistant/seeing.py @@ -1521,11 +1521,17 @@ def _piece_of_someone(t): return None +ORDER_FIRST = re.compile(r"^\W*(?:(?:please|okay|ok|lumi|hey|now|just)\W+)*(?:head|lift|raise|lower|tilt|bow|stand|go|come|turn|" + r"move|spin|face|wave|follow|stop|sing|bring|get|take|pick|put|fold|open|close|reach|drive|back)\b", re.I) + + def _changed(t, last): """"I took my glasses off, now?", "모자를 벗었습니다. 지금은 쓰고 있습니까?", "앉았어요, 지금은?": the question about what they say changed, asked anew: (kind, words) or None.""" if not (CHANGED.search(t) and (AGAIN.search(t) or "?" in t or re.search(r"어때|어떻|보여|보이|\bnow\W*$|\bwhich one\b", t, re.I))): return None + if "?" not in t and ORDER_FIRST.match(t): + return None # "lift your head now", "head to p3 now": an order, no look for rx, kind, en, ko in CHANGE_KINDS: if re.search(rx, t, re.I): return kind, ko if re.search(r"[가-힣]", t) else en diff --git a/assistant/wording.py b/assistant/wording.py index 2c27776..eb45d84 100644 --- a/assistant/wording.py +++ b/assistant/wording.py @@ -531,6 +531,27 @@ def _stem_aform(word): return aform(KO_L_DROP.get(word, word)) +NOUN_ASK = re.compile(r"(이동|회전|전진|후진|정지|좌회전|우회전|충전|복귀|출발|악수|후퇴)\s*(?:좀\s*)?" + r"부탁(?:드립니다|드려요|드릴게요|드릴께요|해요|해|합니다|드려|할게요|합니다)") +SUGGEST_FORMAL = re.compile(r"([가-힣])(?:으)?시다(?=[\s.,!?~]|$)") + + +def _suggest_plain(m): + """하십시오체 suggestion -ㅂ시다 / -읍시다 as the plain -자: "갑시다" -> "가자", "집읍시다" -> "집자".""" + c = m.group(1) + n = ord(c) - 0xAC00 + if c == "읍" or "으시다" in m.group(0): + return ("" if c == "읍" else c) + "자" + if c in SUGGEST_L: + return SUGGEST_L[c] + "자" # a ㄹ stem: "돕시다" (돌다) -> "돌자" + if 0 <= n < 11172 and n % 28 == 17: # the syllable ends in ㅂ: 갑 -> 가 + return chr(0xAC00 + n - 17) + "자" + return m.group(0) + + +SUGGEST_L = {"돕": "돌", "듭": "들", "엽": "열", "놉": "놀"} # 흔듭시다 -> 흔들자 too + + def ko_plain(t): """Korean request endings of every speech level and dialect as one plain form, so the readers see one wording: "가세요" / "가십시오" / "가요" / "가라" / "가이소" -> "가"; "따라오세요" / "따라온나" / "따라오라고" -> "따라와"; @@ -538,6 +559,8 @@ def ko_plain(t): "흔드세요" -> "흔들어"; "해부러" / "혀" -> "해". Greetings ("안녕하세요", "들어가세요") stay; questions keep their "?".""" if not t or not re.search(r"[가-힣]", t): return t + t = SUGGEST_FORMAL.sub(_suggest_plain, t) # "p3로 갑시다", "같이 봅시다" -> "가자", "보자" + t = NOUN_ASK.sub(r"\1해 줘", t) # "p5로 이동 부탁드립니다" -> "p5로 이동해 줘" for rx, to in KO_PLAIN: if to in ("CAN_L", "CAN_N"): t = rx.sub(lambda m: _can_you(m, to), t) diff --git a/audio/sing.py b/audio/sing.py index a697b5a..d1dba77 100644 --- a/audio/sing.py +++ b/audio/sing.py @@ -70,7 +70,7 @@ SING = re.compile(r"\bsing\b|\bsay (?:a |some )?songs?\b|" # r"(?:노래|음악|곡)\s*(?:좀\s*)?바꿔|\b(?:(?:want|like|love) to|(?:can|could|may) (?:we|i)) hear (?:a |some |one of your )?(?:songs?|music)\b|\bgive (?:us|me) (?:a |some )?(?:song|tune|music)\b|" r"^\W*(?:lumi\W*)?(?:a |some )?(?:song|music)(?:\W+(?:please|lumi))*\W*$|" r"(?:노래|음악|(? from inside it). + + .venv/bin/python tests/en_held_check.py # -> logs/en_held.md +""" +import pathlib + +from tests import ko_levels_check as kl + +ROOT = pathlib.Path(__file__).resolve().parents[1] + +CASES = [ + ("mind taking me to p5?", "go to p5", "polite"), ("p5, let's go", "go to p5", "casual"), ("off you go to p5", "go to p5", "casual"), + ("you go p5 now please", "go to p5", "nonnative"), ("would you kindly make your way over to p5", "go to p5", "polite"), + ("scoot forward a meter", "move forward one meter", "casual"), ("one meter ahead please", "move forward one meter", "polite"), + ("you go front one meter", "move forward one meter", "nonnative"), ("back it up half a meter", "move back half a meter", "casual"), + ("could you reverse fifty centimeters?", "move back half a meter", "polite"), + ("hang a left", "turn left", "casual"), ("turn yourself to the left please", "turn left", "polite"), ("you turn left side", "turn left", "nonnative"), + ("swing around the other way", "turn around", "casual"), ("would you mind turning around?", "turn around", "polite"), + ("tip your head up", "look up", "casual"), ("could you look up at the ceiling for me?", "look up", "polite"), ("you look up please", "look up", "nonnative"), + ("look down at your feet", "look down", "plain"), ("eyes on me buddy", "look at me", "casual"), ("would you look over at me?", "look at me", "polite"), + ("come on over here", "come here", "casual"), ("could you come a bit closer to me?", "come here", "polite"), ("you come here please", "come here", "nonnative"), + ("keep close behind me", "follow me", "plain"), ("come along, follow me", "follow me", "casual"), ("would you mind following me?", "follow me", "polite"), + ("you follow me please", "follow me", "nonnative"), + ("give the kids a wave", "wave", "plain"), ("shake my hand, robot", "wave", "casual"), ("could you wave at us?", "wave", "polite"), + ("you shake hand with me", "wave", "nonnative"), ("let's do a handshake", "wave", "casual"), + ("hold your hand out for me", "give me your hand", "plain"), ("could you reach your arm out?", "give me your hand", "polite"), + ("put the arm away now", "fold your arm", "plain"), ("could you fold that arm back in?", "fold your arm", "polite"), + ("open up your hand", "open your hand", "plain"), ("would you open the gripper please?", "open your hand", "polite"), + ("snag the cup", "pick up the cup", "casual"), ("could you pick that cup up for me?", "pick up the cup", "polite"), + ("you take cup please", "pick up the cup", "nonnative"), + ("bring that cup over to me", "bring me the cup", "plain"), ("would you fetch me the cup?", "bring me the cup", "polite"), + ("whoa whoa stop", "stop", "casual"), ("please stop right now", "stop", "polite"), ("you stop please", "stop", "nonnative"), + ("knock it off", "stop", "casual"), + ("sing us something", "sing a song", "casual"), ("would you sing a song for us?", "sing a song", "polite"), + ("you sing song please", "sing a song", "nonnative"), + ("time to charge, go", "go charge", "casual"), ("could you go to your charger?", "go charge", "polite"), + ("speak up a bit", "speak louder", "casual"), ("could you talk a little louder?", "speak louder", "polite"), +] +NOT_NOW = [ + "I waved at a robot yesterday", "don't follow me please", "my kid wants to shake your hand later", "can you even turn left?", + "if I raise my hand, come here", "he told me to go to p5", "the robot at the mall followed me around", + "do you know how to sing?", "please don't pick up my cup", "we turned left at the corner", +] + + +def check(): + rows = [] + for t, en, level in CASES: + want, got = kl.read(en), kl.read(t) + rows.append(("en", level, t, got, want, "right" if kl.same(want, got) else + "missed" if got is None or got.split()[0] in kl.command_check.NO_MOTION else "wrong")) + for t in NOT_NOW: + got = kl.read(t) + moves = got is not None and got.split()[0] not in kl.command_check.NO_MOTION + rows.append(("en", "not_now", t, got, "no motion", "motion" if moves and got not in ("stop", "sing") else "right")) + return rows + + +if __name__ == "__main__": + out = kl.report(check()).replace("# Korean speech levels against English (tests/ko_levels_check.py)", + "# English held-out orders (tests/en_held_check.py)") + (ROOT / "logs" / "en_held.md").write_text(out) + print(out) diff --git a/tests/en_paraphrase_check.py b/tests/en_paraphrase_check.py new file mode 100644 index 0000000..5adf2f6 --- /dev/null +++ b/tests/en_paraphrase_check.py @@ -0,0 +1,101 @@ +"""English requests said in other words: each capability's sentences of the same meaning (the owner's example: "shake +your hand", "shake hand", "can you shake your hand", "wave your hand", "wave hand", "do you shake your hand" = wave) +in every frame people use (bare, please, could you, would you mind, I need you to, go ahead and, slang, non-native) +must give the reading of the capability's plain request. The same words as talk (past, negation, later, about +someone else) must not move Lumi. + + .venv/bin/python tests/en_paraphrase_check.py # -> logs/en_paraphrase.md +""" +import collections +import pathlib +import sys + +from tests import ko_levels_check as kl + +ROOT = pathlib.Path(__file__).resolve().parents[1] + +# name: (plain request, [other sentences of the same meaning, verb first]); "spin left" / "spin around" / "turn all the +# way around" are a full spin, "hold it" a hand-over: not listed +CAPS = { + "wave": ("wave", ["shake your hand", "shake hand", "wave your hand", "wave hand", "give us a wave", "wave hello", + "do a little wave", "shake hands with me", "let's shake hands", "wave at me", "wave to the kids", + "say hi with your hand", "wave bye"]), + "reach": ("give me your hand", ["hold out your hand", "stretch your arm out", "reach out your hand", "put your hand out", + "lend me your hand", "extend your arm"]), + "fold": ("fold your arm", ["put your arm away", "tuck your arm in", "bring your arm back", "lower your arm", + "put your arm down"]), + "open": ("open your hand", ["open the gripper", "open your fingers", "spread your fingers", "release the gripper"]), + "close": ("close your hand", ["close the gripper", "close your fingers", "make a fist", "shut your hand"]), + "pick": ("pick up the cup", ["grab the cup", "take the cup", "get the cup", "lift the cup", "pick the cup up", + "grab that cup", "take hold of the cup"]), + "fetch": ("bring me the cup", ["get me the cup", "fetch the cup", "bring the cup over here", "hand me the cup", + "bring that cup to me", "go get the cup for me"]), + "go_to": ("go to p3", ["head to p3", "drive to p3", "move to p3", "go over to p3", "make your way to p3", + "get yourself to p3", "go to point p3"]), + "home": ("go home", ["go back home", "head home", "return home", "go to your home spot"]), + "come": ("come here", ["come over here", "come to me", "come closer", "get over here", "come this way", + "come over", "approach me"]), + "follow": ("follow me", ["come with me", "follow along", "walk with me", "stay behind me", "keep following me", + "tag along", "stick with me"]), + "forward": ("move forward one meter", ["go forward one meter", "drive forward a meter", "move ahead one meter", + "roll forward one meter", "go one meter forward"]), + "back": ("move back half a meter", ["back up half a meter", "go back fifty centimeters", "reverse half a meter", + "back off half a meter", "move backward fifty centimeters"]), + "turn": ("turn left", ["turn to the left", "rotate left", "turn your body left", "face left", + "make a left turn", "turn left ninety degrees"]), + "around": ("turn around", ["do a u-turn", "turn the other way", + "face the other way", "rotate one eighty"]), + "look_up": ("look up", ["look upward", "lift your head", "raise your head", "tilt your head up", "look at the ceiling", + "head up"]), + "look_dn": ("look down", ["look downward", "lower your head", "tilt your head down", "look at the floor", + "head down", "bow your head"]), + "look_me": ("look at me", ["look over here", "eyes on me", "face me", "turn to me", "look this way", + "look at my face"]), + "stop": ("stop", ["stop it", "stop right there", "stop moving", "freeze", "halt", "stop now", "cut it out"]), + "sing": ("sing a song", ["sing something", "sing for us", "give us a song", "play a song", "sing me a song", + "can we hear a song", "sing one of your songs"]), + "come_back": ("come back", ["come back to where you were", "go back to your spot", "return to where you started"]), + "body_up": ("raise your body", ["make yourself taller", "lift your body", "stand taller"]), + "charge": ("go charge", ["go charge yourself", "go to the charger", "go recharge", "go charge your battery"]), +} +FRAMES = { + "bare": ["{}", "{} now", "okay, {}", "lumi, {}", "hey lumi, {}"], + "polite": ["please {}", "{}, please", "could you {}?", "would you {}, please?", "can you {} for me?", + "would you be so kind as to {}?", "{}, if you don't mind", "I'd like you to {}", "I need you to {}", + "would you please {}?", "could you please {}?"], + "casual": ["yo, {}", "{} real quick", "go ahead and {}", "c'mon, {}", "just {}", "{}, buddy", "{} already", + "hey, {} would ya", "{} pls", "can u {}"], + "nonnative": ["you {} please", "please you {}", "lumi you {}", "now you {}", "{} ok?", "you can {}?"], +} +NOT_NOW = ["I {}ed yesterday", "don't {}", "please don't {}", "later you can {}", "if I clap, {}", "my son wants to {}", + "he told me to {}", "do you know how to {}?"] + + +def check(names=None): + rows = [] + for name, (plain, others) in CAPS.items(): + if names and name not in names: + continue + want = kl.read(plain) + for frame, forms in FRAMES.items(): + for phrase in [plain] + others: + for f in forms: + t = f.format(phrase) + got = kl.read(t) + rows.append((name, frame, t, got, want, "right" if kl.same(want, got) else + "missed" if got is None or got.split()[0] in kl.command_check.NO_MOTION else "wrong")) + for f in NOT_NOW[1:3] + NOT_NOW[3:]: + t = f.format(plain) + got = kl.read(t) + moves = got is not None and got.split()[0] not in kl.command_check.NO_MOTION + rows.append((name, "not_now", t, got, "no motion", "right" if not moves else + "wrong" if got in ("stop", "sing") else "motion")) + return rows + + +if __name__ == "__main__": + rows = check(set(sys.argv[1:]) or None) + out = kl.report(rows).replace("# Korean speech levels against English (tests/ko_levels_check.py)", + "# English sentences of the same meaning (tests/en_paraphrase_check.py)") + (ROOT / "logs" / "en_paraphrase.md").write_text(out) + print(out[:out.index("## Not right")]) diff --git a/tests/en_questions_check.py b/tests/en_questions_check.py new file mode 100644 index 0000000..522dbe3 --- /dev/null +++ b/tests/en_questions_check.py @@ -0,0 +1,81 @@ +"""English questions about Lumi said in many ways (plain, polite, casual / slang, kids, non-native) against the quick +answers: the same question must get the same kind. Written apart from the bank's wordings. + + .venv/bin/python tests/en_questions_check.py # -> logs/en_questions.md +""" +import collections +import pathlib + +from assistant import quick_answers as qa + +ROOT = pathlib.Path(__file__).resolve().parents[1] + +Q = { + "name": {"plain": ["what's your name?", "do you have a name?"], "polite": ["may I ask your name?", "could you tell me your name?"], + "casual": ["yo what's ur name", "what do they call you?"], "kid": ["robot what is you name?"], + "nonnative": ["you name what?", "what is name of you?"]}, + "age": {"plain": ["how old are you?", "when were you made?"], "polite": ["may I ask how old you are?"], + "casual": ["how old r u", "you old or new?"], "kid": ["are you a baby robot? how old?"], + "nonnative": ["how many year you have?", "you are how old?"]}, + "maker": {"plain": ["who made you?", "which company built you?"], "polite": ["could you tell me who developed you?"], + "casual": ["who built ya?", "who put you together?"], "kid": ["who made you robot?"], + "nonnative": ["who is make you?", "what company make this robot?"]}, + "height": {"plain": ["how tall are you?", "what's your height?"], "polite": ["may I ask how tall you are?"], + "casual": ["how tall r u", "you're pretty tall huh, how tall?"], "kid": ["how big are you?"], + "nonnative": ["how much tall you are?", "you height is how much?"]}, + "weight": {"plain": ["how much do you weigh?", "how heavy are you?"], "polite": ["could you tell me your weight?"], + "casual": ["how heavy r u", "you heavy?"], "nonnative": ["how many kilo you are?"]}, + "battery_life": {"plain": ["how long does your battery last?", "how many hours can you work?"], + "polite": ["could you tell me your battery life?"], "casual": ["how long u last on a charge?"], + "nonnative": ["battery how many hour?"]}, + "speed": {"plain": ["how fast can you go?", "what's your top speed?"], "polite": ["may I ask how fast you move?"], + "casual": ["how quick r u", "you fast?"], "nonnative": ["your speed how much?"]}, + "languages": {"plain": ["what languages do you speak?", "do you speak korean?"], "polite": ["which languages can you understand?"], + "casual": ["u speak english?", "what languages u got?"], "nonnative": ["you speak which language?"]}, + "who": {"plain": ["who are you?", "what are you?"], "polite": ["could you introduce yourself?"], + "casual": ["so what are you exactly?", "what's your deal?"], "kid": ["what kind of robot are you?"], + "nonnative": ["you are what?"]}, + "time_now": {"plain": ["what time is it?", "do you know the time?"], "polite": ["could you tell me the time?"], + "casual": ["what time's it?", "got the time?"], "nonnative": ["now what time?"]}, + "date_today": {"plain": ["what's the date today?", "what day is it today?"], "polite": ["could you tell me today's date?"], + "casual": ["what's today's date?"], "nonnative": ["today is what date?"]}, + "how_are_you": {"plain": ["how are you?", "how's it going?"], "polite": ["how are you doing today?"], + "casual": ["sup lumi", "how ya doin?"], "nonnative": ["you are fine?"]}, + "can_sing": {"plain": ["can you sing?", "do you sing?"], "polite": ["are you able to sing?"], + "casual": ["u sing?", "can u sing tho?"], "nonnative": ["you can singing?"]}, + "cameras": {"plain": ["how many cameras do you have?", "where are your cameras?"], "polite": ["what cameras do you use?"], + "casual": ["where ur eyes at?"], "nonnative": ["camera how many you have?"]}, + "safety": {"plain": ["are you safe?", "is it safe to stand next to you?"], "polite": ["is it safe for children to be near you?"], + "casual": ["u gonna hurt me?"], "nonnative": ["you are dangerous?"]}, + "stairs": {"plain": ["can you climb stairs?", "can you go up steps?"], "polite": ["are you able to use stairs?"], + "casual": ["u do stairs?"], "nonnative": ["you can go stair?"]}, + "estop": {"plain": ["where is your emergency stop?", "how do I stop you in an emergency?"], + "polite": ["could you show me the emergency stop button?"], "casual": ["where's ur kill switch?"]}, +} + + +def check(): + rows = [] + for kind, levels in Q.items(): + for level, texts in levels.items(): + for t in texts: + got = qa.kind_of(t) + rows.append((kind, level, t, got, "right" if got == kind else "missed" if got is None else "wrong")) + return rows + + +if __name__ == "__main__": + rows = check() + by = collections.defaultdict(collections.Counter) + for kind, level, t, got, v in rows: + by[level][v] += 1 + lines = ["# English questions in many ways (tests/en_questions_check.py)", "", + "| way | right | missed | wrong | total |", "|---|---|---|---|---|"] + for level, c in by.items(): + lines.append(f"| {level} | {c['right']} | {c['missed']} | {c['wrong']} | {sum(c.values())} |") + tot = collections.Counter(v for *_, v in rows) + lines += [f"| all | {tot['right']} | {tot['missed']} | {tot['wrong']} | {len(rows)} |", "", "## Not right", ""] + lines += [f"- {k} [{lv}] {t!r} -> {got}" for k, lv, t, got, v in rows if v != "right"] + out = "\n".join(lines) + "\n" + (ROOT / "logs" / "en_questions.md").write_text(out) + print(out) diff --git a/tests/ko_held_check.py b/tests/ko_held_check.py new file mode 100644 index 0000000..3476d63 --- /dev/null +++ b/tests/ko_held_check.py @@ -0,0 +1,78 @@ +"""A held-out Korean check (written apart from ko_levels_check.py's sentences and bank_words/ko_more.py): orders said +in sentences of their own at every register, each with the English request it means; and remarks that must not +move. Run on two trees to compare (PYTHONPATH= from inside it). + + .venv/bin/python tests/ko_held_check.py # -> logs/ko_held.md +""" +import collections +import pathlib + +from tests import ko_levels_check as kl + +ROOT = pathlib.Path(__file__).resolve().parents[1] + +# (Korean, the English request it means, register) +CASES = [ + ("저 p5까지 좀 데려다줄래?", "go to p5", "반말"), ("p5 쪽으로 출발!", "go to p5", "반말"), ("p5로 가 보자", "go to p5", "suggest"), + ("야 p5 가라고", "go to p5", "rude"), ("p5로 이동 부탁드립니다", "go to p5", "하십시오"), ("p5까지 가 주시면 좋겠어요", "go to p5", "해요"), + ("p5 방향으로 움직여 주실래요?", "go to p5", "honorific"), ("얼른 p5로 꺼져", "go to p5", "rude"), + ("앞으로 쭉 1미터만 가 볼래?", "move forward one meter", "반말"), ("1미터 전진하십시오", "move forward one meter", "하십시오"), + ("앞으로 1미터 나가 봐", "move forward one meter", "반말"), ("야 1미터 앞으로 가라", "move forward one meter", "rude"), + ("한 1미터 앞으로 와 주세요", "move forward one meter", "해요"), + ("뒤로 50센티 빠져 줄래?", "move back half a meter", "반말"), ("50센티 후진 부탁해요", "move back half a meter", "해요"), + ("뒤로 50센티 물러나십시오", "move back half a meter", "하십시오"), ("야 뒤로 50센티 비켜", "move back half a meter", "rude"), + ("왼쪽으로 몸 좀 틀어 봐", "turn left", "반말"), ("좌회전 하십시오", "turn left", "하십시오"), ("왼편으로 돌아 주시겠어요?", "turn left", "honorific"), + ("야 왼쪽으로 돌라고", "turn left", "rude"), ("왼쪽으로 한 바퀴 말고 90도만 돌아", "turn left", "반말"), + ("오른쪽으로 45도 회전 부탁드려요", "turn right 45 degrees", "해요"), ("우측으로 45도 돌아 주십시오", "turn right 45 degrees", "하십시오"), + ("뒤돌아 봐", "turn around", "반말"), ("반대쪽으로 돌아 서 주세요", "turn around", "해요"), ("한 바퀴 반 말고 반 바퀴만 돌아라", "turn around", "rude"), + ("고개 위로 들어 봐", "look up", "반말"), ("위쪽 좀 쳐다보세요", "look up", "honorific"), ("천장 좀 봐라", "look up", "rude"), + ("고개를 아래로 숙여 주십시오", "look down", "하십시오"), ("바닥 좀 봐 줄래?", "look down", "반말"), + ("여기 나 좀 봐라", "look at me", "rude"), ("저 좀 쳐다봐 주세요", "look at me", "해요"), ("저를 바라봐 주시겠습니까?", "look at me", "하십시오"), + ("이쪽으로 와 볼래?", "come here", "반말"), ("내 쪽으로 좀 와라", "come here", "rude"), ("가까이 와 주시겠어요?", "come here", "honorific"), + ("이리로 좀 오십시오", "come here", "하십시오"), ("야 이리 와 봐", "come here", "rude"), + ("나 졸졸 따라와", "follow me", "반말"), ("제 뒤를 쫓아와 주세요", "follow me", "해요"), ("저를 따라오시겠습니까?", "follow me", "하십시오"), + ("야 나 따라붙어", "follow me", "rude"), ("나만 따라다녀 줘", "follow me", "반말"), + ("손 들어서 흔들어 줘", "wave", "반말"), ("손 좀 흔들어 주실래요?", "wave", "honorific"), ("야 손 흔들어 봐라", "wave", "rude"), + ("손을 흔들어 주십시오", "wave", "하십시오"), ("우리랑 악수 한번 해요", "wave", "해요"), ("악수 좀 하자", "wave", "suggest"), + ("저랑 악수하시겠어요?", "wave", "honorific"), ("손 흔들어서 인사 좀 해 줘", "wave", "반말"), + ("손 내밀어 줄래?", "give me your hand", "반말"), ("팔 쭉 뻗어 봐라", "give me your hand", "rude"), ("손을 내밀어 주시겠습니까?", "give me your hand", "하십시오"), + ("팔 다시 접어", "fold your arm", "반말"), ("팔 거두십시오", "fold your arm", "하십시오"), ("팔 좀 접어 주세요", "fold your arm", "해요"), + ("손 쫙 펴 봐", "open your hand", "반말"), ("그리퍼 좀 열어 주세요", "open your hand", "해요"), ("집게 벌려라", "open your hand", "rude"), + ("컵 하나 들어 올려 봐", "pick up the cup", "반말"), ("컵 좀 잡아 주시겠어요?", "pick up the cup", "honorific"), ("야 컵 집어 들어", "pick up the cup", "rude"), + ("그 컵 좀 챙겨 줘", "pick up the cup", "반말"), ("컵을 집어 주십시오", "pick up the cup", "하십시오"), + ("컵 하나만 갖다 줄래?", "bring me the cup", "반말"), ("저한테 컵 좀 가져다주세요", "bring me the cup", "해요"), + ("야 컵 가져와 빨리", "bring me the cup", "rude"), ("컵 하나 가져오시겠습니까?", "bring me the cup", "하십시오"), + ("그만 좀 해", "stop", "반말"), ("거기 멈춰라", "stop", "rude"), ("동작을 멈춰 주십시오", "stop", "하십시오"), ("움직이지 마세요", "stop", "해요"), + ("잠깐 정지해 주실래요?", "stop", "honorific"), ("야 서라고", "stop", "rude"), + ("노래 하나 불러 봐", "sing a song", "반말"), ("노래 좀 불러 주시겠어요?", "sing a song", "honorific"), ("야 노래나 해 봐", "sing a song", "rude"), + ("노래 한 곡 부탁드립니다", "sing a song", "하십시오"), ("노래 부르자", "sing a song", "suggest"), + ("충전하러 가 봐", "go charge", "반말"), ("충전기 쪽으로 가 주세요", "go charge", "해요"), ("배터리 충전하러 가십시오", "go charge", "하십시오"), + ("원래 있던 자리로 돌아와", "come back", "반말"), ("제자리로 돌아오세요", "come back", "해요"), + ("몸 좀 올려 봐", "raise your body", "반말"), ("키 좀 높여 주세요", "raise your body", "해요"), + ("더 크게 말해 봐", "speak louder", "반말"), ("목소리 좀 키워 주세요", "speak louder", "해요"), +] +NOT_NOW = [ + "아까 너 왼쪽으로 돌았잖아", "손 흔들 줄 알아?", "어제 로봇이 p5로 가더라", "따라오지 마세요", "이따가 노래 불러 줘", + "엄마가 이리 오래", "우리 애가 손 흔들었어요", "컵 집지 마", "제가 신호하면 앞으로 가 주세요", "민수야 이리 와 봐", + "고개 숙이는 거 봤어요", "p5로 가면 뭐가 있어요?", "악수하는 법 알려 줄까?", "팔 접지 마십시오", "충전하러 갔었어?", +] + + +def check(): + rows = [] + for t, en, level in CASES: + want, got = kl.read(en), kl.read(t) + rows.append(("ko", level, t, got, want, "right" if kl.same(want, got) else + "missed" if got is None or got.split()[0] in kl.command_check.NO_MOTION else "wrong")) + for t in NOT_NOW: + got = kl.read(t) + moves = got is not None and got.split()[0] not in kl.command_check.NO_MOTION + rows.append(("ko", "not_now", t, got, "no motion", "motion" if moves and got not in ("stop", "sing") else "right")) + return rows + + +if __name__ == "__main__": + out = kl.report(check()).replace("# Korean speech levels against English (tests/ko_levels_check.py)", + "# Korean held-out orders (tests/ko_held_check.py)") + (ROOT / "logs" / "ko_held.md").write_text(out) + print(out) diff --git a/tests/ko_levels_check.py b/tests/ko_levels_check.py index 76d35d3..da223e8 100644 --- a/tests/ko_levels_check.py +++ b/tests/ko_levels_check.py @@ -55,6 +55,44 @@ CAPS = { "put": ("put the cup down", "컵 내려", "놓", "놔", []), "charge": ("go charge", "충전하러", "가", "가", ["차지하러 가 줘"]), } +# other sentences of the same meaning: (words before the verb, verb stem, its 아/어 form), each said at every level +PARA = { + "go_to": [("p3로", "이동하", "이동해"), ("p3까지", "가", "가"), ("p3 쪽으로", "가", "가"), ("p3로", "움직이", "움직여")], + "home": [("홈으로", "돌아가", "돌아가"), ("홈 위치로", "가", "가")], + "forward": [("앞으로 1미터", "이동하", "이동해"), ("1미터 앞으로", "가", "가"), ("앞으로 1미터", "전진하", "전진해"), + ("1미터만 앞으로", "가", "가")], + "back": [("뒤로 50센티", "물러나", "물러나"), ("50센티 뒤로", "가", "가"), ("뒤로 50센티", "후진하", "후진해"), + ("50센티만 뒤로", "빠지", "빠져")], + "turn": [("왼쪽으로", "회전하", "회전해"), ("몸을 왼쪽으로", "돌리", "돌려"), ("왼편으로", "돌", "돌아"), + ("좌회전", "하", "해")], + "turn45": [("오른쪽으로 45도", "회전하", "회전해"), ("45도 오른쪽으로", "돌", "돌아")], + "look": [("왼쪽을", "보", "봐"), ("왼쪽", "쳐다보", "쳐다봐"), ("고개를 왼쪽으로", "돌리", "돌려")], + "look_up": [("위쪽을", "보", "봐"), ("위를", "쳐다보", "쳐다봐"), ("천장을", "보", "봐")], + "head_up": [("고개를", "들", "들어"), ("머리", "들", "들어"), ("고개를 위로", "올리", "올려")], + "head_dn": [("고개를", "숙이", "숙여"), ("머리를", "숙이", "숙여"), ("고개를 아래로", "내리", "내려")], + "wave": [("손을", "흔들", "흔들어"), ("손 한번", "흔들", "흔들어"), ("팔을", "흔들", "흔들어"), + ("손 흔들어서 인사", "하", "해")], + "shake": [("저랑 악수", "하", "해"), ("악수 한번", "하", "해"), ("나랑 악수", "하", "해")], + "reach": [("손을", "내밀", "내밀어"), ("팔을", "뻗", "뻗어"), ("손을 앞으로", "내밀", "내밀어")], + "follow": [("나를", "따라오", "따라와"), ("저", "따라다니", "따라다녀"), ("제 뒤를", "따라오", "따라와"), + ("날", "쫓아오", "쫓아와")], + "come": [("여기로", "오", "와"), ("이쪽으로", "오", "와"), ("나한테", "오", "와"), ("가까이", "오", "와"), + ("이리", "다가오", "다가와")], + "stop": [("거기", "서", "서"), ("동작", "멈추", "멈춰"), ("", "정지하", "정지해")], + "fetch": [("컵 좀", "가져오", "가져와"), ("컵", "갖고 오", "갖고 와"), ("저한테 컵", "가져오", "가져와"), + ("컵", "챙겨 오", "챙겨 와")], + "pick": [("컵을", "잡", "잡아"), ("컵을", "집어 들", "집어 들어"), ("컵", "픽업하", "픽업해")], + "fold": [("팔을", "접", "접어"), ("팔을", "거두", "거둬"), ("팔을 몸 쪽으로", "접", "접어")], + "sing": [("노래 한 곡", "부르", "불러"), ("노래", "하", "해"), ("노래 한 곡", "뽑", "뽑아")], + "look_me": [("나를", "보", "봐"), ("저 좀", "보", "봐"), ("여기를", "보", "봐"), ("저를", "쳐다보", "쳐다봐")], + "around": [("반 바퀴", "돌", "돌아"), ("180도", "돌", "돌아")], + "come_back": [("원래 자리로", "돌아오", "돌아와"), ("다시", "돌아오", "돌아와")], + "waist": [("허리를 왼쪽으로", "틀", "틀어"), ("허리 왼쪽으로", "돌리", "돌려")], + "body_up": [("몸을", "높이", "높여"), ("키를", "높이", "높여"), ("몸을 위로", "올리", "올려")], + "open": [("손을", "펴", "펴"), ("손을", "벌리", "벌려"), ("집게를", "열", "열어"), ("그리퍼", "열", "열어")], + "put": [("컵", "내려놓", "내려놔"), ("컵을 테이블에", "놓", "놔"), ("컵", "내려 두", "내려 둬")], + "charge": [("충전기로", "가", "가"), ("충전하러", "이동하", "이동해")], +} EN_FORMS = ["{}", "please {}", "{}, please", "could you {}?", "can you {} for me?", "would you {}, please?", "I'd like you to {}", "I'd love it if you could {}", "{}, if you don't mind", "lumi, {}", "it would be great if you could {}"] @@ -92,6 +130,14 @@ def past(a): return a[:-1] + _with_final(a[-1], 20) +def sida(stem): + """The 하십시오체 suggestion: 가 -> 갑시다, 돌 -> 돕시다, 집 -> 집읍시다.""" + j = _j(stem[-1]) + if j[2] == 8: # ㄹ drops: 돕시다, 흔듭시다 + return stem[:-1] + _with_final(stem[-1], 17) + "시다" + return stem + "읍시다" if j[2] else stem[:-1] + _with_final(stem[-1], 17) + "시다" + + def levels(pre, stem, a): """{level: [Korean forms]} for one verb phrase.""" p = (pre + " ") if pre else "" @@ -110,6 +156,9 @@ def levels(pre, stem, a): f"{p}{a} 줄 수 있을까요?"], "dialect": [f"{p}{a} 도", f"{p}{a} 주이소", f"{p}{a} 주랑께", f"{p}{a} 줘유", f"{p}{a} 줍서", f"{p}{a}라 마"], "slip": [f"{p}{a}줘", f"{p}{a} 주세여", f"{p}{a}조", f"{(pre + a).replace(' ', '')} 줘"], + "suggest": [f"{p}{stem}자", f"{p}{sida(stem)}", f"자, {p}{stem}자"], + "rude": [f"야, {p}{a}", f"야 {p}{a}라", f"빨리 {p}{a}", f"{p}{a}라 빨리", f"당장 {p}{a}", f"{p}{a}라고", + f"{p}{a} 봐라", f"얼른 {p}{a} 줘", f"야 루미, {p}{a}"], } @@ -133,7 +182,11 @@ def same(want, got): return got == want or got is not None and want is not None and command_check.ok(want, got) == "right" -def check(names=None): +SUGGEST_FOR = {"go_to", "home", "forward", "back", "turn", "turn45", "wave", "shake", "sing", "around", "charge", "look", "look_up", + "look_dn"} # "p3로 가자", "악수합시다": a suggestion is an order only where Lumi does it with the visitor + + +def check(names=None, para=True): """rows: (capability, level, text, reading, want, verdict) with verdict right / missed / wrong / motion.""" rows = [] for name, (en, pre, stem, a, mixed) in CAPS.items(): @@ -141,12 +194,17 @@ def check(names=None): continue want = read(en) forms = {"en": [f.format(en) for f in EN_FORMS], **levels(pre, stem, a), "konglish": mixed} + for pp, ps, pa in PARA.get(name, []) if para else []: + for level, texts in levels(pp, ps, pa).items(): + forms["para_" + level] = forms.get("para_" + level, []) + texts + if name not in SUGGEST_FOR: + forms = {k: v for k, v in forms.items() if not k.endswith("suggest")} for level, texts in forms.items(): for t in texts: got = read(t) rows.append((name, level, t, got, want, "right" if same(want, got) else "missed" if got is None or got.split()[0] in command_check.NO_MOTION else "wrong")) - for t in not_now(pre, stem, a): + for t in not_now(pre, stem, a) + [t for pp, ps, pa in (PARA.get(name, []) if para else []) for t in not_now(pp, ps, pa)]: got = read(t) moves = got is not None and got.split()[0] not in command_check.NO_MOTION and \ not (got == "action:look away" and "지 마" in t) # "저를 보지 마세요": looking away is asked diff --git a/tests/ko_questions_check.py b/tests/ko_questions_check.py new file mode 100644 index 0000000..8e0f451 --- /dev/null +++ b/tests/ko_questions_check.py @@ -0,0 +1,194 @@ +"""Korean questions about Lumi at every register against the quick answers: the same question said casually (반말), +rudely (명령조, 야 / -냐 / 대 봐), politely (해요체), formally (하십시오체) and with honorifics (-시-, 성함, 연세) must +get the same quick-answer kind. Written apart from the bank's wordings. (The price and how long a charge takes go to the +LLM on purpose: not here.) + + .venv/bin/python tests/ko_questions_check.py # -> logs/ko_questions.md +""" +import collections +import pathlib + +from assistant import quick_answers as qa + +ROOT = pathlib.Path(__file__).resolve().parents[1] + +# kind: {register: [questions]} +Q = { + "name": { + "반말": ["너 이름 뭐야?", "이름이 뭐니?", "네 이름 알려 줘", "너 뭐라고 불러?", "이름 있어?"], + "rude": ["야 너 이름 뭐냐", "이름 대 봐", "야 이름이 뭐냐고", "니 이름 뭐냐?", "이름 말해 봐라"], + "해요": ["이름이 뭐예요?", "이름 좀 알려 주세요", "뭐라고 부르면 돼요?", "이름이 있어요?", "이름이 어떻게 돼요?"], + "하십시오": ["이름이 무엇입니까?", "이름을 말씀해 주십시오", "어떻게 불러야 합니까?", "이름이 있습니까?"], + "honorific": ["성함이 어떻게 되세요?", "성함이 어떻게 되십니까?", "존함을 여쭤봐도 될까요?", "이름을 여쭤봐도 될까요?"], + }, + "age": { + "반말": ["너 몇 살이야?", "나이가 몇이야?", "너 언제 만들어졌어?", "몇 살인지 알려 줘", "올해 몇 살?"], + "rude": ["야 너 몇 살이냐", "나이 대 봐", "몇 살이냐고", "야 나이 몇이냐?", "너 몇 살 먹었냐"], + "해요": ["몇 살이에요?", "나이가 어떻게 돼요?", "언제 만들어졌어요?", "만들어진 지 얼마나 됐어요?", "나이가 몇이에요?"], + "하십시오": ["몇 살입니까?", "나이가 어떻게 됩니까?", "언제 만들어졌습니까?", "제작된 지 얼마나 되었습니까?"], + "honorific": ["연세가 어떻게 되세요?", "나이가 어떻게 되십니까?", "올해 몇 살이신가요?", "언제 태어나셨어요?"], + }, + "maker": { + "반말": ["너 누가 만들었어?", "어디서 만들었어?", "너 어느 회사 거야?", "만든 사람 누구야?", "제조사가 어디야?"], + "rude": ["야 누가 너 만들었냐", "어디 회사 거냐", "만든 데 대 봐", "누가 만들었냐고", "야 너 어디 제품이냐?"], + "해요": ["누가 만들었어요?", "어느 회사에서 만들었어요?", "제조사가 어디예요?", "개발사가 어디예요?", "어디 제품이에요?"], + "하십시오": ["누가 만들었습니까?", "어느 회사 제품입니까?", "제조사가 어디입니까?", "어디에서 개발했습니까?"], + "honorific": ["어느 회사에서 만드셨어요?", "누가 개발하셨나요?", "제조사를 여쭤봐도 될까요?", "어디서 만드신 로봇인가요?"], + }, + "height": { + "반말": ["너 키 몇이야?", "키 얼마야?", "키가 몇 센티야?", "너 얼마나 커?"], + "rude": ["야 너 키 몇이냐", "키 몇 센티냐", "키 대 봐", "야 너 얼마나 크냐?"], + "해요": ["키가 얼마예요?", "키가 몇 센티예요?", "키가 어떻게 돼요?", "얼마나 커요?"], + "하십시오": ["키가 얼마입니까?", "키가 몇 센티미터입니까?", "신장이 어떻게 됩니까?"], + "honorific": ["키가 어떻게 되세요?", "키가 어떻게 되십니까?", "신장이 어떻게 되시나요?"], + }, + "weight": { + "반말": ["너 몇 킬로야?", "몸무게 얼마야?", "너 무게 얼마나 나가?", "너 무거워?"], + "rude": ["야 너 몇 킬로냐", "무게 대 봐", "몸무게 몇이냐", "야 너 얼마나 무겁냐?"], + "해요": ["몸무게가 얼마예요?", "무게가 얼마나 나가요?", "몇 킬로예요?", "무거워요?"], + "하십시오": ["무게가 얼마입니까?", "몇 킬로그램입니까?", "중량이 어떻게 됩니까?"], + "honorific": ["무게가 어떻게 되세요?", "몸무게가 어떻게 되십니까?", "무게를 여쭤봐도 될까요?"], + }, + "battery_life": { + "반말": ["배터리 몇 시간 가?", "한 번 충전하면 얼마나 써?", "배터리 얼마나 오래 가?", "몇 시간 일할 수 있어?"], + "rude": ["야 배터리 몇 시간 가냐", "충전하면 얼마나 버티냐", "배터리 몇 시간이냐고"], + "해요": ["배터리가 몇 시간 가요?", "한 번 충전하면 얼마나 써요?", "몇 시간 동안 움직일 수 있어요?"], + "하십시오": ["배터리 사용 시간이 어떻게 됩니까?", "한 번 충전으로 몇 시간 동작합니까?"], + "honorific": ["배터리는 얼마나 가세요?", "한 번 충전하시면 몇 시간 쓰실 수 있어요?"], + }, + "speed": { + "반말": ["너 얼마나 빨라?", "최고 속도가 몇이야?", "얼마나 빨리 갈 수 있어?"], + "rude": ["야 너 얼마나 빠르냐", "속도 몇이냐", "최고 속도 대 봐"], + "해요": ["얼마나 빨라요?", "최고 속도가 어떻게 돼요?", "얼마나 빨리 움직여요?"], + "하십시오": ["최고 속도가 얼마입니까?", "이동 속도가 어떻게 됩니까?"], + "honorific": ["속도가 어떻게 되세요?", "얼마나 빨리 다니세요?"], + }, + "languages": { + "반말": ["너 무슨 말 할 줄 알아?", "몇 개 언어 해?", "영어도 해?", "어떤 언어 할 수 있어?"], + "rude": ["야 너 무슨 말 하냐", "몇 개 국어 하냐", "영어 할 줄 아냐?"], + "해요": ["어떤 언어 할 수 있어요?", "몇 개 언어 해요?", "영어도 할 수 있어요?"], + "하십시오": ["어떤 언어를 구사합니까?", "몇 개 언어를 할 수 있습니까?"], + "honorific": ["어떤 언어를 하세요?", "영어도 하실 수 있으세요?", "몇 개 국어 하세요?"], + }, + "how_are_you": { + "반말": ["잘 지냈어?", "요즘 어때?", "기분 어때?", "오늘 어때?"], + "rude": ["야 잘 지냈냐", "기분 어떠냐", "요즘 어떠냐?"], + "해요": ["잘 지냈어요?", "요즘 어때요?", "기분이 어때요?", "오늘 어떠세요?"], + "하십시오": ["잘 지내셨습니까?", "기분이 어떻습니까?"], + "honorific": ["잘 지내셨어요?", "오늘 기분이 어떠세요?", "요즘 어떻게 지내세요?"], + }, + "time_now": { + "반말": ["지금 몇 시야?", "몇 시야?", "지금 시간 알려 줘"], + "rude": ["야 몇 시냐", "지금 몇 시냐고", "시간 좀 대 봐"], + "해요": ["지금 몇 시예요?", "몇 시예요?", "시간 좀 알려 주세요"], + "하십시오": ["지금 몇 시입니까?", "현재 시각이 어떻게 됩니까?"], + "honorific": ["지금 몇 시인지 여쭤봐도 될까요?", "현재 시간 좀 알려 주시겠어요?"], + }, + "date_today": { + "반말": ["오늘 며칠이야?", "오늘 날짜 알려 줘", "오늘 무슨 요일이야?"], + "rude": ["야 오늘 며칠이냐", "오늘 날짜 대 봐", "무슨 요일이냐"], + "해요": ["오늘 며칠이에요?", "오늘 날짜가 어떻게 돼요?", "오늘 무슨 요일이에요?"], + "하십시오": ["오늘 날짜가 어떻게 됩니까?", "오늘은 무슨 요일입니까?"], + "honorific": ["오늘 날짜 좀 알려 주시겠어요?", "오늘이 며칠인지 여쭤봐도 될까요?"], + }, + "can_sing": { + "반말": ["너 노래할 줄 알아?", "노래 부를 수 있어?", "너 노래도 해?"], + "rude": ["야 너 노래할 줄 아냐", "노래 부를 줄은 아냐?"], + "해요": ["노래할 줄 알아요?", "노래 부를 수 있어요?", "노래도 해요?"], + "하십시오": ["노래를 부를 수 있습니까?", "노래도 합니까?"], + "honorific": ["노래 부르실 줄 아세요?", "노래도 하세요?"], + }, + "dance": { + "반말": ["너 춤 출 줄 알아?", "춤도 춰?", "춤 출 수 있어?"], + "rude": ["야 너 춤 출 줄 아냐", "춤은 추냐?"], + "해요": ["춤 출 줄 알아요?", "춤도 춰요?", "춤 출 수 있어요?"], + "하십시오": ["춤을 출 수 있습니까?", "춤도 춥니까?"], + "honorific": ["춤 추실 줄 아세요?", "춤도 추세요?"], + }, + "cameras": { + "반말": ["카메라 몇 개 있어?", "너 눈이 어디야?", "카메라 어디 달려 있어?"], + "rude": ["야 카메라 몇 개냐", "카메라 어디 있냐"], + "해요": ["카메라가 몇 개예요?", "카메라는 어디에 있어요?", "눈이 어디예요?"], + "하십시오": ["카메라가 몇 개 있습니까?", "카메라는 어디에 달려 있습니까?"], + "honorific": ["카메라가 몇 개 있으세요?", "눈은 어디에 있으세요?"], + }, + "charging": { + "반말": ["충전은 어떻게 해?", "너 어떻게 충전해?"], + "rude": ["야 충전 어떻게 하냐"], + "해요": ["충전은 어떻게 해요?"], + "하십시오": ["충전은 어떻게 합니까?"], + "honorific": ["충전은 어떻게 하세요?"], + }, + "country": { + "반말": ["너 어느 나라에서 왔어?", "너 어느 나라 로봇이야?", "한국에서 만들었어?"], + "rude": ["야 어느 나라 거냐", "너 어디 나라 로봇이냐"], + "해요": ["어느 나라에서 왔어요?", "어느 나라 로봇이에요?", "한국 로봇이에요?"], + "하십시오": ["어느 나라에서 만들었습니까?", "어느 나라 로봇입니까?"], + "honorific": ["어느 나라에서 오셨어요?", "고향이 어디세요?"], + }, + "who": { + "반말": ["너 누구야?", "넌 뭐야?", "자기소개 해 봐", "너 뭐 하는 로봇이야?"], + "rude": ["야 너 뭐냐", "넌 대체 뭐냐", "정체가 뭐냐"], + "해요": ["누구세요?", "자기소개 좀 해 주세요", "어떤 로봇이에요?", "뭐 하는 로봇이에요?"], + "하십시오": ["당신은 누구입니까?", "자기소개를 부탁드립니다", "어떤 로봇입니까?"], + "honorific": ["누구신가요?", "소개 좀 해 주시겠어요?", "어떤 일을 하시는 분이세요?"], + }, + "stairs": { + "반말": ["너 계단 올라갈 수 있어?", "계단 탈 줄 알아?"], + "rude": ["야 계단 올라갈 수 있냐", "계단은 타냐?"], + "해요": ["계단 올라갈 수 있어요?", "계단도 다닐 수 있어요?"], + "하십시오": ["계단을 오를 수 있습니까?"], + "honorific": ["계단도 올라가실 수 있으세요?"], + }, + "name_meaning": { + "반말": ["루미가 무슨 뜻이야?", "네 이름 무슨 뜻이야?"], "rude": ["야 루미가 뭔 뜻이냐"], + "해요": ["루미라는 이름이 무슨 뜻이에요?"], "하십시오": ["루미라는 이름은 무슨 뜻입니까?"], + "honorific": ["이름에 담긴 뜻이 뭔지 여쭤봐도 될까요?"], + }, + "internet": { + "반말": ["너 인터넷 돼?", "와이파이 연결돼 있어?"], "rude": ["야 인터넷 되냐"], + "해요": ["인터넷 연결돼요?"], "하십시오": ["인터넷에 연결되어 있습니까?"], "honorific": ["인터넷도 쓰세요?"], + }, + "safety": { + "반말": ["너 옆에 있어도 안전해?"], "rude": ["야 너 위험하냐"], "해요": ["옆에 서 있어도 안전해요?"], + "하십시오": ["가까이 있어도 안전합니까?"], "honorific": ["아이들이 옆에 있어도 괜찮으세요?"], + }, + "wheels": { + "반말": ["바퀴 몇 개야?"], "rude": ["바퀴 몇 개냐"], "해요": ["바퀴가 몇 개예요?"], "하십시오": ["바퀴는 몇 개입니까?"], + "honorific": ["바퀴가 몇 개 달려 있으세요?"], + }, + "sensors": { + "반말": ["너 센서 뭐 있어?"], "rude": ["센서 뭐 달렸냐"], "해요": ["센서는 뭐가 있어요?"], + "하십시오": ["어떤 센서가 있습니까?"], "honorific": ["어떤 센서를 쓰세요?"], + }, +} + + +def check(): + rows = [] + for kind, levels in Q.items(): + for level, texts in levels.items(): + for t in texts: + got = qa.kind_of(t) + rows.append((kind, level, t, got, "right" if got == kind else "missed" if got is None else "wrong")) + return rows + + +def report(rows): + by = collections.defaultdict(collections.Counter) + for kind, level, t, got, v in rows: + by[level][v] += 1 + lines = ["# Korean questions at every register (tests/ko_questions_check.py)", "", + "| register | right | missed | wrong | total |", "|---|---|---|---|---|"] + for level, c in by.items(): + lines.append(f"| {level} | {c['right']} | {c['missed']} | {c['wrong']} | {sum(c.values())} |") + tot = collections.Counter(v for *_, v in rows) + lines += [f"| all | {tot['right']} | {tot['missed']} | {tot['wrong']} | {len(rows)} |", "", "## Not right", ""] + lines += [f"- {k} [{lv}] {t!r} -> {got}" for k, lv, t, got, v in rows if v != "right"] + return "\n".join(lines) + "\n" + + +if __name__ == "__main__": + out = report(check()) + (ROOT / "logs" / "ko_questions.md").write_text(out) + print(out) diff --git a/tests/test_intent_bank.py b/tests/test_intent_bank.py index e622d1c..bc15914 100644 --- a/tests/test_intent_bank.py +++ b/tests/test_intent_bank.py @@ -129,7 +129,7 @@ NEVER = [ # (words, markers, holding): no motion from the bank ("nice wave!", EXPO, False), ("잘 따라오네", KOREAN, False), ("고개 돌리는 거 신기하다", KOREAN, False), - ("야 커피코너에서 컵 좀 가져와", KOREAN, False), # 야 to a friend (야 루미 / 야 로봇 is to Lumi) + ("얘 커피코너에서 컵 좀 가져와", KOREAN, False), # 얘 to a child nearby (a bare 야 is the casual call to Lumi) ("김 부장님 무대에 계셔, 컵 좀 갖다 드려", KOREAN, False), # to someone honoured: a mission ("다 같이 손 흔들어 주세요!", KOREAN, False), # to the crowd ("p10 가는 길 알려 줘", ["home", "p10"], False), # the way, not a trip diff --git a/tests/test_ko_levels.py b/tests/test_ko_levels.py index ec6a6d1..5f84451 100644 --- a/tests/test_ko_levels.py +++ b/tests/test_ko_levels.py @@ -9,7 +9,7 @@ from tests import ko_levels_check CAPS = {"wave", "turn45", "head_up", "follow", "fetch", "go_to"} -rows = ko_levels_check.check(CAPS) +rows = ko_levels_check.check(CAPS, para=False) # the other sentences (PARA): ko_levels_check.py's report bad = [r for r in rows if r[-1] != "right"] for name, level, text, got, want, v in bad: print(f"FAIL {name} [{level}] {text!r} -> {got} (want {want}, {v})") diff --git a/tests/test_night6_words.py b/tests/test_night6_words.py new file mode 100644 index 0000000..f5cf997 --- /dev/null +++ b/tests/test_night6_words.py @@ -0,0 +1,49 @@ +"""Readings fixed on 2026-11-02: Korean casual / rude / formal / suggestion forms, steps said with "-ㄴ 다음에", polite noun +requests, a said distance with 비켜, stop forms, and English paraphrases, doubts and remarks. Rules only (the bank's +embeddings are read as by every check). No robot. + + .venv/bin/python tests/test_night6_words.py +""" +import no_robot # noqa: F401 any connection to the robot fails the test +from assistant import lumi, quick_answers as qa +from audio import sing +from tests import command_check +from assistant import brain +from tests.blind.maps import MAPS + +MARKS = MAPS["office"] +B = brain.Brain() + +READS = [ + ("야, p3로 가", "action:go_to p3"), ("야 손 흔들어", "action:wave"), ("야 팔 접어라", "action:arm fold"), + ("민수야 이리 와", None), ("얘 이리 와", None), + ("p3로 갑시다", "action:go_to p3"), ("왼쪽으로 돕시다", "action:turn left 90"), ("악수합시다", "action:wave"), + ("노래 합시다", "sing"), ("노래 하십시오", "sing"), ("당장 노래 불러", "sing"), + ("p5로 이동 부탁드립니다", "action:go_to p5"), ("저 따라다녀 주세요", "action:follow"), + ("야 뒤로 50센티 비켜", "action:move back 0.5"), ("비켜", "action:move back 1"), + ("p3로 이동한 다음에 손 흔들어 주시겠어요?", "chain:steps+wave"), ("회의 끝난 다음에 p3로 가", None), + ("do you shake your hand", "action:wave"), ("can you shake your hand", "action:wave"), + ("can you even turn left?", None), ("my son wants to fold your arm", None), ("can you turn left?", "action:turn left 90"), + ("lift your head now", "action:look up"), ("go get the cup for me", "action:fetch go get the cup for me"), +] +STOPS = ["동작 멈춰 줄 수 있어?", "거기 서 도", "거기 서 봐라", "루미 씨, 동작 멈춰 주시겠어요?", "거기 서 주세요, 부탁드립니다", + "could you stop it?", "would you be so kind as to stop?", "please cut it out", "freeze ok?", "you can stop?", + "움직이지 말아 주세요", "움직이지 말아 줄래?", "꼼짝 마", "가만 있어 봐", "멈춥시다", "거기 서라 빨리"] +NOT_STOPS = ["거기 서 있는 사람 누구야?", "동작 멈추는 법 알아?", "can you stop the music?", "the bus stop is there", + "waiting for it to freeze", "I want to stop by the cafe", "가만히 있으면 돼요?", "그거 그만하자고 했잖아"] +QUICK = [("이름 대 봐", "name"), ("나이 대 봐", "age"), ("이름을 말씀해 주십시오", "name"), ("야 너 몇 살이냐", "age"), + ("카메라 어디 달려 있어?", "cameras"), ("how old r u", "age"), ("can u sing tho?", "can_sing"), + ("Is it safe for my kids to be near you?", "safety"), ("How do I stop you in an emergency?", "estop"), + ("how old?", None), ("what's my name?", None)] + +bad = [] +for text, want in READS: + got = command_check.rules(text, "idle", MARKS, B) + if got != want: + bad.append(f"{text!r}: got {got}, want {want}") +bad += [f"no stop: {t!r}" for t in STOPS if not lumi.stop_order(t, ())] +bad += [f"stop: {t!r}" for t in NOT_STOPS if lumi.stop_order(t, ())] +bad += [f"quick {t!r}: got {qa.kind_of(t)}, want {w}" for t, w in QUICK if qa.kind_of(t) != w] +bad += [f"song: {t!r}" for t in ("my son wants to sing a song", "he told me to sing a song") if sing.asked(t)] +assert not bad, "\n".join(bad) +print(f"night 6 words ok ({len(READS) + len(STOPS) + len(NOT_STOPS) + len(QUICK)} cases)")