diff --git a/.gitignore b/.gitignore index b449260..d4594ec 100644 --- a/.gitignore +++ b/.gitignore @@ -56,3 +56,7 @@ data/memory/ tests/blind/r6/ tests/blind/r8/ .claude/ +docs/night3/ +docs/night4/ +tests/blind/r9/ +tests/blind/r10/ diff --git a/assistant/bank_words/korean.py b/assistant/bank_words/korean.py index ff19a65..7ba7b70 100644 --- a/assistant/bank_words/korean.py +++ b/assistant/bank_words/korean.py @@ -99,6 +99,89 @@ INTENT = { ], } +# ---------- grown wordings (night 3): each kind's nouns x softeners x verbs, a fixed sample per kind ---------- +import itertools as _it +import random as _random + +_SOFT = ["", "좀 ", "빨리 ", "얼른 ", "천천히 ", "지금 ", "바로 ", "한번 ", "어서 ", "퍼뜩 ", "살살 ", "후딱 "] +_CALL = [""] # calls ("루미야", "자") are cut before the bank compares (intent_bank.core): none stored + + +def _grow(kind, parts, n, seed=3): + """n wordings of the product of `parts` (lists of strings joined as they are), the same sample every run.""" + combos = [" ".join("".join(c).split()) for c in _it.product(*parts)] + combos = list(dict.fromkeys(combos)) + _random.Random(f"{kind}{seed}").shuffle(combos) + return combos[:n] + + +GROWN = { + "go_to": _grow("go_to", [_CALL, ["로 ", " 쪽으로 ", "까지 ", "에 ", " 방향으로 ", + " 있는 데로 ", " 있는 곳으로 "], _SOFT, + ["가", "이동해", "출발해", "가 봐", "가 보자", "달려가", "향해 가", "움직여", "옮겨 가", + "가 줘", "이동 좀 해 줘", "가 볼래?", "가 줄래?"]], 500), + "come": _grow("come", [_CALL, _SOFT, ["이리 ", "일로 ", "여기로 ", "이쪽으로 ", "나한테 ", "저한테 ", "제 쪽으로 ", + "내 앞으로 ", "제 앞으로 ", "가까이 ", "내 옆으로 ", "제 옆으로 ", "요기로 ", + "여기까지 ", "우리 쪽으로 ", "저희 쪽으로 "], + ["와", "와 봐", "다가와", "와 줘", "와 볼래?", "와라", "와 줄래?", "와 주라", "다가와 줘"]], 350), + "follow": _grow("follow", [_CALL, ["", "나 ", "날 ", "저 ", "절 ", "저를 ", "나를 ", "제 뒤를 ", "내 뒤를 ", "우리 ", + "우리를 ", "저희를 "], + ["", "잘 ", "천천히 ", "바짝 ", "계속 ", "졸졸 ", "놓치지 말고 ", "뒤에서 ", "좀 "], + ["따라와", "따라와 봐", "쫓아와", "따라다녀", "따라붙어", "따라와 줘", "따라와 줄래?", + "따라오너라", "따라 걸어"]], 350), + "come_back": _grow("come_back", [_CALL, ["원래 자리로 ", "제자리로 ", "아까 그 자리로 ", "처음 위치로 ", + "출발했던 곳으로 ", "원위치로 ", "아까 있던 곳으로 ", "원래 있던 데로 "], + ["", "다시 ", "좀 ", "얼른 "], ["돌아와", "돌아가", "복귀해", "와", "돌아와 줘"]], 200), + "move": _grow("move", [_CALL, ["앞으로 ", "뒤로 ", "왼쪽으로 ", "오른쪽으로 ", "좌측으로 ", "우측으로 "], + ["", "1 meter ", "조금 ", "살짝 ", "한 걸음 ", "한 발짝 ", "약간 ", "쪼금 ", "조금만 "], + ["가", "이동해", "움직여", "가 줘", "이동해 줘", "가 봐", "가 볼래?"]], 400), + "turn": _grow("turn", [_CALL, ["왼쪽으로 ", "오른쪽으로 ", "좌측으로 ", "우측으로 "], + ["", "90 degrees ", "조금 ", "살짝 ", "약간 ", "몸을 ", "몸 "], + ["돌아", "회전해", "틀어", "꺾어", "돌아서", "돌아 줘", "회전해 줘", "돌아 볼래?"]], 350), + "look": _grow("look", [_CALL, ["위 ", "위쪽 ", "아래 ", "아래쪽 ", "왼쪽 ", "오른쪽 ", "천장 ", "바닥 ", "하늘 ", + "정면 ", "저 ", "나 ", "여기 ", "이쪽 ", "저쪽 ", "제 얼굴 ", "내 얼굴 ", "위를 ", + "아래를 ", "왼쪽을 ", "오른쪽을 ", "저를 ", "나를 "], + ["", "좀 ", "잠깐 ", "한번 ", "살짝 "], ["봐", "쳐다봐", "바라봐", "봐 줘", "봐 줄래?", "봐 봐"]], 450) + + _grow("look2", [_CALL, ["고개 ", "고개를 ", "머리 ", "머리를 ", "얼굴 "], ["", "좀 ", "살짝 ", "조금 "], + ["들어", "숙여", "올려", "내려", "왼쪽으로 돌려", "오른쪽으로 돌려", "들어 줘", "숙여 줘", + "위로 들어", "아래로 숙여"]], 250), + "lift": _grow("lift", [_CALL, ["몸 ", "몸을 ", "키 ", "키를 ", "몸통 ", "상체 ", "리프트 ", "리프트를 "], + ["", "좀 ", "조금 ", "살짝 ", "더 ", "쭉 ", "1 meter "], + ["올려", "높여", "내려", "낮춰", "키워", "올려 줘", "내려 줘", "높여 줘", "낮춰 줘"]], 400), + "wave": _grow("wave", [_CALL, ["", "저한테 ", "우리한테 ", "애들한테 ", "손님한테 ", "여기 ", "사람들한테 ", "나한테 "], + ["손 ", "손을 ", "팔 ", "한 손 ", "손 좀 "], ["", "한번 ", "크게 ", "힘차게 ", "반갑게 ", "살살 "], + ["흔들어", "흔들어 봐", "흔들어 줘", "흔들어 인사해", "흔들어 줄래?"]], 350) + + _grow("wave2", [_CALL, ["", "나랑 ", "저랑 ", "우리 "], ["악수하자", "악수해", "악수 한 번 하자", "악수 좀 해", + "악수 해 줘", "악수할래?", "악수해 볼까?"]], 60), + "arm_reach": _grow("arm_reach", [_CALL, ["손 ", "손을 ", "팔 ", "팔을 ", "오른손 ", "한 손 "], ["", "좀 ", "앞으로 ", + "쭉 ", "이리 ", "나한테 "], + ["내밀어", "뻗어", "내밀어 줘", "뻗어 줘", "내밀어 봐", "내밀어 줄래?"]], 250) + + _grow("arm_reach2", [_CALL, ["", "나한테 ", "저한테 ", "이리 "], ["손 줘", "손 좀 줘", "손 이리 줘", + "손 내놔", "손 한번 줘"]], 40), + "arm_fold": _grow("arm_fold", [_CALL, ["팔 ", "팔을 ", "손 ", "손을 "], ["", "좀 ", "다시 ", "이제 ", "얼른 "], + ["접어", "거둬", "집어넣어", "내려", "원위치 해", "넣어", "치워", "접어 줘", "내려 줘"]], 200), + "arm_open": _grow("arm_open", [_CALL, ["손 ", "손을 ", "손가락 ", "그리퍼 ", "집게 ", "그리퍼를 ", "집게를 "], + ["", "좀 ", "쫙 ", "활짝 "], ["펴", "펼쳐", "벌려", "열어", "펴 줘", "열어 줘", "벌려 줘"]], 150), + "arm_close": _grow("arm_close", [_CALL, ["주먹 ", "그리퍼 ", "집게 ", "그리퍼를 ", "집게를 ", "손가락 ", "손 ", "손을 "], + ["", "좀 ", "꽉 ", "살짝 "], ["쥐어", "오므려", "닫아", "쥐어 줘", "닫아 줘", "모아"]], 150), + "pick": _grow("pick", [_CALL, [" ", " 좀 ", "그 ", "저 ", "이 ", "앞에 있는 ", + "테이블 위 ", " 하나 "], + ["집어", "잡아", "들어", "집어 들어", "들어 올려", "집어 줘", "잡아 줘", "집어 봐", "픽업 해"]], 350), + "fetch": _grow("fetch", [_CALL, ["", "나한테 ", "저한테 ", "여기로 ", "이리 "], [" ", "그 ", " 하나 ", + " 좀 "], + ["가져와", "갖다 줘", "가져다 줘", "갖고 와", "가지고 와", "챙겨 와", "가져와 줘", "가져와 줄래?"]], + 350), +} +for _k, _t in GROWN.items(): + INTENT[_k] = INTENT.get(_k, []) + _t + +# "no": the same verbs said about Lumi, to someone else or as a wish for another time; the guards catch most, these +# keep the bank's margin where they don't +INTENT["no"] += _grow("no", [["우리 애가 ", "아까 ", "어제 ", "저 로봇 ", "옆 로봇이 ", "그 로봇은 "], + ["손 흔드는 거 ", "따라오는 거 ", "고개 숙이는 거 ", "팔 뻗는 거 ", "왼쪽으로 도는 거 ", + "앞으로 가는 거 ", "컵 집는 거 ", "키 높이는 거 "], + ["봤어", "귀엽더라", "신기했어", "좋아해", "무서워해", "재밌었어"]], 200) + QUICK = { "name": ["이름이 뭐꼬", "니 이름이 뭐고", "이름이 뭐여", "이름이 뭐당가", "이름 뭐예요", "이름이 머예요", "성함이 어떻게 되십니까", "이름 좀 알려 줘", "이름 알려 주세요", "네임 뭐야", "너 이름 뭐니", "이름이 어떻게 되니", "로봇 이름이 뭐야"], @@ -114,3 +197,33 @@ QUICK = { "안냥", "하이루"], "how_are_you": ["잘 지냈나", "별일 없제", "기분 어떠세요", "컨디션 어때", "잘 있었어"], } + + +def _ask(stems, ends): + """A question at every speech level: each stem with each ending ("이름이 " + "뭐야" / "뭐예요" / "무엇입니까").""" + return [s + e for s in stems for e in ends] + + +_WHAT = ["뭐야", "뭐예요", "뭐에요", "무엇입니까", "뭐니", "뭐냐", "뭐여", "뭐꼬", "뭐고", "뭔데", "뭐죠", "뭐신가요", + "어떻게 돼", "어떻게 돼요", "어떻게 되세요", "어떻게 되십니까", "뭐라고 해요", "뭐라고 불러요"] +_HOW_OLD = ["몇 살이야", "몇 살이에요", "몇 살입니까", "몇 살이니", "몇 살이냐", "몇 살이여", "몇 살이고", "몇 살이세요", + "몇이야", "몇이에요", "얼마나 됐어", "얼마나 됐어요", "얼마나 되셨어요", "얼마나 되었습니까"] +QUICK["name"] += _ask(["이름이 ", "너 이름이 ", "니 이름이 ", "루미 이름이 ", "당신 이름이 ", "로봇 이름이 ", "성함이 "], + _WHAT) +QUICK["age"] += _ask(["", "너 ", "루미 ", "로봇 ", "당신 ", "나이가 ", "너 나이가 "], _HOW_OLD[:9]) + \ + _ask(["만들어진 지 ", "태어난 지 ", "나온 지 "], _HOW_OLD[10:]) +QUICK["maker"] += _ask(["누가 ", "어느 회사가 ", "어디서 ", "어떤 회사가 "], + ["만들었어", "만들었어요", "만들었습니까", "만들었니", "만들었냐", "만들었노", "만들었대", "만드셨어요", + "개발했어", "개발했어요", "개발했습니까", "개발하셨어요"]) +QUICK["who"] += _ask(["너 ", "넌 ", "당신 ", "루미 ", "이 로봇 ", "너는 "], + ["누구야", "누구예요", "누구입니까", "누구니", "누구냐", "누구여", "누꼬", "뭐야", "뭐예요", "뭐하는 애야", + "뭐 하는 로봇이에요", "뭐 하는 로봇입니까", "누구세요", "정체가 뭐야"]) +QUICK["time_now"] = QUICK.get("time_now", []) + _ask(["지금 ", "", "혹시 지금 "], + ["몇 시야", "몇 시예요", "몇 시입니까", "몇 시니", "몇 시냐", "몇 시여", + "몇 시고", "몇 시죠", "몇 시쯤 됐어", "몇 시 됐어요", "몇 시인지 알아요", + "몇 시인지 알려 줘", "몇 시인지 알려 주세요", "몇 시인지 아세요"]) +QUICK["no"] = QUICK.get("no", []) + [ + "잠깐만 시간 좀 줘", "시간 좀 줘", "시간 좀 주세요", "생각할 시간 좀 줘", "잠깐 시간 좀 내 줄래", "시간 있어", "시간 있어요", + "시간 괜찮아요", "시간 돼요", "give me a second", "give me a minute", "give me some time", "do you have time", + "이름 지어 줄까", "내 이름은 민수야", "제 이름 기억해요", "우리 애 몇 살 같아요", "제가 몇 살 같아요", "나 몇 살로 보여", + "누가 이겼어", "누가 더 빨라", "몇 시에 끝나요", "몇 시에 시작해요"] diff --git a/assistant/brain.py b/assistant/brain.py index e8b1d27..b02a3bc 100644 --- a/assistant/brain.py +++ b/assistant/brain.py @@ -59,7 +59,10 @@ Rules: you don't know, or that you can't, and why) with the action none. - If you do not know a fact about the world (people, places, events, products, prices, sports, news, anything after your training), do not guess: choose the action "search" so it is looked up on the internet. Well-known - general knowledge (what a robot or AI is, science, history, geography) and opinions you answer yourself. + general knowledge (what a robot or AI is, science, history, geography) and opinions you answer yourself: settled + facts that do not change (a mountain's height, a building's floors, how many bones, how long a marathon is, who + painted or invented something, when a war or an Olympics was, what an animal eats, why the sky is blue) are + answered at once, never searched; search what changes or is new (news, prices, today's scores, schedules). - For facts about yourself and Cutshion Company use ONLY the reference notes. Only if the notes do not contain the answer, say you are not sure. Never say you were made or developed by any other company. - The company's Korean name is 쿳션 (주식회사 쿳션); never write 컷션 or 커션. @@ -291,19 +294,26 @@ SAID_BEFORE = re.compile(r"\byou said\b|\bearlier you\b|\byou told me\b|아까 FOLLOW_EXAMPLES_K = 2 # follow-up examples (talk_examples.FOLLOWUPS) shown with a short follow-up +LUMI_TOPIC = re.compile(r"\b(?:you|your|yourself|lumi|robots?|arm|gripper|battery|cameras?|lidar|base|wheels?|lift|" + r"jaka|cutshion|company|ceo|gemma|whisper|jetson|thor)\b|너|네가|니가|넌|루미|당신|로봇|팔|그리퍼|" + r"배터리|카메라|라이다|바퀴|리프트|자카|쿳션|회사|대표|젬마|위스퍼|젯슨", re.I) + # a talk about Lumi, its parts or the companies: the notes stay with its follow-ups + + def _follow_examples(text, history): """For a short follow-up on the last answer ("why?", "and then?", "진짜?", "그게 무슨 말이야?"): two small talks where such words were answered about the answer before them, so the model keeps the topic and answers at once.""" asked = bool(history) and history[-1][1].rstrip().endswith("?") and confirm_answer(text) is not None # "네" to - if not history or len(text.split()) > 7 or is_backchannel(text) and not ABOUT_ANSWER.match(text) and not asked: + c = core(text) # "음 루미아, 정말요?" asks what "정말요?" asks + if not history or len(c.split()) > 7 or is_backchannel(c) and not about_answer(text) and not asked: return "" # "더 알려 드릴까요?": do what was offered - if not (asked or ABOUT_ANSWER.match(text) or AND_ALSO.match(text) or FOLLOW_UP.search(text) or SAID_BEFORE.search(text) or - SHORT_Q.search(text) and len(text.split()) <= FRAGMENT_WORDS and not re.search(r"\d", text) and - not ABOUT_YOU.search(text) and (NAMED_BEFORE.search(text) or REFERS_BACK.search(text) or - len(text.strip(" ?!.~")) <= (6 if HANGUL.search(text) else 10))): + if not (asked or about_answer(text) or AND_ALSO.match(c) or FOLLOW_UP.search(c) or SAID_BEFORE.search(text) or + SHORT_Q.search(c) and len(c.split()) <= FRAGMENT_WORDS and not re.search(r"\d", c) and + not ABOUT_YOU.search(c) and (NAMED_BEFORE.search(c) or REFERS_BACK.search(c) or + 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] + q, a = history[-1] if asked else topic_turn(history) a = " ".join(ln for ln in a.splitlines() if not re.match(r"\s*\**ACTION", ln)).strip() if not a: return "" @@ -483,7 +493,8 @@ OBJECTS = {"cup": "cup", "mug": "cup", "glass": "cup", "tumbler": "cup", "bottle "화분": "potted plant", "clock": "clock", "handbag": "handbag", "purse": "handbag", "핸드백": "handbag", "backpack": "backpack", "백팩": "backpack", "suitcase": "suitcase", "캐리어": "suitcase", "여행가방": "suitcase", "hair dryer": "hair drier", "hair drier": "hair drier", "드라이기": "hair drier", "toaster": "toaster", - "토스터": "toaster"} + "토스터": "toaster", "보틀": "bottle", "물컵": "cup", "유리컵": "cup", "머그잔": "cup", + "글라스": "cup"} # spoken word -> camera class; the classes are skills.GRASPS (tests/test_intents.py checks it): a pick of one the # fingers can't take gets its reason (skills.refusal). Not here on purpose: umbrella / 우산 (weather words), 책 (책상) _KO_WORD = {"공", "칼"} # one syllable inside other words (공항, 칼국수): only as a word of its own @@ -632,8 +643,9 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said ("look_away", r"\b(?:look away|look somewhere else|look elsewhere|look the other way|stop (?:looking|staring)(?: at me)?|" r"stop watching me|quit watching me|" r"(?:don'?t|do not|please don'?t) (?:look|stare) at me|quit (?:staring|looking))\b|(?:쳐다|바라)보지 ?마|" - r"그만 ?(?:좀 ?)?(?:쳐다|바라)(?:봐|보세요|보십시오|봐요|봐 ?줘|봐 ?주세요)|" - r"(?:날|나를?|저를?|절)\s*(?:좀\s*)?그만\s*(?:봐|보세요|봐요|쳐다봐)|" + r"그만 ?(?:좀 ?)?(?:쳐다|바라)(?:봐|보세요|보십시오|보시게|봐라|봐요|봐 ?줘|봐 ?주세요)|" + r"(?:날|나를?|저를?|절)\s*(?:좀\s*)?그만\s*(?:봐|보세요|봐요|쳐다봐)|(?:^|[\s,—–-])그만\s*(?:좀\s*)?(?:봐|보세요|봐요|보시게|봐라|" + r"보십시오)\W*$|" r"(?:날|나를?|저를?|절)\s*(?:좀\s*)?(?:보지|쳐다보지) ?마|다른 ?(?:데|곳|쪽)(?:을|를)? ?(?:좀 )?봐"), ("stop", r"\b(stop|halt|freeze|don'?t move)\b|멈춰|정지|그만 ?가|거기 ?서(?=[\s!.~,]*$)|스톱|움직이지 ?마|^\s*(서[\s,!.]*){2,}$"), ("waist", r"\b(?:turn|rotate|twist|swivel|swing|move|bring|point|face|put)\b[^.?!]{0,25}\b(?:your |the )?(?:waist|upper body|" @@ -716,7 +728,7 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said + LET_GO), ("grip_close", r"\b(close (your |the )?(hand|gripper|fingers|claw)|close it|make a fist|clench (your )?(fist|hand)|grab (it|this)|grip (it|this)|" r"hand closed?|squeeze (your )?(hand|fingers)( shut)?)\b|^\W*grip\W*$" - r"|손을? ?(?:꽉 |좀 )*(쥐|오므려|닫아)|\bclose\s*해\s*손|손가락\s*(?:을\s*)?(?:좀\s*|한번\s*|다\s*)*모아|주먹 ?(을 )?쥐|잡아(?!먹|당)|손 ?close|(그리퍼|집게)(를|을)? ?(좀 )?(닫아|오므려)"), + r"|손을? ?(?:꽉 |좀 )*(쥐|오므려|닫아)|\bclose\s*해\s*손|손가락\s*(?:을\s*)?(?:좀\s*|한번\s*|다\s*)*모아|주먹 ?(을 )?쥐|잡아(?!먹|당| ?보자| ?봐도| ?볼래)|손 ?close|(그리퍼|집게)(를|을)? ?(좀 )?(닫아|오므려)"), ("arm", r"\b(reach out(?! to (?!me\b))|stretch (out )?your (arm|hand)|put your (arm|hand) (out|forward)|hand forward|" r"hold out your (arm|hand|gripper|claw|fingers)|extend your (arm|hand|gripper)|give me your hand|offer me your hand|" r"give me (?:a|ur|you) hand(?!\s+(?:with|to|for|in|on|carrying|moving|lifting)\b)|" @@ -731,13 +743,16 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said r"\bgive hand\b|\bhand 이쪽|손을? ?(?:좀 |쭉 )+(?:내밀|뻗)" r"|\bhand back\b(?=\s*(?:해|하|ㄱ))|기본 ?(?:pose|포즈|자세|위치)\s*(?:로|으로)|\bwithdraw (?:your |the )?(?:hand|arm)\b|" r"\bretract (?:your |the )?(?:arm|hand)\b|\barm back to normal\b|\barm (?:back )?home\b|\bbring (?:the |your )?arm (?:home|back)\b|\bback to (?:your |the )?look pose\b|" - r"\byou can fold it\b|^\W*(?:이제\s*)?접어|손 ?(?:을 )?다시 넣어|^\W*(?:됐어\W*)?넣어\W*$|팔 ?(?:을 )?(?:원래대로|제자리로|다시 넣어|넣어)"), + r"\byou can fold it\b|^\W*(?:이제\s*)?접어|손 ?(?:을 )?(?:좀 |다시 |이제 )*넣(?:어|으)|" + r"손 ?(?:을 )?(?:좀 |쫌 |한번 |한 번 )*잡(?:—\s*잡)?아 ?(?:보자|봐도|볼래|봐야지|보고 ?싶)|\blet me (?:hold|shake|touch) your hand\b|" + r"(?:^|[\s,.])(? "wave" on every path if re.search(r"\b(?:say|tell|announce)\b|말해|(? 'go to the stage': fillers inside the words and the word said twice around them.""" - t = re.sub(r" {2,}", " ", FILLER_IN.sub(" ", wording.now_not_later(t))).strip() # "now, not later": no later time + t = re.sub(r" {2,}", " ", FILLER_IN.sub(" ", wording.polite(wording.now_not_later(t)))).strip() # "now, not later": no + # later time; "wave, if you don't mind": no condition return re.sub(r"\b(the|a|to) \1\b", r"\1", t) @@ -1982,6 +2018,18 @@ REFUSE_FLOOR = ("I can't reach the floor with my arm, only things on a table.", IDIOM = re.compile(r"\bput (?:\w+ ){0,3}(?:on (?:my|the|your|our|their) (?:tab|list|bill|account|calendar|schedule|agenda|" r"to-?do list|menu)|on hold)\b|\blet'?s put\b|" r"\bbring it on\b|^\W*hold it\W*$|\bgive me (?:five|a high five|some skin)\b|\bhigh five\b", re.I) # "put it on my tab", "hold it!" (wait): no hand +NOT_A_THING = re.compile( # "give me the top stories", "give me the short version", "힌트 좀 줘": words, not a thing in the hand + r"\b(?:give|hand|pass|bring|gimme|tell|send|show)\s+(?:me|us)?\s*(?:(?:the|a|an|some|your|any|more|quick|short|brief|" + r"latest|top|full|long|real|honest|little|few|good|best|main)\s+)*(?:\w+\s+)?(?:news|stories|story|headlines?|version|summary|" + r"rundown|overview|update|updates|details?|info|information|answer|answers|example|examples|reason|reasons|idea|ideas|tip|tips|" + r"hint|hints|advice|recommendations?|suggestions?|list|number|numbers|name|names|address|directions|time|minute|second|moment|" + r"break|chance|call|ride|hug|smile|kiss|quote|price|forecast|weather|facts?|jokes?|words?|review|report|brief(?:ing)?|recap|" + r"explanation|definition|translation|lowdown|scoop|gist|highlights|scores?|results?|lyrics|tour|demo|presentation|intro(?:duction)?|" + r"feedback|opinions?|thoughts|status|percentage|guess|rating|estimate|ideas?|options?|choices?|minutes|seconds|space|room|" + r"reply|response|clue|clues|sign|signal|wave|nod|look|try|go|shot|rest|lift|push)\b|" + r"(?:뉴스|소식|정보|힌트|팁|설명|대답|답변|답|요약|시간|기회|이름|번호|전화번호|주소|조언|추천|의견|피드백|예시|이유|" + r"아이디어|답장|연락|칭찬|박수|사인|신호|용기|자유|휴식|여유)\s*(?:을|를|좀|도|만)?\s*(?:좀\s*)?(?:더\s*)?" + r"(?:줘|주세요|줘요|주라|줄래|주실래요|주십시오|주시겠어요|주쇼|주이소)", re.I) _POL = r"(?:\W+(?:please|pls|plz|now|lumi|robot|thanks|thank you|okay|ok|then|already|quick|빨리|얼른|어서|좀|제발|루미야?))*" GIVE_LOOSE = re.compile( # with something in the hand, the whole sentence asks for it: give it to the speaker rf"\W*(?:(?:you|please|now|lumi|robot|okay|ok|hey|so|just|me)\W+)*(?:gimme|give|hand|pass)(?: (?:it|that|this|that one|" @@ -2025,7 +2073,7 @@ GIVE_HELD_NOT = re.compile( # a cancel, a past, a place word, "not yet": never r"\band\b(?! (?:give|hand|pass|now)\b)|\b(?:then|after that|also)\b|[가-힣](? "정말요?", "아 맞다, 여러분 + 보세요,어디 있어?" -> "어디 있어?" (the last of several short parts), "Jason, look, Lumi seriously?" -> "seriously?". + Only for reading what kind of follow-up it is; the model gets the words as said.""" + t = _CUT_WORD.sub("", text or "").strip().rstrip(".~ ").strip() + t = _CORE_LEAD.sub("", t).strip() or t + last = _CORE_LEAD.sub("", re.split(r"[,:]\s*", t)[-1]).strip() + return last if last and t != last and len(last.split()) <= FOLLOW_UP_WORDS + 1 and \ + (ABOUT_ANSWER.match(last) or SHORT_Q.search(last)) else t + + +THANKS_ONLY = re.compile(r"^\W*(?:thanks?(?: (?:a lot|so much|very much))?|thank you(?: (?:so much|very much|a lot))?|thx|" + r"cheers|ty|고마워(?:요)?|고맙(?:습니다|다|데이|구먼)|감사(?:합니다|해요|해|하다)|땡큐(?: 베리 ?머치)?)" + r"(?:\W+(?:lumi|robot|루미야?|로봇아?))?\W*$", re.I) # thanks and nothing else +BYE_WORDS = re.compile(r"\b(?:bye|goodbye|see you|gotta go|i (?:have|need) to go)\b|안녕(?!하)|갈게|가 ?볼게|가야|잘 ?있어|" + r"수고하", re.I) # with a question after it: one more question before leaving + + +def topic_turn(history): + """The last turn that said something of its own: a back-channel ("헐 대박", "Oh, I see.") and Lumi's short reply + to it are passed over, so "really?" / "where is it?" after them asks about the answer before.""" + for q, a in reversed(history[-4:]): + if about_answer(q) or not (is_backchannel(q) or UNDERSTOOD.search(q) and len(q.split()) <= 4): + return q, a + return history[-1] + + +def about_answer(text): + """The words ask about the answer just given (ABOUT_ANSWER), also with words around them.""" + c = core(text) + w = c.split()[-1] if c.split() else "" + return bool(ABOUT_ANSWER.match(text or "") or ABOUT_ANSWER.match(c) or len(c.split()) <= 3 and + (ABOUT_ANSWER.match(w) or re.search(r"(?:정말|진짜|참말|설마)(?:요|이야|이에요|이가|로)?\W*$", w))) + # "투자자 앞에서 진짜?", whisper's "어정말요?" LOOKUP_BEFORE_CHARS = 1500 # chars of the last lookup's results given again with a follow-up ("how old is she?") FOLLOW_UP_WORDS = 5 # "why did Samsung stock fall today?" is a new question, "tell me more about it" is not AND_ALSO = re.compile(r"^\s*(and|what about|how about|also|그럼|그리고)\b", re.I) # "and the yen?": a follow-up @@ -2492,7 +2589,9 @@ WEATHER_ASKED = " (the weather)" # lumi.look_up adds it to a weather question; WEATHER_PLACE = re.compile(r"^\W*(?i:(?:and|so|then|ok(?:ay)?)\W+)*(?i:(?:what|how)\s+about\s+)?(?i:in\s+)?" r"(?!(?:Why|What|When|Where|Who|Whose|How|Which|Is|Are|Was|Will|Can|Could|Do|Does|Did|Should|Lumi)\b)(?P[A-Z][\w'-]*(?:\s+[A-Z][\w'-]*)*)[\s?.!]*$") # "what about Busan?" after the weather KO_WEATHER_PLACE = re.compile(r"^\W*(?:(?:그럼|그러면|그리고|아니)\W*)?(?P[가-힣]+?)(?:시|도)?(?:\s*날씨)?" - r"(?:은|는|도|에는|에서는|이요|요)*[\s?.!~]*$") # "그럼 부산은?": a place of web.KO_PLACES only + r"(?:은|는|도|에는|에서는|이요|요)*(?:\s*(?:날씨는?\s*)?(?:어때요?|어때유|어떻습니까|어떠세요|어떠신가요|어떻노|어떻나요?|" + r"어뗘|어떠냐|어떻니|어떤가요|어떻게 ?(?:돼요?|됩니까|되나요|되노)|우째 ?되노))?[\s?.!~]*$") + # "그럼 부산은?", "부산은 어떻노?": a place of web.KO_PLACES only REPAIR = re.compile(r"^\W*(?:(?:no|nope|sorry|oh)\W+)*i\s+mean[t]?\b|^\W*(?:아니|아뇨|아니요)[\s,]|말고\b|" r"말(?:이야|이에요|이요)\W*$", re.I) # "no, I meant North Korea", "아니 서울 말이야" LEAD = re.compile(r"^\s*(?:(?:and|what about|how about|also|no|nope|sorry|oh|그럼|그리고|아니|아뇨|아니요)\b[\s,]*)*" @@ -2515,9 +2614,16 @@ REACTION = re.compile(r"^\W*(?:(?:wow|oh|really|huh|whoa)\W+)*(?:i (?:didn'?t|di re.I) # a reaction to what was found, not a new question NOW_Q = re.compile(r"\bwhat time is it\b|\bwhat'?s the time\b|\bwhat(?:'s| is) (?:the date|today)\b|지금 몇 ?시|오늘 며칠", re.I) # asked of the clock, not of the lookup before -WEATHER_WORDS = re.compile(r"\b(?:and|so|then|too|also|as well|ok(?:ay)?|what|how|about|is|it|the|weather|like|for|on|in|at|will|be|going|" +WEATHER_WORDS = re.compile(r"\b(?:how's|what's|looking|look|and|so|then|too|also|as well|ok(?:ay)?|what|how|about|is|it|the|weather|like|for|on|in|at|will|be|going|" r"to|forecast|rain|there|that|then|please|sorry|no|i|mean|meant)\b|그럼|그러면|그리고|날씨|어때요|어때|어떤가요|어떨까요|어떻게|돼요|" - r"비|와요|올까요|오나요|알려|줘|주세요", re.I) # the rest of "and the weather on Friday then?" + r"비|와요|올까요|오나요|알려|줘|주세요|어떻습니까|어떠세요|어떠신가요|어떻노|어떻나요|어떻나|어뗘|어떠냐|어떻니|" + r"어때유|우째|되노|됩니까|되나요|될까요|돼|어떤가요|어떻게|좀", re.I) # the rest of "and the weather on Friday then?" +WEATHER_ONLY = re.compile(r"^\W*(?:(?:and|so|then|그럼|그러면)\W+)?(?:is it|will it|is it going to|does it|do i need|should i (?:bring|take)|" + r"any|how)\b.{0,25}\b(?:rain\w*|snow\w*|windy|umbrella|jacket|coat)\b[\w\s]*\W*$|" + r"^\W*(?:그럼\s*)?(?:비|눈|소나기|미세먼지|황사|바람)(?:은|는|도|가|이)?\s*(?:와|와요|오나요?|올까요?|옵니까|오니|오노|와유|" + r"어때요?|어떻습니까|많이 불어요?|불어요?|심해요?|나빠요?|있어요?)?[\s?.!~요]*$|" + r"^\W*우산\s*(?:챙겨야|가져가야|필요)", re.I) # a weather question that names no day or place; + # "is it cold?" / "추워요?" is answered from the weather just said (the LLM) PARTICLES = re.compile(r"^[은는도요의에이가서엔]+$") # "월요일은요" less the day CHECKING = re.compile(r"^\W*(?:let me (?:check|see|look)|one moment|just a moment|확인해 ?볼게요|잠시만요?)\W*$", re.I) # lumi says it before the lookup: never again inside the answer @@ -2526,8 +2632,10 @@ CHECKING = re.compile(r"^\W*(?:let me (?:check|see|look)|one moment|just a momen def weather_follow(text): """A short weather follow-up that names a day and maybe a place ("내일은요?", "and Friday?", "what about Busan tomorrow?", "다음 주 월요일 어때요?"): the place ("" = the one asked before), else None.""" - if len(text.split()) > 8 or web.asked_day(text) is None: + if len(text.split()) > 8: return None + if web.asked_day(text) is None: # "비는 와?", "is it cold?" right after the weather: the same + return "" if WEATHER_ONLY.search(text) and not re.search(r"(?<=\s)(?!I\b)[A-Z]", text) else None # day and place rest = web.DAY_PHRASE.sub(" ", text) ko = next((k for k in sorted(web.KO_PLACES, key=len, reverse=True) if k in rest), None) rest = WEATHER_WORDS.sub(" ", rest.replace(ko, " ") if ko else rest) @@ -2670,6 +2778,9 @@ class Brain: for q, a in self.window(): messages += [{"role": "user", "content": q}, {"role": "assistant", "content": a}] follow = _follow_examples(text, self.history) # with them, fewer plain examples (a shorter prompt) + if follow and not LUMI_TOPIC.search("{} {}".format(core(topic_turn(self.history)[0]), topic_turn(self.history)[1])): + 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 messages.append({"role": "user", "content": f"Reference notes:\n{notes}\n\n{_examples(about, k=2 if follow else None, on_task=bool(now) and 'not doing any task' not in now)}" f"{follow}" f"Now it is {now_line()}.\n\n" + memory.turn_lines(self, text) + @@ -2701,7 +2812,7 @@ class Brain: if header is None: # the model skipped the ACTION line header, buf = self._after({"action": "none", "target": ""}, text), first + " " + buf if header["action"] == "unclear" and not retried and \ - (has_meaning(text) or self.history and ABOUT_ANSWER.match(text)) and \ + (has_meaning(text) or self.history and about_answer(text)) and \ not other_latin_language(text): # 26b called short or broken but clear words unclear ("fr?") stream.close() retried, header, buf, full = True, None, "", "" @@ -2785,12 +2896,21 @@ class Brain: if last and part: # "What about your cameras?" / "카메라는요?" after "can I wipe you?" return (f"(The visitor's question \"{self.history[-1][0]}\" asked again, now about {part.group(1)}: answer " f"that question for it, not other facts about it.)\n") - if last and ABOUT_ANSWER.match(text): # "why?", "how do you know?", "진짜?" after a refusal too + if last: # past a back-channel ("헐 대박") to the answer before it + last = " ".join(ln for ln in topic_turn(self.history)[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." + return "(Only thanks for your answer, not a goodbye: say you're welcome in a few words; no goodbye, no question.)\n" + if BYE_WORDS.search(text) and SHORT_Q.search(re.split(r"(?<=[,.!~])\s*", text.strip())[-1]): + return "(A goodbye with one more question: answer the question; no goodbye in your words yet.)\n" + if last and about_answer(text): # "why?", "how do you know?", "진짜?" after a refusal too return (f"(This asks about your answer \"{last[:FRAGMENT_CHARS * 2]}\": its reason or how you know it; " f"a \"really?\" / \"sure?\" is answered \"Yes,\" with that answer's own facts said again (its numbers, names or the " f"things it listed, never just \"that\" / \"those\"), no new fact.)\n") - if not last or len(text.split()) > FRAGMENT_WORDS or not SHORT_Q.search(text) or is_backchannel(text) \ - or ABOUT_YOU.search(text) or OWN_TOPIC.search(text): + pronoun = NAMED_BEFORE.search(c) or REFERS_BACK.search(c) # "when was it built?", "how old are they?" + if not last or len(c.split()) > (FOLLOW_UP_WORDS + 2 if pronoun else FRAGMENT_WORDS) or not SHORT_Q.search(c) \ + or is_backchannel(c) or ABOUT_YOU.search(c) or (OWN_TOPIC.search(c) or OWN_SUBJECT.search(c)) and not pronoun: return "" return f"(This follows your answer \"{SENTENCE_END.split(last)[0][:FRAGMENT_CHARS]}\": it asks about that.)\n" @@ -2809,7 +2929,7 @@ class Brain: if header.get("held", ("none",))[0] != "none" and (self._redo(text) or DO_IT.match(text) or confirm_answer(text) == "yes" and self._last_said().rstrip().endswith("?")): return {"action": header["held"][0], "target": header["held"][1]} # "yes" to "Shall I go there?" - if header["action"] == "quiet" and ABOUT_ANSWER.match(text): + if header["action"] == "quiet" and about_answer(text): return {"action": "none", "target": ""} # "에이, 거짓말하지 마" doubts the answer, not "be quiet" redo = self._redo(text) if redo and header["action"] == "none": # "do it again" after a wave answered "Okay!" with none @@ -2972,6 +3092,9 @@ class Brain: f"in your own words: {' / '.join(ideas)}. " + (f"Said to other visitors lately, so do not use these again: {avoid}. " if avoid else "") + + "It must say goodbye in plain words (bye, see you, take care / " + "안녕히 가세요, 조심히 가세요, 다음에 또 만나요, 또 오세요), not only " + "thanks or 'enjoy'. " "Do not begin with 'You're welcome' or '천만에요'; never say 'Have a " "great day', 'It was nice talking with you' or 'It was my pleasure'; " "in Korean polite (-요)."}) @@ -3129,7 +3252,9 @@ class Brain: if action == "stop" and "?" in text: action = "none" # "how do I stop you?": a question about stopping if action == "end" and "?" in re.split(r"(?<=[.!?~])\s+", text.strip())[-1]: - action = "none" # "thanks, and where is p3?": a question is no goodbye; the + action = model if model in ("search", "weather") else "none" # "갈게요, 근데 후지산은 얼마나 높아?": its + target = target if action != "none" else "" # lookup stays (else "search 후지산 높이" was said aloud) + # "thanks, and where is p3?": a question is no goodbye; the # model reads "okay" / "됐어요" with the talk before (owner) out = {"action": action, "target": target or ""} if held and action == "none": diff --git a/assistant/driving.py b/assistant/driving.py index d1142bb..01acd4a 100644 --- a/assistant/driving.py +++ b/assistant/driving.py @@ -27,8 +27,8 @@ TURN_MORE_DEG = 15.0 # deg; "a bit more" right after a turn: this much f DIRS = (("back", r"\bback(?:wards?)?\b(?! down\b)|\bbackward\b|\breverse\b|^(?:let'?s )?(?:bake|big)\b(?= \d| half| a )|뒤로|뒤쪽|후진|" r"물러"), # whisper's "let's bake / big one meter" ("forward", r"\bforwards?\b|\bahead\b|앞으로|앞쪽|전진"), - ("left", r"\b(?:to the |to your )?left\b|왼쪽|좌측"), - ("right", r"(?= 3 and NAMES_LUMI.search(t[lead.end():]): + t = t[lead.end():] # "and your name is?", "so who are you?": a whole question if FRAGMENT.search(t): return "fragment" if SEVERAL.search(t): diff --git a/assistant/talk_examples.py b/assistant/talk_examples.py index cd4b5d4..2e635d0 100644 --- a/assistant/talk_examples.py +++ b/assistant/talk_examples.py @@ -295,12 +295,12 @@ _BANK = { "en": [ ("Thank you", "You're welcome!"), ("Thanks, Lumi", "Anytime. That's what I'm here for."), - ("Thanks a lot", "Happy to help. Need anything else?"), + ("Thanks a lot", "Happy to help."), ("Thank you so much", "My pleasure, really."), ("Cheers", "Cheers to you too!"), ("Thanks for the cup", "Enjoy it! Let me know if you need another."), ("I appreciate it", "Glad it was useful."), - ("Thanks for your help", "No trouble at all. Anything else on your mind?"), + ("Thanks for your help", "No trouble at all."), ("Much appreciated", "It was nothing, honestly."), ("Thanks for the chat", "I enjoyed it too. Come back anytime."), ("Thank you, robot", "You're welcome, human."), @@ -308,16 +308,16 @@ _BANK = { ("Thanks for the water", "Stay hydrated! Need anything else carried?"), ], "ko": [ - ("고마워요", "천만에요! 더 필요한 거 있으세요?"), + ("고마워요", "천만에요!"), ("감사합니다", "별말씀을요. 도움이 돼서 다행이에요."), ("고마워", "별말씀을요, 언제든지요!"), ("정말 감사해요", "제가 더 기뻐요."), - ("땡큐", "천만에요, 유어 웰컴이에요! 또 불러 주세요."), + ("땡큐", "천만에요, 유어 웰컴이에요!"), ("컵 가져다줘서 고마워", "맛있게 드세요! 더 필요하시면 말씀하세요."), - ("도와줘서 고마워요", "도움이 됐다니 다행이에요. 또 필요한 거 있으세요?"), + ("도와줘서 고마워요", "도움이 됐다니 다행이에요."), ("수고해 줘서 고마워요", "아니에요, 재밌었어요."), ("얘기해 줘서 고마워", "저도 얘기 나눠서 즐거웠어요."), - ("감사해요 루미", "언제든 불러 주세요."), + ("감사해요 루미", "천만에요, 언제든지요."), ("물 가져다줘서 감사해요", "시원하게 드세요. 또 필요하면 불러 주세요."), ("도와주셔서 정말 감사합니다", "아닙니다, 도움이 되어 기쁩니다."), ], @@ -1444,6 +1444,440 @@ FOLLOWUPS = [ ] +def _on(lang, q, a, *pairs): + """Several follow-ups on one answer (each said in another way or another speech level): FOLLOWUPS rows.""" + return [(lang, q, a, f, r) for f, r in pairs] + + +# Night 3: the same follow-up kinds in every Korean speech level (반말, 해요체, 하십시오체, friendly, honorific, +# dialect) and in English at the same depth: really? / are you sure? (the fact said again), a claim against the +# fact (kept), a fragment with no subject or with "it" / "그거" (about the thing just named), "what about X?" / "X는?" +# (the same question about X), yes / no to Lumi's own offer, and a question after words around it ("아 맞다, 근데"). +FOLLOWUPS += [ + # ---------- Lotte World Tower ---------- + *_on("ko", "롯데월드타워 높이가 몇이야?", "약 555m로 한국에서 제일 높은 건물이에요.", + ("몇 층이야?", "123층이에요."), + ("근데 몇 층인데?", "지상 123층이에요."), + ("층수는 어떻게 됩니까?", "지상 123층입니다."), + ("몇 층이고?", "123층이에요."), + ("어디 있어?", "서울 송파구 잠실에 있어요."), + ("거기 어디에 있습니까?", "서울 송파구 잠실에 있습니다."), + ("그게 맞아?", "네, 맞아요. 높이 약 555m, 123층이에요."), + ("참말이가?", "네, 정말이에요. 약 555m로 한국에서 가장 높아요."), + ("에이 설마.", "정말이에요. 약 555m, 123층으로 한국에서 제일 높은 건물이에요."), + ("정말입니까?", "네, 그렇습니다. 높이 약 555m로 한국에서 가장 높은 건물입니다."), + ("언제 지었어?", "2017년에 문을 열었어요."), + ("언제 완공되었습니까?", "2017년에 개장했습니다."), + ("세계에서도 높아?", "네, 세계에서도 손꼽히게 높은 건물이에요. 세계 1위는 두바이의 부르즈 할리파예요."), + ("남산타워보다 높아?", "네, 훨씬 높아요. 남산서울타워는 탑 자체가 약 237m예요.")), + *_on("en", "How tall is Lotte World Tower?", "About 555 metres, the tallest building in Korea.", + ("How many floors?", "123 floors above ground."), + ("And floors?", "It has 123 floors."), + ("Where is it?", "In Jamsil, in Songpa district in Seoul."), + ("Is that right?", "Yes: about 555 metres and 123 floors, the tallest in Korea."), + ("You sure?", "Yes, about 555 metres, taller than any other building in Korea."), + ("When was it built?", "It opened in 2017."), + ("Taller than the Eiffel Tower?", "Yes, the Eiffel Tower is about 330 metres.")), + # ---------- blue whale ---------- + *_on("ko", "지금까지 제일 큰 동물이 뭐야?", "대왕고래(흰긴수염고래)로 최대 약 30m예요.", + ("공룡보다 커?", "네, 대부분의 공룡보다 커요. 몸무게는 150톤이 넘을 수도 있어요."), + ("공룡보다 더 큽니까?", "네, 알려진 공룡보다 더 무겁습니다. 150톤이 넘기도 합니다."), + ("뭐 먹어?", "주로 크릴이라는 작은 새우 같은 동물을 먹어요. 하루에 몇 톤씩 먹어요."), + ("뭐 먹고 사노?", "크릴이라는 작은 갑각류를 먹어요. 하루에 몇 톤이나 먹어요."), + ("무엇을 먹습니까?", "주로 크릴을 먹습니다. 하루에 몇 톤씩 먹습니다."), + ("그렇게 큰데 작은 걸 먹어?", "네, 입을 크게 벌려 물을 들이켠 뒤 수염으로 걸러서 크릴을 먹어요."), + ("진짜?", "네, 정말이에요. 대왕고래가 지금까지 산 동물 중 가장 커요. 길이 최대 약 30m예요."), + ("코끼리가 고래보다 크잖아.", "아니에요, 대왕고래가 훨씬 커요. 코끼리는 몇 톤이지만 대왕고래는 100톤이 넘어요."), + ("상어보다 커?", "네, 고래상어도 10m 남짓이라 대왕고래가 훨씬 커요."), + ("어디 살아?", "전 세계 바다에 살아요. 남극 바다에도 많이 와요.")), + *_on("en", "What's the biggest animal ever?", "The blue whale, up to about 30 metres long.", + ("Bigger than dinosaurs?", "Yes, heavier than any known dinosaur: it can weigh over 150 tonnes."), + ("What does it eat?", "Mostly krill, tiny shrimp-like animals, several tonnes a day."), + ("wat it eat", "Krill, tiny shrimp-like animals, tonnes of them every day."), + ("Really?", "Yes, the blue whale is the biggest animal that ever lived, up to about 30 metres."), + ("No way, elephants are bigger.", "Not really: an elephant weighs a few tonnes, a blue whale over a hundred."), + ("Where does it live?", "In oceans all over the world, also around Antarctica.")), + # ---------- seasons ---------- + *_on("ko", "계절은 왜 생겨?", "지구 자전축이 약 23.5도 기울어져 있어서 그래요.", + ("얼마나 기울었어?", "약 23.5도 기울어 있어요."), + ("몇 도나 기울어져 있습니까?", "약 23.5도입니다."), + ("그러면 호주는 반대야?", "네, 반대예요. 우리가 겨울일 때 호주는 여름이에요."), + ("호주는 계절이 반대입니까?", "네, 남반구라서 계절이 반대입니다."), + ("태양이 가까워져서 여름이 오는 거잖아.", "아니에요, 거리 때문이 아니라 자전축이 기울어서예요. 지구는 오히려 1월에 태양과 가장 가까워요."), + ("거리 때문 아이가?", "아니에요, 자전축이 약 23.5도 기울어서 햇빛을 받는 각도가 달라지기 때문이에요."), + ("진짜요?", "네, 정말이에요. 자전축이 약 23.5도 기울어서 계절이 생겨요."), + ("그게 무슨 말이야?", "지구가 기울어진 채로 태양을 돌아서, 햇빛을 더 똑바로 받는 쪽이 여름이 돼요.")), + *_on("en", "Why do we have seasons?", "Because Earth's axis is tilted about 23.5 degrees.", + ("How much?", "About 23.5 degrees."), + ("So Australia is the opposite?", "Yes, when it's winter here it's summer in Australia."), + ("It's because we get closer to the Sun, right?", "No, it's the tilt: Earth is actually closest to the Sun in early January."), + ("For real?", "Yes, the tilt of about 23.5 degrees makes the seasons, not the distance.")), + # ---------- dolphins ---------- + *_on("ko", "돌고래는 어떻게 자?", "뇌의 반쪽씩 번갈아 자서 숨을 계속 쉴 수 있어요.", + ("왜?", "돌고래는 숨을 쉬려면 직접 물 위로 올라와야 해서, 뇌 반쪽은 깨어 있어야 해요."), + ("왜 그래요?", "숨 쉬는 걸 스스로 챙겨야 해서 뇌 반쪽은 깨어 있어요."), + ("와 그렇노?", "물 위로 올라와 숨을 쉬어야 해서 뇌 반쪽이 깨어 있어요."), + ("물고기야?", "아니요, 돌고래는 포유류예요. 폐로 숨을 쉬고 새끼에게 젖을 먹여요."), + ("물고기 아입니까?", "아닙니다, 돌고래는 포유류입니다. 폐로 숨을 쉽니다."), + ("진짜...", "네, 정말이에요. 뇌의 반쪽씩 번갈아 자요."), + ("눈은 감아?", "자는 쪽 뇌와 반대쪽 눈 하나를 감고 자요.")), + *_on("en", "How do dolphins sleep?", "Half of their brain sleeps at a time, so they keep breathing.", + ("Why?", "They have to come up to breathe on purpose, so one half stays awake."), + ("Is it a fish?", "No, dolphins are mammals: they breathe air and feed their young milk."), + ("Seriously?", "Yes, one half of the brain sleeps while the other half stays awake.")), + # ---------- octopus ---------- + *_on("ko", "문어는 심장이 몇 개야?", "심장이 세 개예요.", + ("왜 세 개야?", "두 개는 아가미로 피를 보내고, 하나는 몸 전체로 피를 보내요."), + ("피는 무슨 색이야?", "파란색이에요. 구리가 든 단백질로 산소를 날라서 그래요."), + ("피 색깔은 어떻습니까?", "파란색입니다. 구리가 든 단백질이 산소를 나르기 때문입니다."), + ("다리는?", "다리는 여덟 개예요."), + ("참말이가?", "네, 정말이에요. 문어는 심장이 세 개예요."), + ("오래 살아?", "아니요, 대부분 1년에서 2년 정도밖에 못 살아요.")), + *_on("en", "How many hearts does an octopus have?", "Three hearts.", + ("Why three?", "Two pump blood through the gills, one pumps it around the body."), + ("And its blood?", "It's blue: a copper-based protein carries the oxygen."), + ("u sure", "Yes, three hearts: two for the gills, one for the body.")), + # ---------- honey ---------- + *_on("ko", "꿀은 왜 안 상해?", "꿀은 수분이 매우 적고 당도가 아주 높아서 미생물이 살기 어렵기 때문이에요.", + ("왜 굳어?", "꿀 속 포도당이 결정이 되면서 굳는 거예요. 상한 게 아니라서 따뜻하게 하면 다시 녹아요."), + ("저기, 왜 굳어?", "포도당이 결정으로 변해서 굳어요. 살짝 데우면 다시 녹아요."), + ("굳는 건 왜 그렇습니까?", "포도당이 결정화되기 때문입니다. 상한 것이 아닙니다."), + ("누가 만들어?", "꿀벌이 꽃의 꿀을 모아 만들어요."), + ("그럼 누가 맹그노?", "꿀벌이 꽃에서 모은 꿀로 만들어요."), + ("상해?", "거의 상하지 않아요. 수분이 적고 당이 많아서요."), + ("진짜 안 상해?", "네, 잘 닫아 두면 아주 오래 가요. 수분이 적고 당도가 높아서 미생물이 못 살아요.")), + *_on("en", "Why doesn't honey spoil?", "It has very little water and lots of sugar, so microbes can't grow.", + ("Why does it go hard?", "Its glucose crystallises; it isn't spoiled, warm it gently and it melts again."), + ("Who makes it?", "Honeybees, from the nectar of flowers."), + ("Does it go bad?", "Hardly ever: with so little water and so much sugar, microbes can't live in it.")), + # ---------- snowflakes ---------- + *_on("ko", "눈송이는 왜 모양이 다 달라?", "떨어지는 동안 온도와 습도가 조금씩 달라서 결정이 다르게 자라요.", + ("똑같은 눈송이도 있어?", "거의 없어요. 아주 단순한 작은 결정 말고는 똑같은 건 거의 찾을 수 없어요."), + ("왜 여섯 개야?", "물 분자가 서로 붙을 때 육각형으로 붙어서 가지가 여섯 개가 돼요."), + ("어째서 여섯 갈래입니까?", "물 분자가 육각형 모양으로 결합하기 때문입니다."), + ("에이 설마.", "정말이에요. 결정이 자라는 조건이 다 달라서 똑같은 눈송이는 거의 없어요.")), + *_on("en", "Why are snowflakes all different?", "Each one meets slightly different temperature and humidity as it falls.", + ("Are any two the same?", "Almost never, except maybe tiny simple crystals."), + ("Why six sides?", "Water molecules lock together in a hexagon pattern, so the arms grow in sixes.")), + # ---------- lightning ---------- + *_on("ko", "번개는 뭐야?", "구름과 땅 사이에서 생기는 거대한 전기 불꽃이에요.", + ("뜨거워?", "네, 아주 뜨거워요. 약 3만 도로 태양 표면보다 다섯 배쯤 뜨거워요."), + ("뜨겁습니까?", "네, 약 3만 도로 태양 표면보다 뜨겁습니다."), + ("천둥은 왜 늦게 들려?", "빛이 소리보다 훨씬 빨라서 번쩍임이 먼저 보이고 소리가 나중에 와요."), + ("번개는 같은 데 두 번 안 친다며?", "아니에요, 같은 곳에도 여러 번 쳐요. 높은 건물은 한 해에 여러 번 맞기도 해요."), + ("왜 생기는데?", "구름 속 얼음 알갱이들이 부딪치면서 전기가 쌓이고, 그게 한꺼번에 흘러서 생겨요.")), + *_on("en", "What is lightning?", "A huge electric spark between clouds and the ground.", + ("Is it hot?", "Very: around 30,000 degrees, hotter than the surface of the Sun."), + ("Why do we hear thunder later?", "Light is far faster than sound, so the flash reaches you first."), + ("Lightning never strikes the same place twice.", "Actually it does: tall buildings get hit many times a year."), + ("Why does it happen?", "Ice bits in the cloud collide and build up electric charge until it jumps.")), + # ---------- pyramids ---------- + *_on("en", "Why were the pyramids built?", "As tombs for Egyptian pharaohs.", + ("How old are they?", "The big ones at Giza are about 4,500 years old."), + ("Where's the biggest?", "At Giza, near Cairo: the Great Pyramid of Khufu."), + ("Seriously?", "Yes, they were tombs for the pharaohs of ancient Egypt."), + ("Who built them?", "Paid Egyptian workers and craftsmen, thousands of them, not slaves as the old story goes.")), + *_on("ko", "피라미드는 왜 지었어?", "이집트 파라오의 무덤으로 지었어요.", + ("얼마나 오래됐어?", "기자의 큰 피라미드들은 약 4,500년 됐어요."), + ("몇 년이나 됐습니까?", "약 4,500년 되었습니다."), + ("제일 큰 건 어디 있어?", "카이로 근처 기자에 있는 쿠푸왕의 피라미드예요."), + ("누가 지었노?", "고대 이집트의 일꾼과 기술자 수천 명이 지었어요.")), + # ---------- Eiffel Tower ---------- + *_on("en", "How tall is the Eiffel Tower?", "About 330 m, built for the 1889 World's Fair.", + ("When was it built?", "Between 1887 and 1889, for the World's Fair in Paris."), + ("Um, when was it built?", "It was finished in 1889, for the World's Fair."), + ("What's it made of?", "Wrought iron, about 7,300 tonnes of it."), + ("Who built it?", "Gustave Eiffel's company."), + ("Really?", "Yes, about 330 metres, finished in 1889.")), + *_on("ko", "에펠탑 높이가 얼마야?", "약 330m예요. 1889년 만국박람회 때 지었어요.", + ("언제 지었다고?", "1889년이에요. 파리 만국박람회 때 완성됐어요."), + ("뭘로 만들었어?", "철로 만들었어요. 무게가 약 7,300톤이에요."), + ("무엇으로 지어졌습니까?", "철로 지어졌습니다."), + ("누가 만들었노?", "귀스타브 에펠의 회사가 만들었어요.")), + # ---------- Mars ---------- + *_on("en", "Why is Mars red?", "Its dust is full of iron oxide, rust.", + ("Is there water?", "Yes, as ice, at the poles and under the ground."), + ("How long is a day there?", "About 24 hours and 37 minutes."), + ("Seriously?", "Yes, its dust is full of iron oxide, which is rust."), + ("Moons?", "Two small ones, Phobos and Deimos.")), + *_on("ko", "화성은 왜 빨개?", "흙먼지에 산화철, 즉 녹이 많아서 그래요.", + ("물은 있어?", "네, 얼음으로 있어요. 극지방과 땅속에 있어요."), + ("물은 있습니까?", "네, 극지방과 땅속에 얼음 상태로 있습니다."), + ("하루는 얼마나 길어?", "약 24시간 37분이에요."), + ("참말이가?", "네, 정말이에요. 흙에 산화철, 녹이 많아서 붉게 보여요."), + ("달은?", "포보스와 데이모스라는 작은 달이 두 개 있어요.")), + # ---------- Moon ---------- + *_on("ko", "달까지 얼마나 멀어?", "평균 약 38만 4천 km예요.", + ("가는 데 얼마나 걸려?", "아폴로 우주선으로 약 3일 걸렸어요."), + ("어 가는 데 얼마나 걸려?", "우주선으로 3일쯤 걸려요."), + ("가는 데 며칠 걸립니까?", "아폴로 우주선으로 약 3일 걸렸습니다."), + ("어 참말이가", "네, 정말이에요. 평균 약 38만 4천 km 떨어져 있어요."), + ("밀물 썰물은 왜 생겨?", "달의 중력이 바닷물을 끌어당겨서 생겨요.")), + *_on("en", "How far is the Moon?", "About 384,000 kilometres on average.", + ("How long to get there?", "About three days, the way the Apollo crews flew."), + ("For real?", "Yes, about 384,000 kilometres on average."), + ("And the tides?", "The Moon's gravity pulls on the oceans, which makes the tides.")), + # ---------- penguins ---------- + *_on("ko", "펭귄은 어디 살아?", "주로 남반구에 살고, 남극 근처에 많이 살아요.", + ("왜 못 날아?", "날개가 헤엄치기 좋은 지느러미처럼 바뀌어서 날 수 없어요. 대신 물속에서 아주 잘 헤엄쳐요."), + ("와 못 나노?", "날개가 헤엄치는 지느러미처럼 변해서 못 날아요."), + ("어찌하여 날지 못합니까?", "날개가 헤엄치기 위한 지느러미 형태로 변했기 때문입니다."), + ("북극에도 살아?", "아니요, 북극에는 없어요. 거의 다 남반구에 살아요."), + ("정말요?", "네, 정말이에요. 펭귄은 거의 다 남반구에 살아요.")), + *_on("en", "Where do penguins live?", "Mostly in the Southern Hemisphere, many around Antarctica.", + ("Why can't they fly?", "Their wings turned into flippers for swimming; they're great swimmers instead."), + ("Any at the North Pole?", "No, almost all penguins live south of the equator.")), + # ---------- Chuseok ---------- + *_on("ko", "추석이 뭐야?", "한국의 가을 추수 명절로, 가족이 모여 차례를 지내고 송편을 먹어요.", + ("언제야?", "음력 8월 15일이에요."), + ("루미 양반, 언제야?", "음력 8월 15일이에요."), + ("언제입니까?", "음력 8월 15일입니다."), + ("송편은 뭐야?", "쌀가루 반죽에 깨나 콩을 넣고 반달 모양으로 빚어 찐 떡이에요."), + ("에이 설마.", "정말이에요. 추석은 가을 수확에 감사하는 명절이에요."), + ("올해는?", "올해 날짜는 달력을 봐야 정확해요. 음력 8월 15일이라 해마다 달라요.")), + *_on("en", "What is Chuseok?", "Korea's autumn harvest holiday: families gather and eat songpyeon.", + ("When is it?", "On the 15th day of the 8th lunar month."), + ("What's songpyeon?", "Half-moon rice cakes filled with sesame or beans, steamed on pine needles.")), + # ---------- Mona Lisa ---------- + *_on("ko", "모나리자는 누가 그렸어?", "레오나르도 다빈치예요.", + ("지금 어디 있어?", "파리 루브르 박물관에 있어요."), + ("음 지금 어디 있어?", "프랑스 파리의 루브르 박물관에 있어요."), + ("커?", "생각보다 작아요. 가로 약 53cm, 세로 약 77cm예요."), + ("큽니까?", "생각보다 작습니다. 약 77cm에 53cm입니다."), + ("에이 설마", "정말이에요. 레오나르도 다빈치가 그렸어요."), + ("왜 유명해?", "신비로운 미소와 기법, 그리고 1911년 도난 사건으로 더 유명해졌어요.")), + *_on("en", "Who painted the Mona Lisa?", "Leonardo da Vinci.", + ("Where is it now?", "In the Louvre, in Paris."), + ("Is it big?", "Smaller than people expect: about 77 by 53 centimetres."), + ("No way.", "It's true: Leonardo da Vinci painted it.")), + # ---------- kimchi / kimjang ---------- + *_on("ko", "김치는 왜 시어져?", "발효되면서 유산균이 산을 만들어서 시어져요.", + ("그거 몸에 좋아?", "네, 유산균이 많아서 장 건강에 좋아요. 다만 짜니까 적당히 드세요."), + ("몸에 좋습니까?", "네, 유산균이 풍부해서 장에 좋습니다."), + ("그럼 여름에 더 빨리 시어?", "네, 따뜻하면 발효가 빨라서 더 빨리 시어요."), + ("여름에는 더 빨리 쉽니까?", "네, 온도가 높으면 발효가 빨라집니다."), + ("정말요?", "네, 정말이에요. 유산균이 산을 만들어서 시어져요.")), + *_on("ko", "김장은 언제 해?", "보통 늦가을, 11월쯤 겨울이 오기 전에 해요.", + ("김장은 여름에 하는 거잖아.", "아니에요, 김장은 겨울을 앞둔 늦가을에 해요. 김장 문화는 유네스코 인류무형문화유산이기도 해요."), + ("왜 그때 해?", "배추가 맛있는 철이고, 추워서 김치가 천천히 익기 좋아서요."), + ("어째서 그때 합니까?", "배추가 제철이고 날씨가 추워 김치가 천천히 익기 때문입니다.")), + *_on("en", "Why does kimchi turn sour?", "As it ferments, lactic acid bacteria make acid.", + ("Is it healthy?", "Yes, it's full of probiotics, just salty, so in moderation."), + ("Faster in summer?", "Yes, warmth speeds up the fermentation.")), + # ---------- Hangul, Olympics ---------- + *_on("ko", "한글은 누가 만들었어?", "조선의 세종대왕이 만들었어요.", + ("언제?", "1443년에 만들고 1446년에 반포했어요."), + ("언제 만드셨어요?", "1443년에 만드시고 1446년에 널리 알리셨어요."), + ("왜 만들었어?", "한자가 어려워서 백성이 쉽게 글을 쓰고 읽게 하려고요."), + ("한글날은?", "10월 9일이에요.")), + *_on("en", "Who created Hangul?", "King Sejong the Great, in 1443.", + ("Why?", "Chinese characters were hard to learn, so ordinary people could read and write."), + ("When is Hangul Day?", "October 9th.")), + *_on("ko", "서울 올림픽은 언제였어?", "1988년이었어요.", + ("겨울 올림픽은?", "2018년 평창 동계올림픽이 있었어요."), + ("그건 그렇고 겨울 올림픽은?", "한국에서는 2018년에 평창에서 열렸어요."), + ("동계 올림픽은 언제 열렸습니까?", "2018년에 평창에서 열렸습니다."), + ("몇 번째였어?", "제24회 하계올림픽이었어요.")), + *_on("en", "When were the Seoul Olympics?", "In 1988.", + ("And the Winter Olympics?", "Korea hosted them in PyeongChang in 2018.")), + # ---------- bees, bones, sharks ---------- + *_on("ko", "벌은 꽃 위치를 어떻게 알려 줘?", "엉덩이를 흔드는 춤으로 방향과 거리를 알려 줘요.", + ("일벌은 얼마나 살아?", "여름에는 보통 5주에서 6주쯤 살아요."), + ("벌은 소리로 말하잖아.", "아니에요, 주로 춤으로 알려 줘요. 흔드는 방향과 시간이 꽃의 방향과 거리예요."), + ("진짜예요?", "네, 정말이에요. 꼬리를 흔드는 춤으로 꽃의 방향과 거리를 알려 줘요.")), + *_on("en", "How do bees show where flowers are?", "With a waggle dance that gives the direction and distance.", + ("How long do worker bees live?", "About five to six weeks in summer."), + ("Bees talk with sounds.", "Mostly they dance: the angle and length of the waggle tell the way.")), + *_on("ko", "어른 뼈는 몇 개야?", "206개예요.", + ("아기는?", "약 270개에서 300개쯤이에요. 자라면서 뼈들이 합쳐져요."), + ("아기는요?", "300개 가까이 돼요. 크면서 붙어서 줄어들어요."), + ("왜 줄어?", "자라면서 여러 개의 뼈가 하나로 붙기 때문이에요."), + ("왜 줄어듭니까?", "성장하면서 여러 뼈가 하나로 합쳐지기 때문입니다.")), + *_on("en", "How many bones does an adult have?", "206.", + ("And a baby?", "Around 270 to 300; many of them fuse as the child grows."), + ("Why fewer later?", "Several small bones grow together into one.")), + *_on("ko", "상어도 자?", "네, 쉬어요. 어떤 상어는 헤엄치면서 쉬고, 어떤 상어는 바닥에 가만히 쉬어요.", + ("왜 헤엄치면서 자?", "어떤 상어는 헤엄쳐야 물이 아가미로 지나가서 숨을 쉴 수 있어요."), + ("진짜?", "네, 정말이에요. 헤엄치면서 쉬는 상어도 있어요.")), + # ---------- Everest, marathon, sports ---------- + *_on("ko", "에베레스트 높이가 얼마야?", "8,849m예요.", + ("거긴 왜 그렇게 추워?", "높이 올라갈수록 공기가 희박해져서 열을 잘 못 붙잡아 추워요."), + ("아직도 자라?", "네, 지각판이 계속 부딪쳐서 해마다 몇 밀리미터씩 높아져요."), + ("물은 몇 도에 끓어?", "거기서는 기압이 낮아서 70도 정도에 끓어요."), + ("에이 9천 미터 아이가?", "아니에요, 8,849m예요. 9천 미터보다 조금 낮아요.")), + *_on("en", "How high is Mount Everest?", "8,849 metres.", + ("Is it still growing?", "Yes, by a few millimetres a year, as India keeps pushing into Asia."), + ("Why so cold up there?", "The air is thin up high, so it holds much less heat.")), + *_on("en", "How long is a marathon?", "42.195 kilometres.", + ("Why such a weird number?", "It goes back to the 1908 London Olympics route, to the royal box."), + ("Who runs it fastest?", "The record is about two hours; for the exact current record I'd have to look it up.")), + *_on("ko", "마라톤은 몇 km야?", "42.195km예요.", + ("왜 그렇게 애매해?", "1908년 런던 올림픽 코스 길이가 기준이 돼서 그래요."), + ("왜 그런 숫자입니까?", "1908년 런던 올림픽 코스를 기준으로 정했기 때문입니다.")), + *_on("ko", "태권도는 올림픽 종목이야?", "네, 2000년 시드니 올림픽부터 정식 종목이에요.", + ("그 전에는?", "1988년 서울과 1992년 바르셀로나 때는 시범 종목이었어요."), + ("그 이전에는요?", "1988년과 1992년에는 시범 종목이었어요.")), + *_on("en", "Is taekwondo in the Olympics?", "Yes, an official sport since Sydney 2000.", + ("And before that?", "It was a demonstration sport in Seoul 1988 and Barcelona 1992.")), + # ---------- dinosaurs, sky, plants, cold ---------- + *_on("ko", "공룡은 왜 멸종했어?", "약 6,600만 년 전 큰 소행성이 지구에 부딪혀서예요.", + ("어디에 떨어졌어?", "지금의 멕시코 유카탄반도 근처에 떨어졌어요."), + ("그게 확실해?", "네, 그게 가장 널리 받아들여지는 설명이에요. 약 6,600만 년 전 소행성 충돌이에요."), + ("다 죽었어?", "새의 조상만 살아남았어요. 지금의 새가 공룡의 후손이에요.")), + *_on("ko", "하늘은 왜 파래?", "햇빛이 공기에 부딪혀 퍼질 때 파란빛이 가장 많이 퍼져서요.", + ("노을은 왜 빨개?", "해가 낮으면 빛이 공기를 더 길게 지나서 파란빛은 흩어지고 붉은빛이 남아요."), + ("그럼 밤에는?", "햇빛이 없으니 퍼질 빛도 없어서 까맣게 보여요.")), + *_on("ko", "식물은 밥을 어떻게 먹어?", "햇빛과 물, 이산화탄소로 스스로 양분을 만들어요. 광합성이라고 해요.", + ("그럼 산소는?", "광합성을 하면서 산소를 내보내요."), + ("왜 초록색이야?", "엽록소가 초록빛은 반사해서 초록색으로 보여요.")), + *_on("ko", "지구에서 제일 추운 곳은?", "남극이에요. 영하 89도까지 내려간 기록이 있어요.", + ("거기 사람 살아?", "연구 기지에 과학자들이 머물지만, 원래 사는 사람은 없어요."), + ("북극은?", "북극도 춥지만 바다 위라서 남극보다는 덜 추워요.")), + *_on("en", "Why is the sky blue?", "Sunlight scatters off the air, and blue light scatters the most.", + ("Lumi, why are sunsets red?", "When the Sun is low its light crosses more air, so the blue scatters away and red is left."), + ("And at night?", "With no sunlight there's nothing to scatter, so it looks black.")), + # ---------- Lumi itself (facts as in brain.SYSTEM) ---------- + *_on("ko", "카메라 몇 개야?", "카메라는 세 개예요. 머리와 몸에 깊이 카메라가 하나씩, 베이스 앞에 3D 카메라가 있어요.", + ("그건 그렇고 참말이가?", "네, 정말이에요. 카메라는 세 개예요. 머리와 몸에 하나씩, 베이스 앞에 하나 있어요."), + ("진짜 세 개입니까?", "네, 세 개입니다. 머리, 몸, 베이스 앞에 하나씩 있습니다."), + ("어디 거야?", "머리와 몸의 카메라는 오비벡 제미니 2 L이에요."), + ("얼마나 멀리 봐?", "머리와 몸 카메라는 약 10m까지 봐요.")), + *_on("en", "How many cameras do you have?", "Three: depth cameras in my head and body, and a 3D camera at the front of my base.", + ("Are u sure?", "Yes, three: one in my head, one on my body and one at the front of my base."), + ("What brand?", "The head and body ones are Orbbec Gemini 2 L depth cameras.")), + *_on("ko", "무게가 얼마야?", "전체 약 96kg이에요. 바퀴 달린 베이스만 50kg이에요.", + ("그게 맞아?", "네, 맞아요. 전체 약 96kg이고 베이스가 50kg이에요."), + ("팔은?", "팔만 따로 9.9kg이에요."), + ("팔은 얼마나 무겁습니까?", "팔은 9.9kg입니다."), + ("왜 그렇게 무거워?", "모터와 큰 배터리가 든 베이스가 절반쯤 차지해서요.")), + *_on("en", "How heavy are you?", "About 96 kg in all; the wheeled base alone is 50 kg.", + ("That right?", "Yes, about 96 kg; the base is 50 of that."), + ("And the arm?", "The arm itself weighs 9.9 kg.")), + *_on("ko", "얼마나 빨라?", "보통 초속 0.6m, 최대 초속 1.2m예요.", + ("컵 들고는?", "컵을 들면 쏟지 않게 초속 10cm 정도로 천천히 가요."), + ("에이 설마.", "정말이에요. 보통 초속 0.6m, 최대 1.2m예요."), + ("왜 그렇게 느려?", "사람들 사이를 다니니까 안전하려고 천천히 다녀요."), + ("계단은?", "계단은 못 올라가요. 1.5cm 턱까지만 넘어요.")), + *_on("en", "How fast are you?", "0.6 metres a second normally, at most 1.2.", + ("With a cup?", "About 10 centimetres a second, so nothing spills."), + ("You're slower than that.", "My normal speed is 0.6 metres a second, at most 1.2."), + ("Stairs?", "No stairs: I can roll over a step of at most 1.5 cm.")), + *_on("ko", "턱은 넘을 수 있어?", "1.5cm 높이까지만 넘을 수 있어요.", + ("작은 턱은?", "1.5cm보다 낮으면 넘어요."), + ("어 작은 턱은...", "1.5cm 이하의 낮은 턱은 넘을 수 있어요."), + ("그게 맞아?", "네, 1.5cm까지예요. 계단은 못 올라가요.")), + *_on("ko", "배터리 얼마나 가?", "한 번 충전하면 약 10시간 가요.", + ("왜 그렇게 오래 가?", "24볼트 45암페어시 리튬이온 배터리가 들어 있어서요."), + ("충전은 얼마나 걸려?", "충전 시간은 저도 몰라요. 직원분께 여쭤봐 주세요."), + ("확실합니까?", "네, 한 번 충전으로 약 10시간 갑니다.")), + *_on("en", "How long does your battery last?", "About 10 hours on a charge.", + ("Why so long?", "I have a 24-volt, 45 amp-hour lithium-ion battery."), + ("And charging?", "How long charging takes I don't know; a staff member can tell you.")), + *_on("ko", "팔은 얼마나 들어?", "손에는 약 1kg까지 들 수 있어요.", + ("그거밖에?", "네, 팔이 그리퍼까지 2kg을 들어서 손에는 약 1kg이에요."), + ("얼마나 뻗어?", "58cm까지 뻗어요."), + ("누가 만들었어?", "팔은 미니 2 협동로봇 팔이에요. 그리퍼는 짐머 제품이에요."), + ("참말이가?", "네, 정말이에요. 손에는 약 1kg까지예요.")), + *_on("en", "How much can your arm lift?", "About 1 kg in my hand.", + ("That's it?", "Yes, the arm carries 2 kg including the gripper, so about 1 kg in the hand."), + ("How far does it reach?", "58 centimetres.")), + *_on("ko", "뇌는 뭐야?", "엔비디아 젯슨 AGX 토르 컴퓨터에서 언어 모델 젬마 4가 돌아가요.", + ("클라우드에서 돌아간다며?", "아니에요, 클라우드가 아니라 제 몸 안의 젯슨 토르에서 직접 돌아가요."), + ("누가 만들었어?", "젬마는 구글이 만들었어요."), + ("말은 어떻게 알아들어?", "위스퍼라는 음성 인식 모델로 알아들어요. 오픈AI가 만들었어요."), + ("저기 진짜...", "네, 정말이에요. 제 몸 안의 젯슨 토르에서 젬마 4가 돌아가요.")), + *_on("en", "What's your brain?", "Gemma 4, running on my own NVIDIA Jetson AGX Thor.", + ("Isn't it in the cloud?", "No, it runs on my own Jetson Thor, not in the cloud."), + ("Who made it?", "Gemma is made by Google.")), + *_on("ko", "마이크 몇 개야?", "여섯 개예요.", + ("니 말 알아듣나? 우리 귀 같은 거?", "네, 사람 귀처럼 마이크로 소리를 듣고 어느 방향에서 말하는지도 알아요."), + ("왜 여섯 개야?", "여러 개로 들어야 목소리가 어느 방향에서 오는지 알 수 있어서요."), + ("내가 어디 있는지 알아?", "네, 목소리가 들려오는 방향을 알 수 있어요.")), + *_on("en", "How many microphones do you have?", "Six.", + ("Can you tell where I am?", "Yes, from the direction your voice comes from."), + ("Why six?", "With several I can tell which direction a voice comes from.")), + # ---------- Cutshion (facts as in brain.SYSTEM) ---------- + *_on("ko", "쿳션 투자 받았어?", "2025년 8월에 씨엔티테크와 에버그린투자파트너스에서 5억 원 시드 투자를 받았어요.", + ("얼마?", "5억 원이에요."), + ("얼마라고?", "5억 원이에요."), + ("누구한테?", "씨엔티테크와 에버그린투자파트너스예요."), + ("진짜?", "네, 2025년 8월에 5억 원 시드 투자를 받았어요.")), + *_on("ko", "쿳션 상 받은 거 있어?", "로보월드 어워드를 2023년과 2024년에 받았어요.", + ("또?", "2026년 5월 벤처리움 데모데이 우수상, 6월 파리 비바테크 테크 포 체인지 어워드도 받았어요."), + ("그 다음엔 뭐 있었어요?", "2026년에 벤처리움 데모데이 우수상과 파리 비바테크 테크 포 체인지 어워드를 받았어요."), + ("아 맞다, 에이설마", "정말이에요. 로보월드 어워드를 2023년, 2024년에 받았어요.")), + *_on("en", "Has Cutshion won awards?", "Yes, RoboWorld Awards in 2023 and 2024.", + ("Any more?", "The Venturium Demo Day Excellence Award and the VivaTech Tech for Change Award in Paris, both in 2026."), + ("Really?", "Yes: RoboWorld Awards in 2023 and 2024, and two more awards in 2026.")), + *_on("ko", "쿳션 대표가 누구야?", "이민석 대표님이에요.", + ("몇 번째 회사야?", "세 번째 창업한 회사예요."), + ("회사는 언제 생겼어?", "2022년 7월에 세워졌어요."), + ("어디 있어?", "서울에 본사가 있어요.")), +] + +FOLLOWUPS += [ + # ---------- yes / no to Lumi's own offer: go on with what was offered, or leave it ---------- + ("en", "What can you do?", "I can talk, answer questions and pick things up. Want to hear more?", + "Yeah.", "I can also go to places on my map, follow you, wave and even sing."), + ("en", "What can you do?", "I can talk, answer questions and pick things up. Want to hear more?", + "Sure, go on.", "I can also go to places on my map, follow you, wave and sing my four songs."), + ("en", "What can you do?", "I can talk, answer questions and pick things up. Want to hear more?", + "Nah, that's fine.", "Okay."), + ("en", "Can you sing?", "Yes, I know four songs. Shall I sing one?", + "Okay.", "Alright, here's one for you."), + ("ko", "뭐 할 수 있어?", "대화하고 질문에 답하고 물건도 집을 수 있어요. 더 알려 드릴까요?", + "응.", "지도에 있는 곳으로 가고, 따라가고, 손도 흔들고 노래도 할 수 있어요."), + ("ko", "뭐 할 수 있어?", "대화하고 질문에 답하고 물건도 집을 수 있어요. 더 알려 드릴까요?", + "네, 알려 주세요.", "지도에 있는 곳으로 이동하고, 사람을 따라가고, 손을 흔들고 노래도 할 수 있어요."), + ("ko", "뭐 할 수 있어?", "대화하고 질문에 답하고 물건도 집을 수 있어요. 더 알려 드릴까요?", + "예, 말씀해 주십시오.", "지도에 있는 장소로 이동하고, 따라가고, 손을 흔들고, 노래도 할 수 있습니다."), + ("ko", "뭐 할 수 있어?", "대화하고 질문에 답하고 물건도 집을 수 있어요. 더 알려 드릴까요?", + "됐어, 괜찮아.", "네, 알겠어요."), + ("ko", "광합성이 뭐야?", "식물이 햇빛으로 양분을 만드는 거예요. 더 자세히 알려 드릴까요?", + "음 응...", "햇빛과 물, 이산화탄소로 당을 만들고, 그때 산소를 내보내요."), + ("ko", "광합성이 뭐야?", "식물이 햇빛으로 양분을 만드는 거예요. 더 자세히 알려 드릴까요?", + "그래 주이소.", "잎의 엽록소가 햇빛을 받아 물과 이산화탄소로 당을 만들고 산소를 내보내요."), + ("en", "What's photosynthesis?", "Plants making food from sunlight. Want the details?", + "Robot, sure.", "Leaves use sunlight to turn water and carbon dioxide into sugar, and give off oxygen."), + ("en", "What's photosynthesis?", "Plants making food from sunlight. Want the details?", + "Mm-hmm.", "Their leaves turn water and carbon dioxide into sugar with sunlight, and release oxygen."), + ("en", "What happens if someone presses your stop button?", "My arm and lift stop at once. Want to know where the buttons are?", + "Sure.", "There are red emergency stop buttons on my body and in my base."), + ("ko", "비상 정지 버튼은 뭐야?", "누르면 팔과 리프트가 바로 멈춰요. 버튼 위치도 알려 드릴까요?", + "어 그래.", "빨간 비상 정지 버튼이 몸통과 베이스에 있어요."), + # ---------- a claim against Lumi's own fact, at any speech level: the fact stays ---------- + ("ko", "키가 몇이야?", "146cm예요. 리프트를 올리면 186cm까지 돼요.", + "에이, 나보다 작잖아.", "네, 저는 146cm예요. 리프트를 올리면 186cm까지 커져요."), + ("ko", "키가 몇이야?", "146cm예요. 리프트를 올리면 186cm까지 돼요.", + "2미터는 되는 거 같은데요?", "아니에요, 146cm이고 리프트를 올려도 186cm예요."), + ("ko", "키가 몇이야?", "146cm예요. 리프트를 올리면 186cm까지 돼요.", + "그보다 크신 것 같습니다만.", "146cm가 맞습니다. 리프트를 올리면 186cm까지 됩니다."), + ("en", "How tall are you?", "146 cm, up to 186 with the lift.", + "Nah, you're like two metres.", "I'm 146 cm, and 186 with my lift all the way up."), + ("ko", "쿳션은 어디 회사야?", "서울에 있는 로봇 회사예요.", + "부산 회사 아이가?", "아니에요, 쿳션 본사는 서울에 있어요."), + ("en", "Where is Cutshion?", "Its head office is in Seoul.", + "I heard it's in Busan.", "No, Cutshion's head office is in Seoul."), + # ---------- a question after words around it: the question is what counts ---------- + ("ko", "인플레이션이 뭐꼬?", "물가가 전체적으로 계속 오르는 거예요.", + "아 맞다, 근데 와 생기노?", "돈이 많이 풀리거나 사려는 사람이 많을 때, 또 비용이 오를 때 생겨요."), + ("ko", "인플레이션이 뭐꼬?", "물가가 전체적으로 계속 오르는 거예요.", + "그기 나쁜 기가?", "조금 오르는 건 정상이지만, 많이 오르면 월급과 저축의 가치가 줄어서 나빠요."), + ("en", "What's inflation?", "Prices in general going up over time.", + "Oh, wait, why does it happen?", "When there's a lot of money around or costs go up, prices rise."), + ("en", "What's inflation?", "Prices in general going up over time.", + "Hmm, quick one: is it bad?", "A little is normal; a lot eats into wages and savings."), + ("ko", "부산 인구 얼마나 되노?", "약 330만 명이에요.", + "고맙데이. 근데 서울은?", "서울은 약 940만 명이에요."), + ("ko", "부산 인구 얼마나 되노?", "약 330만 명이에요.", + "와 그래 많노?", "서울 다음으로 큰 도시고, 큰 항구가 있어서 사람이 많이 모였어요."), + ("ko", "부산 인구가 얼마나 됩니까?", "약 330만 명입니다.", + "그러면 서울은 어떻습니까?", "서울은 약 940만 명입니다."), + ("en", "How many people live in Busan?", "About 3.3 million.", + "Thanks. And Seoul?", "About 9.4 million."), +] + + def pick_followup(said, before_q, before_a, lang, k=2): """Up to k FOLLOWUPS closest to this follow-up: the follow-up's own words count most (a "why?" shows a "why?"), then the talk before it; same language first.""" diff --git a/assistant/voice_words.py b/assistant/voice_words.py index 43d45e3..a7b2d4c 100644 --- a/assistant/voice_words.py +++ b/assistant/voice_words.py @@ -77,7 +77,8 @@ def read(text, last=""): """("volume" | "speed", +1 | -1) when the words ask Lumi to speak louder / quieter / faster / slower, else None. `last` is the assistant's answer just before (brain history): after "ACTION: voice volume +1" a bare "more" / "again" / "조금 더" asks for the same again.""" - t = text or "" + from assistant import wording + t = wording.polite(wording.ko_plain(text or "")) # every speech level as 반말, no "if you don't mind" again = re.match(r"ACTION: voice (volume|speed) ([+-]1)\b", last or "") if again and driving.AGAIN.search(driving.clean(t)): return again.group(1), int(again.group(2)) diff --git a/assistant/wording.py b/assistant/wording.py index eab45b9..881c4bf 100644 --- a/assistant/wording.py +++ b/assistant/wording.py @@ -343,6 +343,36 @@ NOT_LATER = re.compile(r"[\s,;]*\b(?:and |but |so )?(?:not|no) (?:later(?! than) # "go to the stage, right now, not later", "지금 가, 나중 말고": said to mean now; the later-time guards must not see it +POLITE_FRAME = re.compile( # a polite frame around a request: "wave, if you don't mind", "I'd love it if you could wave" + r"[\s,]*\bif you (?:don'?t|do not|wouldn'?t|would not) mind\b[\s,]*(?=[.!?]*$)|" + r"^\W*if you (?:don'?t|do not|wouldn'?t|would not) mind\b[\s,]*|[\s,]*\bif you please\b|" + r"\b(?:i'?d|i would|we'?d|we would) (?:really )?(?:love|like|appreciate) it if you(?: could| would| can|(?!\s+\w+ed\b))\b|" + r"\b(?:it'?d|it would|that would|that'?d|it'?ll|it will) be (?:really |so |very )?(?:great|nice|good|lovely|awesome|cool|" + r"helpful|wonderful|amazing|fantastic) if you(?: could| would| can|(?!\s+\w+ed\b))\b|" + r"\bit would help (?:me |us )?(?:a lot )?if you(?: could| would)?\b", re.I) + + +def _base_verb(w): + """'waved' -> 'wave', 'stopped' -> 'stop', 'turned' -> 'turn'.""" + if w.endswith("ed") and len(w) > 4: + if w[-3] == "e" or w[-3] in "cvsz" and w[-4] not in "aeiou" or w.endswith(("aved", "oved", "ived")): + return w[:-1] + return w[:-3] if w[-3] == w[-4] else w[:-2] + return w + + +def polite(t): + """The words without an English polite frame (POLITE_FRAME): "wave, if you don't mind" -> "wave", "I'd love it + if you could wave" -> "please wave", "I'd love it if you waved at us" -> "please wave at us". Korean frames are + ko_plain's.""" + t = re.sub(r"\b((?:love|like|appreciate) it|be (?:really |so |very )?(?:great|nice|good|lovely|awesome|cool|helpful|" + r"wonderful|amazing|fantastic)) if you (\w+ed)\b", lambda m: f"{m.group(1)} if you could {_base_verb(m.group(2))}", + t or "", flags=re.I) + out = POLITE_FRAME.sub(lambda m: " please " if re.search(r"\bif you(?: could| would| can)?$", m.group(0), re.I) and + not re.search(r"mind|please", m.group(0), re.I) else " ", t or "") + return re.sub(r"\s{2,}", " ", out).strip(" ,") or (t or "") + + def now_not_later(t): """The words without "not later" / "나중 말고" (NOT_LATER).""" return re.sub(r"\s{2,}", " ", NOT_LATER.sub(" ", t or "")).strip() or (t or "") @@ -393,6 +423,11 @@ KO_PLAIN = [ (re.compile(r"(?, ) asked about again"); wrong claims ("나 안경 안 꼈지?" with glasses on); every say new against rounds 1–4 and the earlier r6 seeing files | | `memory_dialogues` (+ `_b`) | 184/156 (1036/878), _b 196/164 (1061/929) | NEW set (HANDOFF §16.3): dialogue fields `now` (ISO clock) and `memory` {`talks` [{title, when, person, summary, facts, commands}], `seen` [{object, colour, where, when}], `self` {arm, gripper, holding, head, lift_mm, place, doing, battery}, `forget_person`} to load into a fake store; turns in dialogues_mixed format; recall by topic (+ day / time), facts of that talk, topics never talked about (offer the closest or "can't remember", never yes), "what did we talk about yesterday", older than 48 h (only the last two days), seen today yes (place / time) / no / other colour, "do what we said" (`ask \| none`: read back first), "forget this / 잊어 줘" (NEW token `forget`, later recall not answered with its facts), name told or not, self state from the self line, a topic from earlier in the same talk; must_not "I have no memory", "ask staff", hesitation | | `questions_world` (+ `_b`) | 976/966, _b 215/237 | NEW set: `CASES = [{"text", "lang", "kind" (lumi / company / jaka / weather / news / web / time), "expect", "must", "must_not", "q" (meaning id), "crowd", "mix"}]`; 52 meanings (_b 14 more) in 30+ wordings each. NEW expect tokens: `quick` (a fixed fact at once, no LLM: name, what, age, maker, height, weight, speed, battery life, languages, which AI, alive, what can you do, time / date / day), `knowledge` (from the notes, never online: other Lumi facts, Cutshion, JAKA), `lookup:weather` / `lookup:news` / `lookup:web` (looked up; no must on changing content), `unknown` (not in the notes: a not-sure phrase, no guessed value) | | `questions_world_c` | 1012/1006 | growth file, questions_world format: 45 new meanings (new `q` ids), 42+ wordings each, 77 % Korean / mixed (all speech levels, elderly 하십시오체, 경상도 dialect, omitted subjects, Konglish, slips, false claims): Lumi (head / waist turn, DOF, microphones, TTS, speech recognition, reply time, repeatability, gripper and width, paper cups, emergency stop, pushing, map accuracy, step / slope, passage, carrying speed, learning, ultrasonic sensors), Cutshion (slogan, TIPS, seed investment, exhibitions, Pionoid, CUVision, GOMCOOK, candy ball / palletizing / education robots, US office, Daegu branch), JAKA (customers, branches, K1, Lumi platform, Mini), weather (fine dust, snow, other cities), news (tech, top story), web (Australia's capital, KOSPI), time (days to Christmas, the month) | +| `questions_world_d` | 364/369 | night 3, generator `gen_questions_d.py` (seed 6621): 56 NEW meanings (q ids new) from knowledge/: Lumi (footprint, top height, base / arm weight, reach, payload, gripper speed, cup tilt, what it picks, floor and doors and faces = can't, YOLOv8, base camera range, lidar blind spots, battery spec, self-charging, computer specs, navigation computer, model size / maker, Ollama, Python, teaching, hearing range, 3 m move limit, drive, end tools, clip mic, number of songs; unknown: charge time, learning algorithm), Cutshion (founding month, lab, venture, partners, VivaTech, US deal, ice cream robot, drawing robot customers, TUSK, PEITIAN; unknown: hiring, office hours, warranty), JAKA (patents, installed base, K1L, K1W, Pro, FAST / Mars, Coboπ; unknown: founder), web (Hallasan, yen rate, this year's Nobel, Korean Series). Korean in six speech levels, Konglish, false claims, slips; NEW field `level`; "can't" meanings have two must regexes (a no-word and the topic word) | | `unknowns` (+ `_b`) | 247/250, _b 72/78 | round 4 format; JAKA facts from the notes as known (2014, Shanghai / Changzhou, the name, 21.9 %, K1 / K1L …); unknown: JAKA CEO / staff / prices, Lumi internals the notes don't give (charge time, ROS, night vision, waterproof, OS …), Cutshion plans, staff names, conference / venue facts (schedule, Wi-Fi, tickets, parking) | Number patterns in regexes are written `(? logs/ko_levels.md, a table by level and the misses + .venv/bin/python tests/ko_levels_check.py wave turn # only these capabilities +""" +import collections +import pathlib +import sys + +from assistant import brain, voice_words +from tests import command_check +from tests.blind.maps import MAPS + +ROOT = pathlib.Path(__file__).resolve().parents[1] +MARKS = MAPS["office"] + +# name: (English request, Korean words before the verb, verb stem, its 아/어 form, Konglish / mixed forms) +CAPS = { + "go_to": ("go to p3", "p3로", "가", "가", ["p3로 고 해 줘", "go to p3 해 주세요"]), + "home": ("go home", "홈으로", "가", "가", ["홈으로 무브 해 줘"]), + "forward": ("move forward one meter", "앞으로 1미터", "가", "가", ["포워드로 1미터 가 줘"]), + "back": ("move back half a meter", "뒤로 50센티", "가", "가", ["백으로 50센티 가 주세요"]), + "turn": ("turn left", "왼쪽으로", "돌", "돌아", ["레프트로 턴 해 줘", "왼쪽으로 turn 해 주세요"]), + "turn45": ("turn right 45 degrees", "오른쪽으로 45도", "돌", "돌아", ["라이트로 45도 턴 해요"]), + "look": ("look left", "왼쪽", "보", "봐", ["왼쪽 룩 해 줘"]), + "look_up": ("look up", "위를", "보", "봐", ["업 봐 줘"]), + "head_up": ("raise your head", "고개", "들", "들어", ["헤드 업 해 줘"]), + "head_dn": ("lower your head", "고개", "숙이", "숙여", ["고개 다운 해 줘"]), + "wave": ("wave", "손", "흔들", "흔들어", ["웨이브 해 줘", "wave 해 주세요"]), + "shake": ("let's shake hands", "악수", "하", "해", ["셰이크 핸드 해 줘"]), + "reach": ("give me your hand", "손", "내밀", "내밀어", []), + "follow": ("follow me", "저를", "따라오", "따라와", ["팔로우 미 해 줘", "follow me 해 주세요"]), + "come": ("come here", "이리", "오", "와", ["컴 히어 해 줘"]), + "stop": ("stop", "", "멈추", "멈춰", ["스탑 해 주세요"]), + "fetch": ("bring me the cup", "컵", "가져오", "가져와", []), + "pick": ("pick up the cup", "컵", "집", "집어", ["컵 픽업 해 줘"]), + "fold": ("fold your arm", "팔", "접", "접어", []), + "sing": ("sing a song", "노래", "부르", "불러", ["노래 싱 해 줘"]), + "louder": ("speak louder", "더 크게", "말하", "말해", []), + "slower": ("speak slower", "좀 천천히", "말하", "말해", []), +} +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 {}"] +# English forms where the verb must be first ("would you mind ...ing" is not made: no gerunds here) + + +def _j(c): + n = ord(c) - 0xAC00 + return (n // 588, n // 28 % 21, n % 28) if 0 <= n < 11172 else None + + +def _with_final(c, final): + l, v, _ = _j(c) + return chr(0xAC00 + (l * 21 + v) * 28 + final) + + +def hon(stem): + """The stem before an honorific -시- ending: 돌 -> 도, 집 -> 집으, 가 -> 가.""" + j = _j(stem[-1]) + if j[2] == 8: # ㄹ drops: 도세요, 흔드세요 + return stem[:-1] + _with_final(stem[-1], 0) + return stem + "으" if j[2] else stem + + +def ul(stem): + """The stem's 관형형 before 수 / 줄: 가 -> 갈, 돌 -> 돌, 집 -> 집을.""" + j = _j(stem[-1]) + if j[2] == 8: + return stem + return stem + "을" if j[2] else stem[:-1] + _with_final(stem[-1], 8) + + +def past(a): + """The past of the 아/어 form: 돌아 -> 돌았, 가 -> 갔, 해 -> 했.""" + return a[:-1] + _with_final(a[-1], 20) + + +def levels(pre, stem, a): + """{level: [Korean forms]} for one verb phrase.""" + p = (pre + " ") if pre else "" + h = hon(stem) + return { + "반말": [f"{p}{a}", f"{p}{a} 줘", f"{p}{a} 줄래?", f"{p}{a} 줄 수 있어?", f"{p}좀 {a} 줘"], + "friendly": [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} 줄래요?", f"{p}{a} 줄 수 있어요?", f"{p}좀 {a} 주세요"], + "하십시오": [f"{p}{h}십시오", f"{p}{a} 주십시오", f"{p}{a} 주시겠습니까?", f"{p}{a} 주시기 바랍니다", + f"{p}{a} 주실 수 있습니까?"], + "하게": [f"{p}{a} 주게", f"{p}{a} 주시게"], + "honorific": [f"{p}{h}세요", f"{p}{a} 주시겠어요?", f"{p}{a} 주실 수 있으신가요?", f"{p}{a} 주셨으면 해요", + f"{p}{a} 주시면 감사하겠습니다", f"{p}{a} 주시길 부탁드립니다", f"{p}{a} 주세요, 부탁드립니다", + f"루미 씨, {p}{a} 주시겠어요?"], + "question": [f"{p}{a} 주면 안 돼?", f"{p}{a} 주면 안 될까요?", f"{p}{a} 주실래요?", f"{p}{ul(stem)} 수 있으세요?", + 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(' ', '')} 줘"], + } + + +def not_now(pre, stem, a): + """The same phrase with no order now: a past, an ability question, a negation, a later time, a condition.""" + p = (pre + " ") if pre else "" + return [f"아까 {p}{past(a)}어요", f"어제 {p}{past(a)}잖아", f"{p}{ul(stem)} 줄 알아요?", f"{p}{stem}지 마세요", + f"{p}{stem}지 마", f"이따가 {p}{a} 주세요", f"제가 손 들면 {p}{a} 주세요", f"{p}{a} 주면 어떻게 돼요?", + f"우리 애가 {p}{past(a)}어요", f"{p}{hon(stem) if _j(stem[-1])[2] == 8 else stem}는 거 봤어요"] + + +def read(text): + """The reading lumi.answer()'s rules give (None: left to the LLM).""" + voice = voice_words.read(text, "") + if voice: + return f"voice {voice[0]} {voice[1]:+d}" + return command_check.rules(text, "idle", MARKS, brain.Brain()) + + +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): + """rows: (capability, level, text, reading, want, verdict) with verdict right / missed / wrong / motion.""" + rows = [] + for name, (en, pre, stem, a, mixed) in CAPS.items(): + if names and name not in names: + continue + want = read(en) + forms = {"en": [f.format(en) for f in EN_FORMS], **levels(pre, stem, a), "konglish": mixed} + 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): + got = read(t) + moves = got is not None and got.split()[0] not in 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")) # a stop or a song moves nothing + return rows + + +def report(rows): + by = collections.defaultdict(collections.Counter) + for name, level, *_, v in rows: + by[level][v] += 1 + lines = ["# Korean speech levels against English (tests/ko_levels_check.py)", "", + "| level | right | missed | wrong | motion | total |", "|---|---|---|---|---|---|"] + for level, c in by.items(): + lines.append(f"| {level} | {c['right']} | {c['missed']} | {c['wrong']} | {c['motion']} | {sum(c.values())} |") + tot = collections.Counter(v for *_, v in rows) + lines += [f"| all | {tot['right']} | {tot['missed']} | {tot['wrong']} | {tot['motion']} | {len(rows)} |", "", + "## Not right", ""] + lines += [f"- {name} [{level}] {t!r} -> {got} (want {want})" for name, level, t, got, want, v in rows if v != "right"] + return "\n".join(lines) + "\n" + + +if __name__ == "__main__": + out = report(check(set(sys.argv[1:]) or None)) + (ROOT / "logs" / "ko_levels.md").write_text(out) + print(out[:out.index("## Not right")]) diff --git a/vision/pointing.py b/vision/pointing.py index 5aaf92c..bd091ee 100644 --- a/vision/pointing.py +++ b/vision/pointing.py @@ -67,12 +67,12 @@ _ASK = [(re.compile(_LEAD + _GO_EN + rf" (?:{w}){_END}", re.I), k) for w, k in ( _PAD_EN = (r"(?:(?:hey|hi|ok|okay|so|um+|uh+|er+|hmm+|oh|alright|listen|robot|lumi|buddy|bro|now|please|pls|you|young man|" r"kindly|dear|command:|test one:|quick|excuse me|well|sorry|right|yo|my turn|you mind\?|you mind)[\s,.!:]*)*") _FRAME_EN = (r"(?:(?:(?:can|could|would|will) (?:you|u)(?: maybe| please| kindly)? |why don'?t you |how about you |i (?:want|need|order) " - r"you to |let'?s see (?:you|u) |be a dear and |would you be so kind as to |mind if i ask you to |try to |" + r"you to |let'?s see (?:you|u) |be a (?:dear|love|doll|sweetie) and |would you be so kind as to |mind if i ask you to |try to |" r"go ahead and |you think you could |maybe |i'?d like you to |would it be possible to |kindly |please |pls |you |" r"(?:you|u) (?:must|will|can) |let'?s have you |could i ask you to |i'?d love it if you could |if you don'?t mind,? |" r"i was hoping you could |can |next,? |attention lumi,? |oi |erm,? )*)") _VERB_EN = r"(?:go|come|move|moov|drive|driive|walk|head|get|roll)(?: over| on over)?(?: and)?(?: stand)?|go stand|stand" -_THERE2_EN = (r"(?:over )?there(?:,? where i(?:'m| am) pointing(?: now)?)?|ovr there|that way|" +_THERE2_EN = (r"(?:over )?(?:there|dare|dere)(?:,? where i(?:'m| am) pointing(?: now)?)?|ovr there|that way|" r"(?:to|too) (?:that|the|teh) (?:spot|spoot|place|lpace|point)(?: over there)?(?: i(?:'m| am) (?:showing|sowing) (?:you|u)| " r"i(?:'m| am) pointing(?: at| to)?)?|(?:to |too )?where (?:i|my finger) points?|(?:to |too )?where i(?:'m| am) pointing(?: at| to)?") _END_EN = (r"(?:[\s,.]*(?:please|pretty p+lease|now|bro|thanks|for us|for me|if you would|will ya|okay|ok|dear|immediately|go|"