Improve command, cup task and talk understanding in English and Korean
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -211,6 +211,17 @@ _BANK = {
|
|||||||
("What's the capital of Australia?", "none", "Canberra, not Sydney."),
|
("What's the capital of Australia?", "none", "Canberra, not Sydney."),
|
||||||
("Who's the president of France right now?", "search", "Let me check."),
|
("Who's the president of France right now?", "search", "Let me check."),
|
||||||
("What's the score of today's Dodgers game?", "search", "Let me check."),
|
("What's the score of today's Dodgers game?", "search", "Let me check."),
|
||||||
|
("how fast can a cheetah run?", "none", "Up to about 110 km/h, in short sprints."),
|
||||||
|
("Why so fast?", "none", "A light body, a very bendy spine and long legs make each stride huge."),
|
||||||
|
("A giraffe neck, how many bones it has?", "none", "Seven, the same as ours; each bone is just very long."),
|
||||||
|
("How long does a baby kangaroo stay in the pouch?", "none", "About six to eight months, then it hops out."),
|
||||||
|
("how much does a sloth sleep, like per day?", "none", "About 15 hours a day in the wild."),
|
||||||
|
("Namsan tower height is how much?", "none", "N Seoul Tower is about 236 metres; on the mountain top about 480 metres above the sea."),
|
||||||
|
("How quickly does a sunflower grow?", "none", "In good sun up to a few centimetres a day; it reaches two to three metres in a summer."),
|
||||||
|
("Can elephants really not jump?", "none", "Yes, they can't: their legs are built to carry weight, and one foot always stays on the ground."),
|
||||||
|
("Oh right, what's a hanok?", "none", "A traditional Korean house, with a tiled or thatched roof and floor heating."),
|
||||||
|
("Wait, what's the coldest place on Earth?", "none", "Antarctica; near Vostok station it once fell to about minus 89 °C."),
|
||||||
|
("What's the newest iPhone?", "search", "Let me check."),
|
||||||
],
|
],
|
||||||
"ko": [
|
"ko": [
|
||||||
("사람이 달에 처음 간 게 언제야?", "none", "1969년 7월, 아폴로 11호 때예요."),
|
("사람이 달에 처음 간 게 언제야?", "none", "1969년 7월, 아폴로 11호 때예요."),
|
||||||
@@ -230,7 +241,21 @@ _BANK = {
|
|||||||
("에펠탑은 언제 세워지셨는지 여쭤봐도 될까요?", "none", "1889년 파리 만국박람회 때 완공됐어요."),
|
("에펠탑은 언제 세워지셨는지 여쭤봐도 될까요?", "none", "1889년 파리 만국박람회 때 완공됐어요."),
|
||||||
("호주 수도가 어디게?", "none", "캔버라예요. 시드니가 아니에요."),
|
("호주 수도가 어디게?", "none", "캔버라예요. 시드니가 아니에요."),
|
||||||
("지금 프랑스 대통령 누구야?", "search", "확인해 볼게요."),
|
("지금 프랑스 대통령 누구야?", "search", "확인해 볼게요."),
|
||||||
("오늘 야구 결과 어떻게 됐어요?", "search", "확인해 볼게요."),
|
("오늘 야구 몇 대 몇으로 끝났어요?", "search", "확인해 볼게요."),
|
||||||
|
("된장은 어떻게 만듭니까?", "none", "삶은 콩으로 메주를 쑤어 띄운 뒤 소금물에 담가 숙성시키고, 건더기를 건져 만듭니다."),
|
||||||
|
("김치 맛을 시게 만드는 건 뭐임?", "none", "유산균이에요. 익으면서 젖산을 만들어서 신맛이 나요."),
|
||||||
|
("치타는 을매나 빨리 뛰노?", "none", "짧게는 시속 110킬로미터쯤까지 달려요."),
|
||||||
|
("기린 목뼈 그거 몇 개야?", "none", "일곱 개예요. 사람이랑 같은데 하나하나가 아주 길어요."),
|
||||||
|
("캥거루 새끼는 주머니에 얼마나 있습니까?", "none", "약 6개월에서 8개월 동안 주머니에서 지냅니다."),
|
||||||
|
("나무늘보는 하루에 얼마나 자요?", "none", "야생에서는 하루에 15시간쯤 자요."),
|
||||||
|
("남산타워 height 몇 m예요?", "none", "N서울타워는 약 236미터이고, 산 위라서 해발로는 480미터쯤이에요."),
|
||||||
|
("해바라기는 얼마나 빨리 커?", "none", "햇빛이 좋으면 하루에 몇 센티미터씩, 여름 한철에 2~3미터까지 자라요."),
|
||||||
|
("코끼리가 점프를 못 한다는 게 참말이가?", "none", "네, 맞아요. 다리가 무게를 받치게 생겨서 항상 한 발은 땅에 있어요."),
|
||||||
|
("고래는 숨을 얼마나 참으실 수 있는지 여쭤봐도 될까요?", "none", "향유고래는 한 시간 넘게도 참을 수 있어요."),
|
||||||
|
("아 맞다, 판소리가 뭐야?", "none", "북 장단에 맞춰 한 사람이 노래와 말로 긴 이야기를 들려주는 우리 전통 음악이에요."),
|
||||||
|
("잠깐, 세상에서 제일 긴 강은?", "none", "나일강이에요. 약 6,650킬로미터예요."),
|
||||||
|
("그건 그렇고 정확히 몇 킬로?", "none", "약 6,650킬로미터예요. 아마존강과 비슷해서 재는 방법에 따라 달라요."),
|
||||||
|
("요즘 나온 갤럭시 최신 모델 뭐야?", "search", "확인해 볼게요."),
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,47 @@
|
|||||||
|
"""Cup-task wordings for the intent bank (F1, night 4): fetch from a place said in every way ("the cup on p2",
|
||||||
|
"p2에 있는 컵", "피원 컵을", "move the cup from A to B", "옮겨"), at every Korean level; and "no": the same words
|
||||||
|
reported, asked about, put off or taken back (nothing moves). The words decide the fields (brain.parse_fetch)."""
|
||||||
|
|
||||||
|
_KO_FETCH = ["<place>에 있는 <obj> 가져와", "<place>에 있는 <obj> 좀 갖다 줘", "<place>에 놓인 <obj> 가져와",
|
||||||
|
"<place> <obj> 가져와", "<place>의 <obj> 가져다 줘", "<place> 위에 있는 <obj> 가져와",
|
||||||
|
"<place>에서 <obj> 집어서 가져와", "<place>에서 <obj> 들고 와", "<place>에 있는 <obj>을 여기로 가져와",
|
||||||
|
"<place>에서 <obj> 좀 챙겨 와", "<place>에 있는 <obj> 옮겨 와"]
|
||||||
|
_KO_END = [("가져와", ["가져와", "가져와요", "가져오세요", "가져오십시오", "가져와 주세요", "가져와 주시겠어요?",
|
||||||
|
"가져와 주시겠습니까?", "가져와 줄래?", "가져오게", "가져와 주게나", "가져온나", "가져와유",
|
||||||
|
"가져와 주이소", "가져와 주실 수 있으신가요?", "가져와 주시면 감사하겠습니다"]),
|
||||||
|
("갖다 줘", ["갖다 줘", "갖다 주세요", "갖다 주십시오", "갖다 주실래요?", "갖다 주게", "갖다 줘유",
|
||||||
|
"갖다 주이소", "갖다 주시겠어요?", "갖다 드려 주세요"]),
|
||||||
|
("가져다 줘", ["가져다 줘", "가져다 주세요", "가져다 주십시오", "가져다 주시겠습니까?", "가져다 주게나"]),
|
||||||
|
("들고 와", ["들고 와", "들고 와요", "들고 오세요", "들고 오십시오"]),
|
||||||
|
("챙겨 와", ["챙겨 와", "챙겨 와요", "챙겨 오세요"]),
|
||||||
|
("옮겨 와", ["옮겨 와", "옮겨 와 주세요", "옮겨 오십시오"])]
|
||||||
|
|
||||||
|
_EN_FETCH = ["bring me the <obj> on <place>", "get me the <obj> that's on <place>", "fetch the <obj> sitting at <place>",
|
||||||
|
"grab the <obj> at <place> and bring it here", "bring the <obj> over from <place>",
|
||||||
|
"<place> <obj>, bring it to me", "go to <place>, get the <obj> and bring it back to me",
|
||||||
|
"pick up the <obj> at <place> and bring it to me", "the <obj> on <place>, could you fetch it",
|
||||||
|
"move the <obj> from <place> over here", "carry the <obj> from <place> to me"]
|
||||||
|
_EN_FRAME = ["{}", "please {}", "could you {}", "would you mind, {}", "can you {} for me", "{} please", "lumi, {}",
|
||||||
|
"hey robot, {}", "excuse me, {}", "i need you to {}", "{} real quick", "do me a favour and {}"]
|
||||||
|
|
||||||
|
_NO = ["did you bring the <obj> from <place>?", "you brought the <obj> from <place> yesterday", "can you bring cups at all?",
|
||||||
|
"don't bring the <obj> from <place>", "i'll bring the <obj> from <place> myself", "tomorrow bring the <obj>",
|
||||||
|
"maybe later you can bring the <obj> from <place>", "my friend brought the <obj> from <place>",
|
||||||
|
"she asked whether you can fetch things", "bring me the <obj> from <place>, no wait, never mind",
|
||||||
|
"<place>에서 <obj> 가져왔어?", "어제 <obj> 가져왔지?", "<place>에서 <obj> 가져오지 마", "내가 <obj> 가져올게",
|
||||||
|
"나중에 <obj> 가져와 줘", "<obj> 가져올 수 있어?", "친구가 <place>에서 <obj> 가져왔대", "<obj> 가져오는 거 봤어",
|
||||||
|
"<place>에서 <obj> 가져와, 아 아니다 됐어", "<obj> 가져오시면 안 됩니다", "<obj> 가져다 주실 필요 없어요",
|
||||||
|
"할머니가 <obj> 가져오라고 하셨는데 괜찮아", "<obj> 가져오는 건 내일 해", "<place>에서 <obj> 가져다 줄 수 있나 궁금하네"]
|
||||||
|
|
||||||
|
|
||||||
|
def _ko():
|
||||||
|
"""Each wording with the endings of every level for its verb."""
|
||||||
|
out = []
|
||||||
|
for base in _KO_FETCH:
|
||||||
|
for verb, ends in _KO_END:
|
||||||
|
if base.endswith(verb):
|
||||||
|
out += [f"{base[:-len(verb)].rstrip()} {e}" for e in ends]
|
||||||
|
return out
|
||||||
|
|
||||||
|
|
||||||
|
INTENT = {"fetch": sorted(set(_ko() + [f.format(c) for c in _EN_FETCH for f in _EN_FRAME])), "no": _NO}
|
||||||
@@ -227,3 +227,27 @@ QUICK["no"] = QUICK.get("no", []) + [
|
|||||||
"시간 괜찮아요", "시간 돼요", "give me a second", "give me a minute", "give me some time", "do you have time",
|
"시간 괜찮아요", "시간 돼요", "give me a second", "give me a minute", "give me some time", "do you have time",
|
||||||
"이름 지어 줄까", "내 이름은 민수야", "제 이름 기억해요", "우리 애 몇 살 같아요", "제가 몇 살 같아요", "나 몇 살로 보여",
|
"이름 지어 줄까", "내 이름은 민수야", "제 이름 기억해요", "우리 애 몇 살 같아요", "제가 몇 살 같아요", "나 몇 살로 보여",
|
||||||
"누가 이겼어", "누가 더 빨라", "몇 시에 끝나요", "몇 시에 시작해요"]
|
"누가 이겼어", "누가 더 빨라", "몇 시에 끝나요", "몇 시에 시작해요"]
|
||||||
|
|
||||||
|
# ---------- night 4: Konglish verbs and short dialect forms ko_plain does not turn into the plain verb ----------
|
||||||
|
INTENT["pick"] += _v(["<obj> 그랩 해", "<obj> 그랩", "<obj> 픽 해", "<obj> 픽업해", "<obj> 캐치 해", "<obj> 홀드 해",
|
||||||
|
"<obj> 잡아 봐라", "<obj> 집어 도", "<obj> 쫌 집어"], ("", " 줘"))
|
||||||
|
INTENT["fetch"] += _v(["<obj> 겟 해 와", "<obj> 겟해 와", "<obj> 브링 해", "<obj> 가져와 봐라", "<obj> 갖고 온나",
|
||||||
|
"<obj> 퍼뜩 가져와", "<obj> 쫌 갖다 도", "나한테 <obj> 브링"], ("", " 줘"))
|
||||||
|
INTENT["follow"] += _v(["팔로우 해", "나 팔로우", "날 팔로우", "come with 나", "나랑 같이 가", "같이 가자 루미",
|
||||||
|
"내 뒤로 붙어", "졸졸 따라 댕겨", "따라 온나"], ("", " 줘"))
|
||||||
|
INTENT["come"] += _v(["컴 히어", "컴온 히어", "이리로 컴", "여기로 컴", "가까이 컴", "이리 온나", "일로 온나", "이리 오이라"],
|
||||||
|
("", " 해", " 해 줘"))
|
||||||
|
INTENT["wave"] += _v(["웨이브 해", "하이 해", "바이바이 해", "빠이빠이 해", "손 인사 해", "손으로 인사 해", "핸드 웨이브 해",
|
||||||
|
"손 흔들어 봐라", "손 쫌 흔들어"], ("", " 줘", " 봐"))
|
||||||
|
INTENT["arm_reach"] += _v(["손 줘라", "핸드 줘", "암 내밀어", "핸드 아웃 해", "손 쭉 내밀어 봐라", "팔 뻗어 봐라",
|
||||||
|
"손 이리 도", "손 쫌 도"], ("", " 줘"))
|
||||||
|
INTENT["arm_fold"] += _v(["암 다운 해", "암 폴드 해", "arm fold 해", "팔 원위치 해", "팔 집어넣어", "손 거둬 들여",
|
||||||
|
"팔 접어 봐라"], ("", " 줘"))
|
||||||
|
INTENT["look"] += _v(["룩 업 해", "룩 다운 해", "업 봐", "다운 봐", "레프트 봐", "라이트 봐", "위로 룩", "아래로 룩",
|
||||||
|
"고개 쫌 들어", "고개 쫌 숙여", "고개 들어 봐라", "고개 숙여 봐라"], ("", " 줘"))
|
||||||
|
INTENT["lift"] += _v(["바디 업", "바디 다운", "키 업", "키 다운", "몸 업", "몸 다운", "몸 쫌 올려", "몸 쫌 내려",
|
||||||
|
"키 쫌 키워", "키 쫌 줄여"], ("", " 해", " 해 줘"))
|
||||||
|
INTENT["turn"] += _v(["턴 해", "레프트 턴", "라이트 턴", "라이트로 턴", "레프트로 턴", "백 턴", "유턴 쫌", "한 바퀴 턴",
|
||||||
|
"왼쪽으로 돌아 봐라", "오른쪽으로 돌아 봐라"], ("", " 해", " 해 줘"))
|
||||||
|
INTENT["move"] += _v(["무브 포워드", "고 백", "백 해", "앞으로 무브", "뒤로 무브", "레프트로 무브", "라이트로 무브",
|
||||||
|
"앞으로 쪼매 가 봐라", "뒤로 쫌 빠져"], ("", " 줘"))
|
||||||
|
|||||||
+361
-80
@@ -191,10 +191,13 @@ Facts you know (say the one that is asked, also in a short follow-up; nothing mo
|
|||||||
a passage at least 70 cm wide, no stairs. Lidar: a laser scanner at the bottom of the base, 2 cm to 10 m, 240
|
a passage at least 70 cm wide, no stairs. Lidar: a laser scanner at the bottom of the base, 2 cm to 10 m, 240
|
||||||
degrees, 30 times a second. You know where you are by comparing the lidar with the map, to within
|
degrees, 30 times a second. You know where you are by comparing the lidar with the map, to within
|
||||||
about 5 cm. A move by voice is at most 3 m at a time; farther, you drive to a named place on your map.
|
about 5 cm. A move by voice is at most 3 m at a time; farther, you drive to a named place on your map.
|
||||||
- Battery: 24-volt lithium-ion, 45 Ah; lasts about 10 hours on a charge ("how long on a charge?": 10 hours; how
|
- Battery: 24-volt lithium-ion, 45 Ah; lasts about 10 hours on a charge ("how long on a charge?", "배터리 몇 시간
|
||||||
far you go is given in hours, no distance is known; how long charging takes is not known).
|
가?", "three hours, right?": 10 hours, kept against a wrong number; how far you go is given in hours, no distance
|
||||||
|
is known; only how long charging itself takes is not known). On patrol below 5 percent you drive home to charge
|
||||||
|
and go on (start again) at 60 percent.
|
||||||
- You are made for shops, hotels, schools, labs and exhibitions. You cannot dance, walk, jump or fly: say so.
|
- You are made for shops, hotels, schools, labs and exhibitions. You cannot dance, walk, jump or fly: say so.
|
||||||
- Computer ("processor", "chip", "칩", "컴퓨터"): NVIDIA Jetson AGX Thor (its graphics processor: Blackwell, 2070 TOPS).
|
- Computer ("processor", "chip", "칩", "컴퓨터"): NVIDIA Jetson AGX Thor (its graphics processor: Blackwell, 2070 TOPS;
|
||||||
|
14 processor cores, 122 GB of memory / 메모리).
|
||||||
- Detector: YOLOv8 on your graphics processor, 4 to 13 ms per picture. Speech: Whisper, model large-v3-turbo; answers:
|
- Detector: YOLOv8 on your graphics processor, 4 to 13 ms per picture. Speech: Whisper, model large-v3-turbo; answers:
|
||||||
Gemma 4 26b (Google), served by Ollama; voice: Supertonic TTS; first words about 2 s after a question.
|
Gemma 4 26b (Google), served by Ollama; voice: Supertonic TTS; first words about 2 s after a question.
|
||||||
- Cutshion: makes barista, AI drawing, cooking, ice cream, candy ball, welding, palletizing and educational
|
- Cutshion: makes barista, AI drawing, cooking, ice cream, candy ball, welding, palletizing and educational
|
||||||
@@ -289,7 +292,9 @@ def _notes(hits):
|
|||||||
return "\n\n".join(out) or "(no matching notes)"
|
return "\n\n".join(out) or "(no matching notes)"
|
||||||
|
|
||||||
|
|
||||||
SAID_BEFORE = re.compile(r"\byou said\b|\bearlier you\b|\byou told me\b|아까는|아까 .*(?:라며|했잖|말했)|전에는 .*(?:라며|했잖)", re.I)
|
SAID_BEFORE = re.compile(r"\byou said\b|\bearlier you\b|\byou told me\b|\bthat'?s not what you said\b|\b(?:changed|changing) your (?:answer|story)\b|"
|
||||||
|
r"\bdifferent (?:from|than) (?:before|earlier|what you said)\b|아까는|아까 .*(?:라며|했잖|말했)|전에는 .*(?:라며|했잖)|"
|
||||||
|
r"아까(?:랑|하고|와|캉|카고|이랑)\s*(?:\S+\s+)?(?:다르|달라|틀리|바뀌|바꼈)|말(?:이|을)?\s*(?:바뀐|바뀌|바꼈|바꾸|다르|달라)", re.I)
|
||||||
# the visitor holds Lumi's own answer against it: the fact stays
|
# the visitor holds Lumi's own answer against it: the fact stays
|
||||||
FOLLOW_EXAMPLES_K = 2 # follow-up examples (talk_examples.FOLLOWUPS) shown with a short follow-up
|
FOLLOW_EXAMPLES_K = 2 # follow-up examples (talk_examples.FOLLOWUPS) shown with a short follow-up
|
||||||
|
|
||||||
@@ -406,7 +411,11 @@ Short Korean commands are commands: "컵 가져다 줘" -> fetch cup, "컵 옮
|
|||||||
- weather <place>: the visitor asks about the weather (place in English; - means here, Seoul).
|
- weather <place>: the visitor asks about the weather (place in English; - means here, Seoul).
|
||||||
- search <query>: you need facts from the internet you do not know (news, prices, opening hours, people...).
|
- search <query>: you need facts from the internet you do not know (news, prices, opening hours, people...).
|
||||||
Do not use search for things in the reference notes, the date or the time, nor for opinions, advice, fun
|
Do not use search for things in the reference notes, the date or the time, nor for opinions, advice, fun
|
||||||
facts, recommendations or well-known general knowledge: answer those yourself.
|
facts, recommendations or well-known general knowledge: answer those yourself. Search only what changes or is
|
||||||
|
new (news, prices, scores, schedules, who holds an office now, the newest products). Everything that stays the
|
||||||
|
same is none, answered at once in any wording, dialect or mixed: what a word, a custom or a thing is ("윤초는
|
||||||
|
뭐예요?"), how it is made or works, why, an animal's or plant's body and life, a famous building's height or floors
|
||||||
|
("부엉이 목 을매나 돌아가노?", "tower height 몇 m예요?"), and every follow-up on them.
|
||||||
- Any wording of a command you can do is that command, polite or casual, English, Korean or mixed ("can you shake
|
- Any wording of a command you can do is that command, polite or casual, English, Korean or mixed ("can you shake
|
||||||
your hand?" -> wave, "고개 왼쪽으로 돌려" -> look left, "뒤로 1미터 가" -> move back 1). What your body can't do
|
your hand?" -> wave, "고개 왼쪽으로 돌려" -> look left, "뒤로 1미터 가" -> move back 1). What your body can't do
|
||||||
(jump, dance, fly, climb stairs, open doors, lift heavy things) is none: say plainly that you can't. A person, a
|
(jump, dance, fly, climb stairs, open doors, lift heavy things) is none: say plainly that you can't. A person, a
|
||||||
@@ -494,7 +503,7 @@ OBJECTS = {"cup": "cup", "mug": "cup", "glass": "cup", "tumbler": "cup", "bottle
|
|||||||
"backpack": "backpack", "백팩": "backpack", "suitcase": "suitcase", "캐리어": "suitcase", "여행가방": "suitcase",
|
"backpack": "backpack", "백팩": "backpack", "suitcase": "suitcase", "캐리어": "suitcase", "여행가방": "suitcase",
|
||||||
"hair dryer": "hair drier", "hair drier": "hair drier", "드라이기": "hair drier", "toaster": "toaster",
|
"hair dryer": "hair drier", "hair drier": "hair drier", "드라이기": "hair drier", "toaster": "toaster",
|
||||||
"토스터": "toaster", "보틀": "bottle", "물컵": "cup", "유리컵": "cup", "머그잔": "cup",
|
"토스터": "toaster", "보틀": "bottle", "물컵": "cup", "유리컵": "cup", "머그잔": "cup",
|
||||||
"글라스": "cup"}
|
"글라스": "cup", "애플": "apple", "바틀": "bottle"}
|
||||||
# spoken word -> camera class; the classes are skills.GRASPS (tests/test_intents.py checks it): a pick of one the
|
# 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), 책 (책상)
|
# 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
|
_KO_WORD = {"공", "칼"} # one syllable inside other words (공항, 칼국수): only as a word of its own
|
||||||
@@ -529,12 +538,15 @@ BEHIND_WORDS = (r"\blook(?:ing)? (?:over |to(?:wards?)? |at |in )?(?:the |your )
|
|||||||
HEAD_WORDS = (r"\blook (?:straight )?(?:up|down|left|right|ahead|forward|straight|at me|behind|this way|over here|to (?:the|your|my) (?:left|right))\b"
|
HEAD_WORDS = (r"\blook (?:straight )?(?:up|down|left|right|ahead|forward|straight|at me|behind|this way|over here|to (?:the|your|my) (?:left|right))\b"
|
||||||
r"|\blook (?:a (?:little |bit )?)?(?:more |further )?(?:at|to|towards?|on|over|in) (?:the |your |my )?(?:left|right|front)(?: side)?\b"
|
r"|\blook (?:a (?:little |bit )?)?(?:more |further )?(?:at|to|towards?|on|over|in) (?:the |your |my )?(?:left|right|front)(?: side)?\b"
|
||||||
r"|\blook (?:a (?:little |bit )?)?(?:more|further) (?:to (?:the |your )?)?(?:left|right|up|down)\b" # "look at the left side"
|
r"|\blook (?:a (?:little |bit )?)?(?:more|further) (?:to (?:the |your )?)?(?:left|right|up|down)\b" # "look at the left side"
|
||||||
|
r"|(?:왼쪽|오른쪽|좌측|우측)(?:(?:을|를|쪽)?\s*(?:한번\s*|좀\s*)?돌아\s?(?:봐|보)|으로\s*(?:한번\s*|좀\s*)?돌아(?:봐|보))"
|
||||||
|
# "왼쪽을 돌아봐", "오른쪽으로 돌아봐 줄래요?": the head; "왼쪽으로 돌아 봐" (try turning) is the base
|
||||||
r"|" + BEHIND_WORDS +
|
r"|" + BEHIND_WORDS +
|
||||||
r"|\blook at (?:my|this|that|our) (?:son|daughter|kid|child|baby|friend|wife|husband|boy|girl|mom|dad)\b"
|
r"|\blook at (?:my|this|that|our) (?:son|daughter|kid|child|baby|friend|wife|husband|boy|girl|mom|dad)\b"
|
||||||
r"|(?:우리|내|제) (?:애|아이|아들|딸|친구)\s*(?:좀\s*)?(?:봐|쳐다)"
|
r"|(?:우리|내|제) (?:애|아이|아들|딸|친구)\s*(?:좀\s*)?(?:봐|쳐다)"
|
||||||
r"|\b(?:turn|move|rotate|tilt|swing) your head\b|\b(?:raise|lift|lower|drop) your head\b|\bface me\b|\bhead (?:up|down)\b"
|
r"|\b(?:turn|move|rotate|tilt|swing) your head\b|\b(?:raise|lift|lower|drop) your head\b|\bface me\b|\bhead (?:up|down)\b"
|
||||||
r"|(?:고개|머리)(?:를|좀|살짝|조금|약간|\s)*(?:왼쪽|오른쪽|위|아래|정면|앞|들어|숙여|올려|내려|돌려)"
|
r"|(?:고개|머리)(?:를|좀|살짝|조금|약간|\s)*(?:왼쪽|오른쪽|위|아래|정면|앞|들어|숙여|올려|내려|돌려)"
|
||||||
r"|(?:고개|머리)(?:를|좀|\s)*(?:원위치|원래대로|제자리)|\bhead back to (?:the )?(?:centre|center|middle)\b" # the head, not put back
|
r"|(?:고개|머리)(?:를|좀|\s)*(?:원위치|원래대로|제자리)|\bhead back to (?:the )?(?:centre|center|middle)\b" # the head, not put back
|
||||||
|
r"|(?<![가-힣])룩\s*(?:업|다운|앳\s*미)(?![가-힣])|(?<![가-힣])룩\s*(?:왼쪽|오른쪽)" # Konglish "룩 다운 해 주세요"
|
||||||
r"|(?:위|아래|밑|왼쪽|오른쪽|정면|앞|나|날|저|절|나를|저를)(?:를|을|으로|로|쪽|쪽을|에)?\s*(?:\d+\s*도\s*(?:만|쯤|정도)?\s*)?(?:(?:좀|조금|더|약간|살짝)\s*)*(?:봐|보세요|봐요|봐 ?줘|봐 ?주세요|볼래|봐 ?봐)")
|
r"|(?:위|아래|밑|왼쪽|오른쪽|정면|앞|나|날|저|절|나를|저를)(?:를|을|으로|로|쪽|쪽을|에)?\s*(?:\d+\s*도\s*(?:만|쯤|정도)?\s*)?(?:(?:좀|조금|더|약간|살짝)\s*)*(?:봐|보세요|봐요|봐 ?줘|봐 ?주세요|볼래|봐 ?봐)")
|
||||||
LIFT_WORDS = (r"\b(?:raise|lift|lower) (?:yourself|your body|your torso|your upper body)\b|\blift (?:yourself )?(?:up|down)\b(?! (?:the|a|an|that|this|it)\b)"
|
LIFT_WORDS = (r"\b(?:raise|lift|lower) (?:yourself|your body|your torso|your upper body)\b|\blift (?:yourself )?(?:up|down)\b(?! (?:the|a|an|that|this|it)\b)"
|
||||||
r"|\bget (?:a (?:little |tiny )?bit |a little |slightly )?(?:taller|shorter|smaller|higher|lower)\b|\bmake yourself (?:taller|shorter|smaller)\b|\bstand (?:up )?tall(?:er)?\b"
|
r"|\bget (?:a (?:little |tiny )?bit |a little |slightly )?(?:taller|shorter|smaller|higher|lower)\b|\bmake yourself (?:taller|shorter|smaller)\b|\bstand (?:up )?tall(?:er)?\b"
|
||||||
@@ -552,7 +564,8 @@ LIFT_SMALL_MM = 30.0 # mm; "raise yourself a bit"
|
|||||||
def head_target(t):
|
def head_target(t):
|
||||||
"""Normalised words -> "left" | "left 30" | "up small" | "me" | "center"; None for "look up the news"."""
|
"""Normalised words -> "left" | "left 30" | "up small" | "me" | "center"; None for "look up the news"."""
|
||||||
t = re.sub(r"^\W*(?:right|alright|all right|okay|ok)\s*[,.!]\s*", "", t) # "right, look at the floor": okay
|
t = re.sub(r"^\W*(?:right|alright|all right|okay|ok)\s*[,.!]\s*", "", t) # "right, look at the floor": okay
|
||||||
if re.search(r"\blook up\b\s+(?!(?:a |please|lumi|slightly|again|at|to|\d|now|and|then|too|more)\b)[a-z]", t):
|
t = re.sub(r"\b(?:right|straight|directly) (?=at (?:me|us)\b)|\bgo ahead and\b", "", t) # "look right at me": at me
|
||||||
|
if re.search(r"\blook up\b\s+(?!(?:a |please|lumi|slightly|again|at|to|\d|now|and|then|too|more)\b)(?!for (?:me|us)\W*$)[a-z]", t):
|
||||||
return None
|
return None
|
||||||
if re.search(r"\b(?:straight|ahead|forward|center|centre|front)\b|정면|가운데|원위치|원래대로|제자리|(?:^|\s)앞(?:을|으로|쪽)?\s*(?:좀\s*)?(?:봐|보)", t):
|
if re.search(r"\b(?:straight|ahead|forward|center|centre|front)\b|정면|가운데|원위치|원래대로|제자리|(?:^|\s)앞(?:을|으로|쪽)?\s*(?:좀\s*)?(?:봐|보)", t):
|
||||||
return "center"
|
return "center"
|
||||||
@@ -560,13 +573,13 @@ def head_target(t):
|
|||||||
side = "right" if re.search(r"\bright\b|오른쪽", t) else "left" # "over your right shoulder"; left when none
|
side = "right" if re.search(r"\bright\b|오른쪽", t) else "left" # "over your right shoulder"; left when none
|
||||||
return f"{side} {HEAD_YAW[1]:g}"
|
return f"{side} {HEAD_YAW[1]:g}"
|
||||||
for d, words in (("left", r"\bleft\b|왼쪽"), ("right", r"\bright\b|오른쪽"),
|
for d, words in (("left", r"\bleft\b|왼쪽"), ("right", r"\bright\b|오른쪽"),
|
||||||
("up", r"\bup\b|\braise\b|\blift\b|\bceiling\b|\bsky\b|위|들어|올려|천장|하늘"),
|
("up", r"\bup\b|\braise\b|\blift\b|\bceiling\b|\bsky\b|위|들어(?!가|오|와)|올려|천장|하늘|룩\s*업"),
|
||||||
("down", r"\bdown\b|\blower\b|\bdrop\b|\b(?:my |your |the )?(?:feet|shoes?|floor|ground)\b|아래|밑|숙여|내려|"
|
("down", r"\bdown\b|\blower\b|\bdrop\b|\b(?:my |your |the )?(?:feet|shoes?|floor|ground)\b|아래|밑|숙여|내려|룩\s*다운|"
|
||||||
r"바닥|발(?:을|밑|끝)?\s*(?:좀\s*)?봐|신발")):
|
r"바닥|발(?:을|밑|끝)?\s*(?:좀\s*)?봐|신발")):
|
||||||
if re.search(words, t):
|
if re.search(words, t):
|
||||||
deg = re.search(r"(\d+)\s*(?:degrees?|도)?", t) # a bare number on the head is degrees
|
deg = re.search(r"(\d+)\s*(?:degrees?|도)?", t) # a bare number on the head is degrees
|
||||||
return f"{d} {deg.group(1)}" if deg else (f"{d} small" if SMALL.search(t) or MORE.search(t) else d)
|
return f"{d} {deg.group(1)}" if deg else (f"{d} small" if SMALL.search(t) or MORE.search(t) else d)
|
||||||
if re.search(r"\b(?:at me|face me)\b|(?:^|\s)(?:나|날|저|절|나를|저를)\s*(?:좀\s*)?봐|\blook at (?:my|this|that|our) \w+|"
|
if re.search(r"\b(?:at me|face me)\b|룩\s*앳\s*미|(?:^|\s)(?:나|날|저|절|나를|저를)\s*(?:좀\s*)?봐|\blook at (?:my|this|that|our) \w+|"
|
||||||
r"(?:우리|내|제) (?:애|아이|아들|딸|친구)", t): # "look at my son": towards whoever speaks
|
r"(?:우리|내|제) (?:애|아이|아들|딸|친구)", t): # "look at my son": towards whoever speaks
|
||||||
return "me" # after the directions: "look down at me" is down
|
return "me" # after the directions: "look down at me" is down
|
||||||
return None
|
return None
|
||||||
@@ -634,7 +647,7 @@ PUT_BACK = ( # the held thing back where it was picked: "put the banana back w
|
|||||||
r"|\b(?:put|set|place|return|leave|bring)\b.*\bwhere (?:it was|you (?:found|got|picked|took) it)\b"
|
r"|\b(?:put|set|place|return|leave|bring)\b.*\bwhere (?:it was|you (?:found|got|picked|took) it)\b"
|
||||||
r"|\breturn (?:it|that|this|the (?:\w+ )?\w+) to (?:where|its place)"
|
r"|\breturn (?:it|that|this|the (?:\w+ )?\w+) to (?:where|its place)"
|
||||||
r"|^\W*(?:(?:please|now|okay|ok|lumi|robot)\W+)*back (?:to )?where (?:it was|you (?:found|got|picked|took) it)"
|
r"|^\W*(?:(?:please|now|okay|ok|lumi|robot)\W+)*back (?:to )?where (?:it was|you (?:found|got|picked|took) it)"
|
||||||
r"|(?:제자리|원래 ?(?:자리|위치|있던 ?(?:자리|곳|데))|있던 ?(?:자리|곳|데)|원위치)\s*(?:에|로|에다)?\W*(?:(?:갖다|도로|다시|좀|그냥)\s*)*(?:놓|둬|놔|두)"
|
r"|(?:제자리|원래 ?(?:자리|위치|있던 ?(?:자리|곳|데))|있던 ?(?:자리|곳|데)|원위치)\s*(?:에|로|에다)?\W*(?:(?:갖다|도로|다시|좀|그냥|지금|당장|얼른|빨리|어서|퍼뜩|싸게)\s*)*(?:놓|둬|놔|두)"
|
||||||
r"|\breturn (?:it|that|this|the (?:\w+ )?\w+) to (?:its|the|your) (?:spot|place)\b|\bputt (?:it|that|this) back\b"
|
r"|\breturn (?:it|that|this|the (?:\w+ )?\w+) to (?:its|the|your) (?:spot|place)\b|\bputt (?:it|that|this) back\b"
|
||||||
r"|^\W*(?:(?:robot|lumi|please|now|okay|ok)\W+)*return (?:it|that|this|the (?:\w+ )?\w+)\W*$|(?:원래 ?자리|제자리)\s*(?:로\s*)?back\b|\breturn\s*해")
|
r"|^\W*(?:(?:robot|lumi|please|now|okay|ok)\W+)*return (?:it|that|this|the (?:\w+ )?\w+)\W*$|(?:원래 ?자리|제자리)\s*(?:로\s*)?back\b|\breturn\s*해")
|
||||||
INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||||
@@ -650,13 +663,13 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
|||||||
("stop", r"\b(stop|halt|freeze|don'?t move)\b|멈춰|정지|그만 ?가|거기 ?서(?=[\s!.~,]*$)|스톱|움직이지 ?마|^\s*(서[\s,!.]*){2,}$"),
|
("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|"
|
("waist", r"\b(?:turn|rotate|twist|swivel|swing|move|bring|point|face|put)\b[^.?!]{0,25}\b(?:your |the )?(?:waist|upper body|"
|
||||||
r"torso|hips?)\b|\b(?:waist|upper body|torso)\b[^.?!]{0,20}\b(?:left|right|front|forward|center|centre|straight|back|"
|
r"torso|hips?)\b|\b(?:waist|upper body|torso)\b[^.?!]{0,20}\b(?:left|right|front|forward|center|centre|straight|back|"
|
||||||
r"\d+)|(?:허리|상체|몸통|윗몸)(?:를|을|만|좀|\s)*[^.?!]{0,15}(?:돌려|돌리|틀어|비틀|돌아|원위치|정면|가운데|앞으로|원래대로)|"
|
r"\d+)|(?:허리|상체|몸통(?!째)|윗몸|웨이스트)(?:를|을|만|좀|\s)*[^.?!]{0,15}(?:돌려|돌리|돌릴|틀어|비틀|돌아|원위치|정면|가운데|앞으로|원래대로)|"
|
||||||
r"\bwaist\b\s*(?:left|right|turn|돌려|왼쪽|오른쪽)|(?:왼쪽|오른쪽)으?로?\s*(?:허리|상체)|"
|
r"\bwaist\b\s*(?:left|right|turn|돌려|왼쪽|오른쪽)|(?:왼쪽|오른쪽)으?로?\s*(?:허리|상체)|"
|
||||||
r"\b(?:turn|swivel|twist|rotate) your (?:body|trunk)\b[^.?!]{0,30}\bwithout (?:driving|moving (?:your )?(?:base|wheels))|"
|
r"\b(?:turn|swivel|twist|rotate) your (?:body|trunk)\b[^.?!]{0,30}\bwithout (?:driving|moving (?:your )?(?:base|wheels))|"
|
||||||
r"\b(?:turn|swivel|twist|rotate) your trunk\b|허리(?:를)? ?(?:좀 ?)?(?:펴|곧게)|\btorso\b.{0,6}(?:정면|front)"),
|
r"\b(?:turn|swivel|twist|rotate) your trunk\b|허리(?:를)? ?(?:좀 ?)?(?:펴|곧게)|\btorso\b.{0,6}(?:정면|front)"),
|
||||||
# ^ the waist (upper body) only, never the base: "turn your waist left", "허리 왼쪽으로 돌려", "상체 정면으로"
|
# ^ the waist (upper body) only, never the base: "turn your waist left", "허리 왼쪽으로 돌려", "상체 정면으로"
|
||||||
("follow", r"\b(?:follow|following|come with|come along with|come together with|walk with|tag along with)\s+(?:me|us)\b(?!\s+(?:on|at)\b)|" # not "follow
|
("follow", r"\b(?:follow|following|come with|come along with|come together with|walk with|tag along with)\s+(?:me|us)\b(?!\s+(?:on|at)\b)|" # not "follow
|
||||||
r"\bcome along\b|(?<!말 )(?<!말을 )따라\s?(?:와|오세요|오십시오|올래)|(?<!로 )(?:같이|함께)\s?(?:가자|가요|갑시다|걸어)|" # me on instagram"
|
r"\bcome along\b|(?<!말 )(?<!말을 )따라\s?(?:와|오세요|오십시오|올래)|(?<!로 )(?:같이|함께)\s?(?:가자|가요|갑시다|걸어|가(?=\W*$))|" # me on instagram"
|
||||||
r"\b(?:and|then) follow(?: me| along)?\W*(?:(?:please|plz|thanks|bro|now|okay|ok)\W*)*$|"
|
r"\b(?:and|then) follow(?: me| along)?\W*(?:(?:please|plz|thanks|bro|now|okay|ok)\W*)*$|"
|
||||||
r"\b(?:keep|stay|walk|go) (?:right )?behind me\b|\bi(?:'?ll| will) walk,? (?:and )?you follow\b|"
|
r"\b(?:keep|stay|walk|go) (?:right )?behind me\b|\bi(?:'?ll| will) walk,? (?:and )?you follow\b|"
|
||||||
r"^\W*(?:\w+\W+){0,2}(?:you )?follow\W*(?:(?:please|plz|thanks|bro|now|okay|ok)\W*)*$|\bfolow me\b|"
|
r"^\W*(?:\w+\W+){0,2}(?:you )?follow\W*(?:(?:please|plz|thanks|bro|now|okay|ok)\W*)*$|\bfolow me\b|"
|
||||||
@@ -666,10 +679,10 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
|||||||
rf"|\b(go|drive) to\b.*\b(get|take|grab|pick up|fetch|bring)\b.*\b({_OBJ})s?\b"
|
rf"|\b(go|drive) to\b.*\b(get|take|grab|pick up|fetch|bring)\b.*\b({_OBJ})s?\b"
|
||||||
rf"|\b(pick up|pick|take|grab|get)\b.*\b({_OBJ})s?\b.*\b(go|drive) to\b|({_OBJ}).*(집어서|들고).*가서"
|
rf"|\b(pick up|pick|take|grab|get)\b.*\b({_OBJ})s?\b.*\b(go|drive) to\b|({_OBJ}).*(집어서|들고).*가서"
|
||||||
r"|가져와|가져다|갖다|가지고 ?와|갖고 ?(?:와|오)|챙겨 ?오|가져 ?오실|가저 ?(?:와|다)|에서.*\b(?:bring|fetch|brign|fech)\s*해|가져 ?오(?:세요|십시오|시오|너라|거라|게|라|실래요|시겠어요)|가지고 ?오(?:세요|십시오|시오|너라|거라|게|라|실래요|시겠어요)|챙겨 ?와|에서.*(옮겨|가져)" rf"|({_OBJ}).*(집고|들고|가지고).*(와|줘)"),
|
r"|가져와|가져다|갖다|가지고 ?와|갖고 ?(?:와|오)|챙겨 ?오|가져 ?오실|가저 ?(?:와|다)|에서.*\b(?:bring|fetch|brign|fech)\s*해|가져 ?오(?:세요|십시오|시오|너라|거라|게|라|실래요|시겠어요)|가지고 ?오(?:세요|십시오|시오|너라|거라|게|라|실래요|시겠어요)|챙겨 ?와|에서.*(옮겨|가져)" rf"|({_OBJ}).*(집고|들고|가지고).*(와|줘)"),
|
||||||
("come", r"\bcome (?:back )?(here|hear|to me|closer|over here|over|this way)\b|\bcome\b.*\bme\b|이리 ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오|올래)|"
|
("come", r"\bcome (?:back )?(here|hear|to me|closer|over here|over|this way)\b|\bcome\b(?! back for (?:me|us)\b).*\bme\b|이리 ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오|올래)|"
|
||||||
r"(?:여기로|이쪽으로) ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오)|가까이 ?(?:좀 ?)?(?:와|오세요)|"
|
r"(?:여기로|이쪽으로) ?(?:좀 ?)?(?:돌아 ?)?(?:와|오세요|오십시오)|가까이 ?(?:좀 ?)?(?:와|오세요)|"
|
||||||
r"나한테 ?(?:돌아 ?)?와"),
|
r"나한테 ?(?:돌아 ?)?와"),
|
||||||
("go_home", r"\bgo (back )?(home|to (the |your )?(dock(?!2)|charger|charging))|\bgo charge|충전하러|집(?:에|으로) ?가|충전기로"),
|
("go_home", r"\bgo (back )?(home|to (the |your )?(dock(?!2)|charger|charging))|\bhead (back )?to (the |your )(dock(?!2)|charger)\b|\bgo (re)?charge|충전하러|집(?:에|으로) ?가|충전기로"),
|
||||||
("go_point", r"\b(?:go|drive|move|head|come|return|walk|roll|run|proceed|navigate|travel|hurry|make your way|get|take yourself)"
|
("go_point", r"\b(?:go|drive|move|head|come|return|walk|roll|run|proceed|navigate|travel|hurry|make your way|get|take yourself)"
|
||||||
r"(?: back)?(?: over| on| ahead)?(?: to| too| 2|to) (?:the )?(?:point |marker )?([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*?)\b|(\d+)\s*번\s*(?:으로|포인트)"
|
r"(?: back)?(?: over| on| ahead)?(?: to| too| 2|to) (?:the )?(?:point |marker )?([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*?)\b|(\d+)\s*번\s*(?:으로|포인트)"
|
||||||
r"|^\W*(?:(?:루미야?|lumi|hey lumi)\W*)?(?:[a-z][a-z0-9_]*\s*말고\s+)?(?:좀\s*)?(?:point\s+)?([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*?)\s*(?:포인트\s*)?(?:앞|쪽|방향|지점|위치)?\s*"
|
r"|^\W*(?:(?:루미야?|lumi|hey lumi)\W*)?(?:[a-z][a-z0-9_]*\s*말고\s+)?(?:좀\s*)?(?:point\s+)?([a-z][a-z0-9_]*|[가-힣][가-힣0-9_]*?)\s*(?:포인트\s*)?(?:앞|쪽|방향|지점|위치)?\s*"
|
||||||
@@ -690,23 +703,23 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
|||||||
r"\bwave (?:at|to|your|hello|hi|bye|goodbye|bye-bye|back|again|for|one more time|once more|us off)\b|\bgimme a wave\b|\b(?:why don'?t you|if you (?:could|can|would)|"
|
r"\bwave (?:at|to|your|hello|hi|bye|goodbye|bye-bye|back|again|for|one more time|once more|us off)\b|\bgimme a wave\b|\b(?:why don'?t you|if you (?:could|can|would)|"
|
||||||
r"you (?:could|should|can|might)|could you|would you|can you|will you) (?:please |just )?wave\b(?!s)|\b(?:give|do) (?:(?:them|him|her|us|me|everyone|the \w+) )?"
|
r"you (?:could|should|can|might)|could you|would you|can you|will you) (?:please |just )?wave\b(?!s)|\b(?:give|do) (?:(?:them|him|her|us|me|everyone|the \w+) )?"
|
||||||
r"a (?:little |quick |big |friendly )?wave\b|(?<![a-z])(?:wave|웨이브)\s?(?:해|하고|좀)|\bshake (?:for|at|with) (?:us|me)\b|\bsake hands?\b|\bshake (?:your |my |our )?hands?\b(?! with (?!me\b|us\b))|\b(?:give me|do|have|let'?s do) a handshake\b|\bsay (?:hi|hello|bye) with your hand\b|^\W*(?:(?:lumi|hey|okay|ok|please|robot|루미야?)\W+)*(?:sh—\s*)?shake(?: shake)*(?:\W+(?:please|lumi|now|lol))*\W*$|악수\s*(?:좀\s*|한 ?번\s*|도\s*)*(?:하자|해|할래|합시다|하실래|하시죠|하세요|하십시오|할까)|(?:손|송|팔) ?(?:을 |좀 |도 )?흔(?:들|드(?=세요|십시오|시|셔|러|소))|(?:손|송) ?(?:으로 ?)?인사|\bbye wave\b|(?:보고|향해|한테|에게)\s*(?:wave|웨이브)\b|\b(?:wayve|wavve|waive)\b|"
|
r"a (?:little |quick |big |friendly )?wave\b|(?<![a-z])(?:wave|웨이브)\s?(?:해|하고|좀)|\bshake (?:for|at|with) (?:us|me)\b|\bsake hands?\b|\bshake (?:your |my |our )?hands?\b(?! with (?!me\b|us\b))|\b(?:give me|do|have|let'?s do) a handshake\b|\bsay (?:hi|hello|bye) with your hand\b|^\W*(?:(?:lumi|hey|okay|ok|please|robot|루미야?)\W+)*(?:sh—\s*)?shake(?: shake)*(?:\W+(?:please|lumi|now|lol))*\W*$|악수\s*(?:좀\s*|한 ?번\s*|도\s*)*(?:하자|해|할래|합시다|하실래|하시죠|하세요|하십시오|할까)|(?:손|송|팔) ?(?:을 |좀 |도 )?흔(?:들|드(?=세요|십시오|시|셔|러|소))|(?:손|송) ?(?:으로 ?)?인사|\bbye wave\b|(?:보고|향해|한테|에게)\s*(?:wave|웨이브)\b|\b(?:wayve|wavve|waive)\b|"
|
||||||
r"(?:한 ?번(?:만)? ?더|다시|또)\s*(?:좀\s*)?흔들어|(?:빠이 ?빠이|빠빠이|바이 ?바이|bye ?bye)\s*(?:좀\s*)?(?:해|하자|해요|해 ?줘|해 ?주세요|해 ?봐|해 ?줄래)"),
|
r"(?:한 ?번(?:만)? ?더|다시|또)\s*(?:좀\s*)?흔들어|(?:빠이 ?빠이|빠빠이|바이 ?바이|bye ?bye)\s*(?:좀\s*)?(?:해|하자|해요|해 ?줘|해 ?주세요|해 ?봐|해 ?줄래|하(?:세요|시게|십시오|시오|이소|시죠|게나?)(?![가-힣]))"),
|
||||||
("spin", r"\bspin (?:yourself )?(?:all the way |completely |fully )?(?:a)?round\b(?! (?:the|a|an|my|your|and look)\b)"
|
("spin", r"\bspin (?:yourself )?(?:all the way |completely |fully )?(?:a)?round\b(?! (?:the|a|an|my|your|and look)\b)"
|
||||||
r"|\bturn (?:yourself )?(?:all the way|completely|fully) (?:a)?round\b|\bdo a (?:full )?(?:360|full turn|full circle|spin)\b|\bturn 360\b|\b360\s*(?:turn|spin)\b|\bspin\s*[.!]*$"
|
r"|\bturn (?:yourself )?(?:all the way|completely|fully) (?:a)?round\b|\bdo a (?:full )?(?:360|full turn|full circle|spin)\b|\bturn 360\b|\b360\s*(?:turn|spin)\b|\bspin\s*[.!]*$"
|
||||||
r"|한 ?바퀴 ?(?:빙 ?)?(?:한 ?번 ?)?(?:돌|회전)(?![았었던은]|고 ?(?:와|오))|360\s*도\s*(?:돌|회전)(?![았었던은])|빙글 ?빙글 ?돌(?![았었던은])"),
|
r"|한 ?바퀴 ?(?:빙 ?)?(?:한 ?번 ?)?(?:돌|회전)(?![았었던은]|고 ?(?:와|오))|360\s*도\s*(?:돌|회전)(?![았었던은])|빙글 ?빙글 ?돌(?![았었던은])"),
|
||||||
("turn", r"\bturn (a)?round\b|(?:왼쪽|오른쪽)으로 ?(?:좀 ?)?(?:\d+(?:\.\d+)? ?도 ?)?도(?:세요|십시오)|\bturn (?:to (?:the |your )?)?(left|right)\b|뒤로 ?돌|돌아 ?봐|"
|
("turn", r"\bturn (a)?round\b|\b(?:turn to )?face the other (?:way|direction)\b|\bdo an? (?:180|one[- ]?eighty)\b|(?:왼쪽|오른쪽)으로 ?(?:[좀쫌] ?)?(?:\d+(?:\.\d+)? ?도 ?)?도(?:세요|십시오)|\bturn (?:to (?:the |your )?)?(left|right)\b|뒤로 ?돌|돌아 ?봐|"
|
||||||
r"(?:왼쪽|오른쪽)으로 ?(?:좀 ?)?(?:\d+(?:\.\d+)? ?도 ?(?:(?:만|쯤|정도|가량) ?)?)?(?:돌|회전)|"
|
r"(?:왼쪽|오른쪽)으로 ?(?:[좀쫌] ?)?(?:\d+(?:\.\d+)? ?도 ?(?:(?:만|쯤|정도|가량) ?)?)?(?:돌|회전|틀어)|"
|
||||||
r"\b(?:rotate|pivot|swing|swivel|turn)\b(?:\s+(?:yourself|your body|by|to the|to your|around to the))*\s*"
|
r"\b(?:rotate|pivot|swing|swivel|turn)\b(?:\s+(?:yourself|your body|by|to the|to your|around to the))*\s*"
|
||||||
r"(?:\d+\s*(?:degrees?|degs?|derees?|°)\s*)?(?:to (?:the |your )?)?(?:left|right|clockwise|counter-?clockwise)\b|"
|
r"(?:\d+\s*(?:degrees?|degs?|derees?|°)\s*)?(?:to (?:the |your )?)?(?:left|right|clockwise|counter-?clockwise)\b|"
|
||||||
r"\b(?:hang|take|make) a (?:left|right)\b|"
|
r"\b(?:hang|take|make) a (?:left|right)\b|"
|
||||||
r"(?:좌측|우측|왼편|오른편|(?<![가-힣])좌|(?<![가-힣])우|시계 ?방향|반시계 ?방향)으?로 ?(?:좀 ?)?(?:\S+ ?(?:도|°) ?(?:만 ?)?)?"
|
r"(?:좌측|우측|왼편|오른편|(?<![가-힣])좌|(?<![가-힣])우|시계 ?방향|반시계 ?방향)으?로 ?(?:[좀쫌] ?)?(?:\S+ ?(?:도|°) ?(?:만 ?)?)?"
|
||||||
r"(?:돌|회전|틀어|도세요|도십시오|도시)"),
|
r"(?:돌|회전|틀어|도세요|도십시오|도시)"),
|
||||||
# ^ also "pivot right 60°", "swing left 45 degrees", "rotate clockwise", "우측으로 30° 틀어 줘", "시계 방향으로 돌아"
|
# ^ also "pivot right 60°", "swing left 45 degrees", "rotate clockwise", "우측으로 30° 틀어 줘", "시계 방향으로 돌아"
|
||||||
("make_way", r"\b(can|could|would) you (please )?move( a bit| a little| please)?\s*[?.!]*$|\bmove (aside|out of the way|over)\b|"
|
("make_way", r"\b(can|could|would) you (please )?move( a bit| a little| please)?\s*[?.!]*$|\bmove (aside|out of the way|over)\b|"
|
||||||
r"\b(make way|get out of the way|give me some room)\b|비켜|자리 ?(좀 )?(비워|옮겨)|길 ?(좀 )?(비켜|터)"),
|
r"\b(make way|get out of the way|give me some room)\b|비켜|자리 ?(좀 )?(비워|옮겨)|길 ?(좀 )?(비켜|터)"),
|
||||||
("go_point", r"\b(?:go|come|drive|head) back ([a-z][a-z0-9_]*)\b"), # "come back p9 / booth_9": a place, not 1 m back
|
("go_point", r"\b(?:go|come|drive|head) back ([a-z][a-z0-9_]*)\b"), # "come back p9 / booth_9": a place, not 1 m back
|
||||||
("come_back", r"\bcome back\b|\breturn\b|\b(?:go|head|drive) back (?:to )?(?:where|your|the)\b|" # bare "go back" is
|
("come_back", r"\bcome back\b|\breturn\b|\b(?:go|head|drive) back (?:to )?(?:where|your|the)\b|" # bare "go back" is
|
||||||
r"돌아 ?(?:와|가|오|올|갈)"), # a short drive (as before); COME_BACK reads the whole sentence
|
r"돌아 ?(?:와|가|오|올|갈)|(?:원래\s*(?:있던|있었던|서 ?있던)\s*(?:자리|곳|데|위치)|왔던\s*(?:길|곳|데|자리))\s*(?:으로|로)\s*(?:다시\s*)?(?:가|와)"), # a short drive (as before); COME_BACK reads the whole sentence
|
||||||
("move", r"\b(?!go (?:right )?ahead\b)(?:move|go|come|drive|step)\s+(?:a little\s+|a bit\s+)?(forward|ahead|back(?:wards?)?|left|right)\b"
|
("move", r"\b(?!go (?:right )?ahead\b)(?:move|go|come|drive|step)\s+(?:a little\s+|a bit\s+)?(forward|ahead|back(?:wards?)?|left|right)\b"
|
||||||
r"(?:\s+(\d+(?:\.\d+)?|half)\s*(?:m|meters?|metres?)?)?|"
|
r"(?:\s+(\d+(?:\.\d+)?|half)\s*(?:m|meters?|metres?)?)?|"
|
||||||
r"\b(?:move|go|come)\s+(\d+(?:\.\d+)?)\s*(?:m|meters?|metres?)\s+(forward|ahead|back(?:wards?)?|left|right)\b|"
|
r"\b(?:move|go|come)\s+(\d+(?:\.\d+)?)\s*(?:m|meters?|metres?)\s+(forward|ahead|back(?:wards?)?|left|right)\b|"
|
||||||
@@ -768,6 +781,8 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
|||||||
r"|\bsnow(?:ing)?\b(?=.*(?:\?|today|tomorrow|tonight|week|soon|year))|첫눈|눈 ?(?:와|오|올|소식)|\brain come\b"
|
r"|\bsnow(?:ing)?\b(?=.*(?:\?|today|tomorrow|tonight|week|soon|year))|첫눈|눈 ?(?:와|오|올|소식)|\brain come\b"
|
||||||
r"|\b(?:raining|snowing) (?:right )?now\b|비 ?(?:오고|와요|오나요|올라)"
|
r"|\b(?:raining|snowing) (?:right )?now\b|비 ?(?:오고|와요|오나요|올라)"
|
||||||
r"|\bis it (?:cold|hot|warm|chilly|freezing|raining|snowing|sunny) in\b"
|
r"|\bis it (?:cold|hot|warm|chilly|freezing|raining|snowing|sunny) in\b"
|
||||||
|
r"|(?:비|눈) ?소식|몇 ?도까지 ?(?:올라|내려|떨어)|웨더|(?:^|\s)레인 ?(?:와|올|오)|\bwhat'?s the (?:high|low) (?:today|tomorrow|tonight)\b"
|
||||||
|
r"|\bhow'?s it (?:looking )?(?:outside|out there)\b"
|
||||||
rf"|\bhow(?:'s| is) (?:it in |the weather in )?(?:{_EN_PLACES})\b(?=.*\b(?:today|tomorrow|now|tonight|weekend)\b)"
|
rf"|\bhow(?:'s| is) (?:it in |the weather in )?(?:{_EN_PLACES})\b(?=.*\b(?:today|tomorrow|now|tonight|weekend)\b)"
|
||||||
r"|(?<!\ba )\b(?:warm|warmer|cold|colder|hot|hotter|chilly|freezing|sunny|cloudy)\b(?=.*\b(?:today|tomorrow|tonight|weekend|"
|
r"|(?<!\ba )\b(?:warm|warmer|cold|colder|hot|hotter|chilly|freezing|sunny|cloudy)\b(?=.*\b(?:today|tomorrow|tonight|weekend|"
|
||||||
r"monday|tuesday|wednesday|thursday|friday|saturday|sunday|outside)\b)"
|
r"monday|tuesday|wednesday|thursday|friday|saturday|sunday|outside)\b)"
|
||||||
@@ -778,15 +793,19 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
|||||||
r"|비 ?(?:옵니까|오노|오니|오냐|와유|오남)|우산\s*(?:챙겨야|가져가야|들고 가야|필요)|\bany (?:rain|snow)\b|\bumbrellas?\b.*\b(?:today|tomorrow|tonight)\b"),
|
r"|비 ?(?:옵니까|오노|오니|오냐|와유|오남)|우산\s*(?:챙겨야|가져가야|들고 가야|필요)|\bany (?:rain|snow)\b|\bumbrellas?\b.*\b(?:today|tomorrow|tonight)\b"),
|
||||||
("search", r"\b(news|latest|headlines?|who won|score of|price of|exchange rate|stock)\b|뉴스|환율|(?<![가-힣])주가|"
|
("search", r"\b(news|latest|headlines?|who won|score of|price of|exchange rate|stock)\b|뉴스|환율|(?<![가-힣])주가|"
|
||||||
r"\bwhat'?s (?:happening|going on) in the world\b|\bwhat happened in the world\b|(?:최근|최신|요즘|새) ?소식|"
|
r"\bwhat'?s (?:happening|going on) in the world\b|\bwhat happened in the world\b|(?:최근|최신|요즘|새) ?소식|"
|
||||||
r"누가 이겼|경기 결과|\btop (?:stories|headlines)\b|요즘 ?경제|경제 ?(?:뉴스|상황|소식|어때|어떻)|"
|
r"^(?!.*\b(?:you|your|here|lumi)\b)\W*what(?:'s| is)? (?:happened|happening) today\b|" # "what happened today?"
|
||||||
|
r"세상에 (?:요즘 |오늘 )?무슨 일|"
|
||||||
|
r"누가 이겼|(?:경기|축구|야구|농구|배구|월드컵) ?결과|\bdid (?!you\b|i\b|we\b|they\b|he\b|she\b|cutshion\b|kutchen\b|gomcook\b|jaka\b|your\b)[A-Z]?\w+ win\b|\btop (?:stories|headlines)\b|요즘 ?경제|경제 ?(?:뉴스|상황|소식|어때|어떻)|"
|
||||||
rf"(?:{_COIN})\S*\s*(?:(?:지금|현재|오늘|요즘|원화로)\s*)?(?:얼마|가격|시세)|\bhow much is (?:a |one )?(?:{_COIN})\b|"
|
rf"(?:{_COIN})\S*\s*(?:(?:지금|현재|오늘|요즘|원화로)\s*)?(?:얼마|가격|시세)|\bhow much is (?:a |one )?(?:{_COIN})\b|"
|
||||||
rf"(?:{_COIN})\b.{{0,6}}\bhow much\b|"
|
rf"(?:{_COIN})\b.{{0,6}}\bhow much\b|"
|
||||||
rf"(?:{_COIN})\b.{{0,12}}\b(?:price|worth|trading)\b|" # "리플 지금 얼마야?", "how much is bitcoin?"
|
rf"(?:{_COIN})\b.{{0,12}}\b(?:price|worth|trading)\b|" # "리플 지금 얼마야?", "how much is bitcoin?"
|
||||||
r"^(?!.*(?:cutshion|쿳션|컷션|커션|회사|너희|루미|\byour\b|\bcompany\b)).*?(?:" # Cutshion's CEO: the notes
|
r"^(?!.*(?:cutshion|쿳션|컷션|커션|회사|너희|루미|\byour\b|\bcompany\b)).*?(?:" # Cutshion's CEO: the notes
|
||||||
r"\bwho(?:'s| is| was)? (?:the )?(?:current |new )?(?:ceo|president|prime minister|chairman|chair|founder|owner|"
|
r"\bwho(?:'s| is| was)? (?:the )?(?:current |new )?(?:ceo|president|prime minister|chairman|chair|founder|owner|"
|
||||||
r"head coach|coach|mayor|governor|leader|king|queen) of |"
|
r"head coach|coach|mayor|governor|leader|king|queen) of |"
|
||||||
|
r"\bwho (?:leads|runs|heads) (?!you|your|this|that|the|it|us|me|lumi|here)[a-z]\w+|"
|
||||||
r"(?<![가-힣])(?!우리|저희|이 |그 )[가-힣A-Za-z0-9]+\s*(?:CEO|ceo|대표|회장|사장|대통령|총리|감독|창업자)"
|
r"(?<![가-힣])(?!우리|저희|이 |그 )[가-힣A-Za-z0-9]+\s*(?:CEO|ceo|대표|회장|사장|대통령|총리|감독|창업자)"
|
||||||
r"(?:가|는|이|은)?\s*누구)|" # "who is the CEO of OpenAI?", "오픈AI CEO가 누구야?"
|
r"(?:가|는|이|은)?\s*(?:누구|어떤\s*분|어느\s*분)|(?<![가-힣])(?<!우리 )(?<!저희 )(?<!너희 )(?!우리|저희|이 |그 |로봇)[가-힣A-Za-z0-9]+(?:는|은)?\s*누가\s*(?:이끌|경영))|"
|
||||||
|
# "who is the CEO of OpenAI?", "오픈AI CEO가 누구야?", "오픈AI는 누가 이끌고 있습니까"
|
||||||
r"\bpopulation\b|\bhow many people live\b|인구|\binhabitants\b|몇 ?명 ?(?:이 )?살|사람이 ?\S* ?(?:사노|살아|살고)|"
|
r"\bpopulation\b|\bhow many people live\b|인구|\binhabitants\b|몇 ?명 ?(?:이 )?살|사람이 ?\S* ?(?:사노|살아|살고)|"
|
||||||
rf"\bhow big is (?:{_EN_PLACES})\b|\b(?:{_EN_PLACES}) people how many\b|"
|
rf"\bhow big is (?:{_EN_PLACES})\b|\b(?:{_EN_PLACES}) people how many\b|"
|
||||||
r"\b(?:dollars?|euros?|yen)\b.{0,20}\b(?:won|rate)\b|\bin won\b|\bexchange rai?te?\b|\bhow many won\b|"
|
r"\b(?:dollars?|euros?|yen)\b.{0,20}\b(?:won|rate)\b|\bin won\b|\bexchange rai?te?\b|\bhow many won\b|"
|
||||||
@@ -815,14 +834,20 @@ STOP_ASK = re.compile(r"(?:(?:can|could|would|will) you (?:please |just )?stop(?
|
|||||||
|
|
||||||
COME_BACK = re.compile( # the whole sentence asks Lumi back to where it stood before its last trip
|
COME_BACK = re.compile( # the whole sentence asks Lumi back to where it stood before its last trip
|
||||||
r"(?:(?:please|can you|could you|would you|will you|now|just|ok|okay|alright|so|and|lumi)\s+)*"
|
r"(?:(?:please|can you|could you|would you|will you|now|just|ok|okay|alright|so|and|lumi)\s+)*"
|
||||||
r"(?:come back|return|(?:go|head|drive) back(?= ))(?: to)?(?: (?:where you (?:were|was|started|came from|were standing)"
|
r"(?:come (?:on )?back|return|(?:go|head|drive) back(?= ))(?: to)?(?: (?:where you (?:were|was|started|came from|were standing)"
|
||||||
r"(?: before)?|(?:your|the) (?:start(?:ing)? (?:point|place|spot|position)|start|original (?:spot|place|position)|"
|
r"(?: before)?|the way you came|(?:your|the) (?:start(?:ing)? (?:point|place|spot|position)|start|original (?:spot|place|position)|"
|
||||||
r"old (?:spot|place)|spot|place)))?(?: (?:now|please|lumi|again|for me))*|"
|
r"old (?:spot|place)|spot|place)))?(?: (?:now|please|lumi|again|for me))*|"
|
||||||
r"(?:(?:다시|이제|좀|얼른|어서)\s*)*(?:(?:원래|아까|처음)\s*(?:있던|있었던|서 ?있던)?\s*(?:자리|곳|데|위치|장소)\s*(?:으로|로|에)\s*|"
|
r"(?:(?:다시|이제|좀|얼른|어서)\s*)*(?:(?:원래|아까|처음)\s*(?:있던|있었던|서 ?있던)?\s*(?:자리|곳|데|위치|장소)\s*(?:으로|로|에)\s*|"
|
||||||
r"제자리로\s*)?(?:다시\s*)?(?:되)?돌아\s?(?:와|가|오세요|가세요|와요|가요|와라|가라|올래|갈래)"
|
r"제자리로\s*)?(?:다시\s*)?(?:되)?돌아\s?(?:와|가|오세요|가세요|와요|가요|와라|가라|올래|갈래)"
|
||||||
r"(?:\s*(?:줘요?|주세요|줄래요?|봐))?")
|
r"(?:\s*(?:줘요?|주세요|줄래요?|봐))?|"
|
||||||
|
r"(?:(?:다시|이제|좀|얼른|어서)\s*)*(?:원래\s*(?:있던|있었던|서 ?있던)\s*(?:자리|곳|데|위치)|왔던\s*(?:길|곳|데|자리))\s*(?:으로|로)\s*"
|
||||||
|
r"(?:다시\s*)?(?:(?:되)?돌아\s?)?(?:가|와|가세요|와요|가요|가라|와라)(?:\s*(?:줘요?|주세요|줄래요?|주시겠어요|주십시오|봐))?")
|
||||||
|
# "원래 있던 자리로 가 주세요", "왔던 길로 돌아가": back where it stood
|
||||||
|
GREET_ONLY = re.compile( # a hello and a name, nothing asked: never a wave by itself ("hello robot", "안녕 루미야")
|
||||||
|
r"^\W*(?:(?:hi|hello|hey|hiya|howdy|yo|good (?:morning|afternoon|evening)|안녕(?:하세요|하십니까)?|반가워요?|반갑습니다)\W*)+"
|
||||||
|
r"(?:(?:lumi|loomi|robot|there|everyone|buddy|루미야?|루미 ?씨|로봇아?|로봇 ?씨)\W*)*$", re.I)
|
||||||
CALLING = re.compile(r"^\W*(?:(?:hey|hi|okay|ok|so|um+|uh+|alright|please|well|now|저기요?|혹시|음+|자|야|어+|그럼|이제)\W+)*"
|
CALLING = re.compile(r"^\W*(?:(?:hey|hi|okay|ok|so|um+|uh+|alright|please|well|now|저기요?|혹시|음+|자|야|어+|그럼|이제)\W+)*"
|
||||||
r"(?:(?:lumi|루미야?|루미)\W+)?(?:(?:저기요?|혹시|음+|자|그럼|이제|now)\W+)*", re.I) # words that call Lumi or fill, before the request itself
|
r"(?:(?:lumi|루미 ?씨|루미야?|루미|로봇아|로봇 ?씨|robot)\W+)?(?:(?:저기요?|혹시|음+|자|그럼|이제|now)\W+)*", re.I) # words that call Lumi or fill, before the request itself
|
||||||
_NOT_A_NAME = (r"Lumi|Okay|Ok|Yes|No|Wait|Well|Hey|Hi|So|Oh|Please|Sorry|Thanks|Now|Look|Wow|Alright|Great|Sure|Right|Hello|"
|
_NOT_A_NAME = (r"Lumi|Okay|Ok|Yes|No|Wait|Well|Hey|Hi|So|Oh|Please|Sorry|Thanks|Now|Look|Wow|Alright|Great|Sure|Right|Hello|"
|
||||||
r"Come|Go|Then|And|But|Also|Here|There|Yeah|Nope|Cool|Nice|Maybe|Seoul|Korea|Um+|Uh+|Uhm|Er+m?|Hmm+|Ah+|"
|
r"Come|Go|Then|And|But|Also|Here|There|Yeah|Nope|Cool|Nice|Maybe|Seoul|Korea|Um+|Uh+|Uhm|Er+m?|Hmm+|Ah+|"
|
||||||
r"Excuse|Actually|First|Just|Stop|Turn|Move|Take|Pick|Bring|Put|Give|Follow|Wave|Lift|Raise|Lower|Open|"
|
r"Excuse|Actually|First|Just|Stop|Turn|Move|Take|Pick|Bring|Put|Give|Follow|Wave|Lift|Raise|Lower|Open|"
|
||||||
@@ -833,13 +858,19 @@ _FILL_EN = r"(?:(?:hey|look|oh|ah|wait|okay|ok|alright|now|so|um+|uh+|hmm+|and|b
|
|||||||
ASIDE_EN = re.compile(rf"^\W*(?i:{_FILL_EN}(?:mom|mum|mommy|dad|daddy|honey|sweetie|guys|you guys|kids|boss|everyone|everybody|team|folks|"
|
ASIDE_EN = re.compile(rf"^\W*(?i:{_FILL_EN}(?:mom|mum|mommy|dad|daddy|honey|sweetie|guys|you guys|kids|boss|everyone|everybody|team|folks|"
|
||||||
r"children)\b)\W|"
|
r"children)\b)\W|"
|
||||||
r"^\W*(?i:hey)\s+(?!(?i:lumi|loomi|rumi|you|robot|there|guys)\b)[A-Z][a-z]+\b|"
|
r"^\W*(?i:hey)\s+(?!(?i:lumi|loomi|rumi|you|robot|there|guys)\b)[A-Z][a-z]+\b|"
|
||||||
|
r"(?:^|,\s*)(?i:dude)\s*,|(?<![a-z])(?i:dad|mom|daddy|mommy|honey|sweetie|grandma|grandpa)\s*,\s|"
|
||||||
|
rf":\s*(?!(?:{_NOT_A_NAME})\b)(?!(?i:lumi|loomi|rumi|robot)\b)[A-Z][a-z]+,\s|" # "dude, hand it to her": a friend
|
||||||
|
rf"^\W*(?:(?:자|이제|그럼|저기|야|어|음)\s+)+(?!(?:{_NOT_A_NAME})\b)(?!(?i:lumi|loomi|rumi|robot)\b)[A-Z][a-z]+,\s|"
|
||||||
|
rf"^[^,]{{1,25}},\s+(?!(?:{_NOT_A_NAME})\b)(?!(?i:lumi|loomi|rumi|robot|buddy|sir|madam|ma'?am)\b)[A-Z][a-z]+,\s|" # "shh, Sarah, make your way"
|
||||||
rf"^\W*(?i:{_FILL_EN})(?!(?:{_NOT_A_NAME})\b)[A-Z][a-z]+, (?!(?i:lumi)\b)|" # "Jake, take the cup",
|
rf"^\W*(?i:{_FILL_EN})(?!(?:{_NOT_A_NAME})\b)[A-Z][a-z]+, (?!(?i:lumi)\b)|" # "Jake, take the cup",
|
||||||
r",\s*(?i:mom|mum|dad|honey|sweetie|guys|kids)\s*(?:,|[.!?]*\s*$)|" # "so Minji, stand up
|
r",\s*(?i:mom|mum|dad|honey|sweetie|kids)\s*(?:,|[.!?]*\s*$)|" # "so Minji, stand up
|
||||||
rf",\s*(?!(?:{_NOT_A_NAME})\b)[A-Z][a-z]+\s*[.!?]*\s*$") # taller", "here you go, mom"
|
rf",\s*(?!(?:{_NOT_A_NAME})\b)[A-Z][a-z]+\s*[.!?]*\s*$") # taller", "here you go, mom"
|
||||||
ASIDE_KO = re.compile(r"(?:엄마|아빠|할머니|할아버지|이모|삼촌|선생님|친구|동생|언니|누나|형|오빠)(?:한테|에게)\s*(?:손|인사|흔들)"
|
ASIDE_KO = re.compile(r"(?:엄마|아빠|할머니|할아버지|이모|삼촌|선생님|친구|동생|언니|누나|형|오빠)(?:한테|에게)\s*(?:손|인사|흔들)"
|
||||||
r"(?!.*(?:줘|주세요|주실|드려|드리|줄래|주라|주시))|"
|
r"(?!.*(?:줘|주세요|주실|드려|드리|줄래|주라|주시))|"
|
||||||
r"^\W*(?:(?:근데|음+|흠+|아+|어+|그럼|자|저기)\s+)?(?:아저씨|아줌마|이모|삼촌|할머니|할아버지|아가야|아기야|애기야|얘야|"
|
r"(?:^|[,.!?]\s*|(?<=[가-힣])(?:니까|는데|은데|라서|어서|는디|때처럼|중인데)\s+|\s전에\s+)\W*(?:(?:근데|음+|흠+|아+|어+|그럼|자|저기)\s+)?(?:아저씨|아줌마|이모|삼촌|할머니|할아버지|아가야|아기야|애기야|얘야|"
|
||||||
r"여러분|친구야|영감|할멈|엄마|아빠|여보|자기야|오빠|언니|누나|형|얘들아|애들아|선생님|팀장님|부장님|과장님|대리님|사장님)(?:[\s,!~]|$)|"
|
r"여러분|친구야|영감|할멈|엄마|아빠|여보|자기야|오빠|언니|누나|형|얘들아|애들아|선생님|팀장님|부장님|과장님|대리님|사장님|"
|
||||||
|
r"어머님|아버님|어머니|아버지|회장님|원장님|교수님|선배님|박사님|이사님|실장님|사모님|아드님|따님|"
|
||||||
|
r"우리 (?:아들|딸|애|아기|손주|손녀|손자|막내)|아들아?|딸아|[김이박최정강조윤장임한오서신권황안송류홍] ?(?:군|양|서방))(?:[\s,!~]|$)|"
|
||||||
r"^\W*(?:(?:근데|음+|흠+|아+|어+|그럼|자|저기)\s+)?(?P<name>[가-힣]{2})(?P<v>아|야)[\s,!~]|"
|
r"^\W*(?:(?:근데|음+|흠+|아+|어+|그럼|자|저기)\s+)?(?P<name>[가-힣]{2})(?P<v>아|야)[\s,!~]|"
|
||||||
r"(?:thank you|땡큐|고맙습니다|감사합니다|안녕하세요|인사)\s*(?:해야지|해|하세요|해 ?봐|드려야지|드려)[\s.!~]*$")
|
r"(?:thank you|땡큐|고맙습니다|감사합니다|안녕하세요|인사)\s*(?:해야지|해|하세요|해 ?봐|드려야지|드려)[\s.!~]*$")
|
||||||
# "thank you 해": a parent to a child
|
# "thank you 해": a parent to a child
|
||||||
@@ -850,7 +881,7 @@ NOT_NAME = {"루미", "누미", "류미", "무미", "루비", "루니", "아니"
|
|||||||
def to_someone_else(text):
|
def to_someone_else(text):
|
||||||
""""Hey Jake, come see this", "Mom, look!", "민수야 이리 와 봐": said to another person nearby, not an order to Lumi."""
|
""""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)\s*,", text, re.I):
|
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"
|
||||||
for m in re.finditer(r"[,\s]([가-힣]{2})(아|야)(?=[\s,!~.]|$)", text): # "그거 내려놔, 지훈아 깨져"
|
for m in re.finditer(r"[,\s]([가-힣]{2})(아|야)(?=[\s,!~.]|$)", text): # "그거 내려놔, 지훈아 깨져"
|
||||||
c = m.group(1)[-1]
|
c = m.group(1)[-1]
|
||||||
@@ -878,14 +909,15 @@ CONDITION = re.compile( # a condition or a later time: "when the show starts,
|
|||||||
r"(?:i|we|you|he|she|they|it|the|my|your|his|her|our|their|everyone|someone|people|kids?|guests?|mom|dad)\b|"
|
r"(?:i|we|you|he|she|they|it|the|my|your|his|her|our|their|everyone|someone|people|kids?|guests?|mom|dad)\b|"
|
||||||
r"^\W*(?:if|unless)\b(?! you (?:could|would|can|don'?t mind|wouldn'?t mind|please)\b)|\b(?:later|tomorrow|tonight|next time|in (?:a|an|\d+|one|two|three|five|ten) (?:minutes?|seconds?|hours?|min|sec))\b|"
|
r"^\W*(?:if|unless)\b(?! you (?:could|would|can|don'?t mind|wouldn'?t mind|please)\b)|\b(?:later|tomorrow|tonight|next time|in (?:a|an|\d+|one|two|three|five|ten) (?:minutes?|seconds?|hours?|min|sec))\b|"
|
||||||
r"\b(?:only|just) (?:when|if|after)\b|\bwhen i (?:say|tell|count|clap|wave|give)\b|"
|
r"\b(?:only|just) (?:when|if|after)\b|\bwhen i (?:say|tell|count|clap|wave|give)\b|"
|
||||||
r"(?:^|\s)(?:나중에|이따가?|있다가|내일|이따|만약|만일|다음에)(?=\s|\W*$)|[가-힣](?<![정화측반전표라장내외평단])면\s(?!안 ?돼|좋겠)|[가-힣]거든\s|"
|
r"(?:^|\s)(?:나중에|이따가?|있다가|내일|이따|만약|만일|다음에)(?![가-힣])|[가-힣](?<![정화측반전표라장내외평단])면\s(?!안 ?돼|좋겠)|[가-힣]거든\s|"
|
||||||
|
r"[가-힣](?:하|가|오|보|되|들|말하|시키)믄\s|" # 전라 / 경상 "말하믄": a condition
|
||||||
r"[가-힣] 때(?:에|는|까지)?[\s,]", re.I)
|
r"[가-힣] 때(?:에|는|까지)?[\s,]", re.I)
|
||||||
REMARK = re.compile( # about Lumi or someone, what was said or seen, the speaker's own plans: no order to Lumi
|
REMARK = re.compile( # about Lumi or someone, what was said or seen, the speaker's own plans: no order to Lumi
|
||||||
rf"{_LEAD}(?:i(?:'ll| will|'m going to| am going to| always| usually| never| saw| just saw| was(?! wondering)| had| did| can'?t)(?! (?:take|have) (?:it|this|that)\b| (?:give|hand) you (?!(?:a|an|some) (?:tip|hint|call|ring|ride|hand|hug|break|second|minute|chance|clue|idea)\b))|"
|
rf"{_LEAD}(?:i(?:'ll| will|'m going to| am going to| always| usually| never| saw| just saw| was(?! wondering)| had| did| can'?t| wish)(?! (?:take|have) (?:it|this|that)\b| (?:give|hand) you (?!(?:a|an|some) (?:tip|hint|call|ring|ride|hand|hug|break|second|minute|chance|clue|idea)\b))|"
|
||||||
r"i (?:just |already )?(?:put|took|went|moved|picked|gave|brought|grabbed|turned|waved|did|dropped|set)\b|"
|
r"i (?:just |already )?(?:put|took|went|moved|picked|gave|brought|grabbed|turned|waved|did|dropped|set)\b|"
|
||||||
r"we(?:'ll| will| always| saw)|my (?!hand\b)\w+ (?:can|can'?t|is|was|said|told|keeps|will|did)|"
|
r"we(?:'ll| will| always| saw)|my (?!hand\b)\w+ (?:can|can'?t|is|was|said|told|keeps|will|did)|"
|
||||||
r"(?:he|she|they|someone|everyone|nobody|the robot|this robot|that robot)(?:'s| is| was| will| did| does| can| keeps?| said| told| always)?\b|"r"it(?:'s| is| was| will| did| does| can| keeps?)\b|"
|
r"(?:he|she|they|someone|everyone|nobody|the robot|this robot|that robot)(?:'s| is| was| will| did| does| can| keeps?| said| told| always)?\b|"r"it(?:'s| is| was| will| did| does| can| keeps?)\b|"
|
||||||
r"you (?:shouldn'?t|should not|always|never|did|just|were|already)|did you|do you ever|have you|"
|
r"you (?:shouldn'?t|should not|always|never|did|just|were|already)|did you|do you ever|(?:can|could) you ever|have you|"
|
||||||
r"(?:제가|내가|저는|나는|난|전)\s(?!.*(?:드릴게|줄게|줄께|드릴께|드려요)))|"
|
r"(?:제가|내가|저는|나는|난|전)\s(?!.*(?:드릴게|줄게|줄께|드릴께|드려요)))|"
|
||||||
r"(?<!\bi )\b(?:said|says|told|keeps? telling|was telling|asked (?:the robot|lumi|you))\b|라고\s*(?:했|하|말)|"
|
r"(?<!\bi )\b(?:said|says|told|keeps? telling|was telling|asked (?:the robot|lumi|you))\b|라고\s*(?:했|하|말)|"
|
||||||
r"(?:았|었|였|했)(?:지|죠|잖아)(?:요)?\s*\??\s*$|(?:^|\s)(?:아까|방금|어제)\s.*(?:았|었|였|했)|싶었|"
|
r"(?:았|었|였|했)(?:지|죠|잖아)(?:요)?\s*\??\s*$|(?:^|\s)(?:아까|방금|어제)\s.*(?:았|었|였|했)|싶었|"
|
||||||
@@ -908,12 +940,15 @@ REMARK = re.compile( # about Lumi or someone, what was said or seen, the speak
|
|||||||
r"\bat (?:\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|noon)(?::\d\d)?\s*(?:pm|am|p\.m\.|a\.m\.|o'?clock)?(?!\s*(?:degrees?|m\b|meters?|cm))\b|"
|
r"\bat (?:\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve|noon)(?::\d\d)?\s*(?:pm|am|p\.m\.|a\.m\.|o'?clock)?(?!\s*(?:degrees?|m\b|meters?|cm))\b|"
|
||||||
r"(?:^|\s)[0-9한두세네다섯여섯일곱여덟아홉열]+ ?시(?:에|쯤)|^(?!.*\b(?:put|place|set|drop|leave)\b|.*(?:놔|놓|둬)).*(?:\b(?:or|either)\b(?! (?:else|something|so|not)\b)|아니면)|"
|
r"(?:^|\s)[0-9한두세네다섯여섯일곱여덟아홉열]+ ?시(?:에|쯤)|^(?!.*\b(?:put|place|set|drop|leave)\b|.*(?:놔|놓|둬)).*(?:\b(?:or|either)\b(?! (?:else|something|so|not)\b)|아니면)|"
|
||||||
r"\b(?:to|at) (?:the|this|that) robot\b|로봇(?:한테|에게)|\b(?:left or right|right or left)\b|왼쪽(?:이나|이야|으로 아니면) 오른쪽", re.I)
|
r"\b(?:to|at) (?:the|this|that) robot\b|로봇(?:한테|에게)|\b(?:left or right|right or left)\b|왼쪽(?:이나|이야|으로 아니면) 오른쪽", re.I)
|
||||||
|
_YOU_CAN = (r"(?:go|come|move|turn|look|lift|raise|lower|wave|shake|say hi|follow|bring|fetch|get|take|pick|grab|put|"
|
||||||
|
r"give|reach|extend|stretch|stick|hold|open|close|drive|spin|rotate|face|show|sing|stop|back|head|walk)")
|
||||||
|
# "Lumi you can extend your hand to me?": a non-native request, read as one (r6 / r8 / r9: 111 of 113)
|
||||||
ASKED = re.compile( # a question, not an order: "and when you carry a cup?", "그거 누구 줄 거야?", "can you wave?"
|
ASKED = re.compile( # a question, not an order: "and when you carry a cup?", "그거 누구 줄 거야?", "can you wave?"
|
||||||
rf"{_LEAD}(?:what|where|when|why|how(?! about)|who|which|whose|are you|were you|was it|is it(?! possible)|is that|do you|does it|did it)\b.*\?|"
|
rf"{_LEAD}(?:what|where|when|why|how(?! about)|who|which|whose|are you|were you|was it|is it(?! possible)|is that|do you|does it|did it)\b.*\?|"
|
||||||
r"\b(?:aren'?t|weren'?t|don'?t|didn'?t|won'?t|isn'?t) you\s*\?|\byou'?re\b(?!.*,\s*(?:okay|ok|alright|please)\s*\?\s*$).*\?\s*$|"
|
r"\b(?:aren'?t|weren'?t|don'?t|didn'?t|won'?t|isn'?t) you\s*\?|\byou'?re\b(?!.*,\s*(?:okay|ok|alright|please)\s*\?\s*$).*\?\s*$|"
|
||||||
r"\b(?:can|could) you\b(?![^?]*(?:\d|\b(?:one|two|three|four|five|six|ten|twenty|thirty|fifty|half|a bit|a little|"
|
r"\b(?:can|could) you\b(?![^?]*(?:\d|\b(?:one|two|three|four|five|six|ten|twenty|thirty|fifty|half|a bit|a little|"
|
||||||
r"some)\b|\bcm\b|met(?:er|re)))[^?]*\b(?:backwards?|sideways|in place|on the spot|diagonally|on your own|alone|upside down)\b"
|
r"some)\b|\bcm\b|met(?:er|re)))[^?]*\b(?:backwards?|sideways|in place|on the spot|diagonally|on your own|alone|upside down)\b"
|
||||||
r"[^?]*\?|" rf"{_LEAD}you (?!guys\b)(?!.*\b(?:can'?t|won'?t|will|would|could) you\s*\?\s*$)\w+.*\?\s*$|\bor what\s*\?|"
|
r"[^?]*\?|" rf"{_LEAD}you (?!guys\b)(?!can {_YOU_CAN}\b(?!.*\b(?:or|by yourself|alone)\b))(?!.*\b(?:can'?t|won'?t|will|would|could) you\s*\?\s*$)\w+.*\?\s*$|\bor what\s*\?|"
|
||||||
rf"{_LEAD}(?:can|could) you (?!sing)\w+\s*\?\s*$|{_LEAD}(?:can|could) you (?:get|grow|be|go|become) \w+er\s*\?\s*$|{_LEAD}(?:can|may|could|should|shall) (?:i|we) (?!have\b|get\b|see you\b|watch you\b|trouble you\b|take (?:it|that|this)\W*$)|"
|
rf"{_LEAD}(?:can|could) you (?!sing)\w+\s*\?\s*$|{_LEAD}(?:can|could) you (?:get|grow|be|go|become) \w+er\s*\?\s*$|{_LEAD}(?:can|may|could|should|shall) (?:i|we) (?!have\b|get\b|see you\b|watch you\b|trouble you\b|take (?:it|that|this)\W*$)|"
|
||||||
r"\b(?:can|could|does|will) your \w+|"
|
r"\b(?:can|could|does|will) your \w+|"
|
||||||
r"(?:^|\s)(?:뭐|뭘|무엇|어디|언제|왜|어떻게|누구|누가|몇|얼마)(?:[가-힣]*)\s.*(?:\?|거야|니|나요|까요?|냐)\s*$|"
|
r"(?:^|\s)(?:뭐|뭘|무엇|어디|언제|왜|어떻게|누구|누가|몇|얼마)(?:[가-힣]*)\s.*(?:\?|거야|니|나요|까요?|냐)\s*$|"
|
||||||
@@ -935,12 +970,13 @@ NEGATED = re.compile( # "could you not look left", "왼쪽으로 돌면 안
|
|||||||
ABOUT_IT = re.compile(r"\bit(?:'s| is) (?:going|gonna|about) to\b|\bit'?s gonna\b|\b(?:maybe|perhaps) it(?:'ll| will)?\b|"
|
ABOUT_IT = re.compile(r"\bit(?:'s| is) (?:going|gonna|about) to\b|\bit'?s gonna\b|\b(?:maybe|perhaps) it(?:'ll| will)?\b|"
|
||||||
r"\bwatch,\s*it\b|\bi wonder\b|\bdo robots\b|\b(?:let'?s|we could|we can) (?:ask|tell|get) (?:it|the robot|lumi)\b|"
|
r"\bwatch,\s*it\b|\bi wonder\b|\bdo robots\b|\b(?:let'?s|we could|we can) (?:ask|tell|get) (?:it|the robot|lumi)\b|"
|
||||||
r"(?:한테|에게) .*(?:라고|하라고) ?(?:해 ?볼까|해 ?보자|하자|시켜)|[가-힣](?:라고|라구) (?:나와|나오|나온|써|적혀|하더|그러)|"
|
r"(?:한테|에게) .*(?:라고|하라고) ?(?:해 ?볼까|해 ?보자|하자|시켜)|[가-힣](?:라고|라구) (?:나와|나오|나온|써|적혀|하더|그러)|"
|
||||||
r"^\W*(?!루미)[가-힣]{1,3} ?(?:대리|과장|부장|팀장|차장|실장|사원|주임|선배|후배)(?:님)?\W", re.I) # "김 대리 컵 들어"
|
r"^\W*(?:(?:이보게|여보게|이봐요?|어이)\s+)?(?![루누류]미|로봇)[가-힣]{1,3} ?(?:대리|과장|부장|팀장|차장|실장|사원|주임|선배|"
|
||||||
|
r"후배|군|서방)(?:님)?\W", re.I) # "김 대리 컵 들어", "김 군, 자네도 가 보게", "이보게 박 서방"
|
||||||
# "watch, it's going to hand it to me", "maybe it'll give me the cup", "루미한테 팔 뻗으라고 해 볼까?"
|
# "watch, it's going to hand it to me", "maybe it'll give me the cup", "루미한테 팔 뻗으라고 해 볼까?"
|
||||||
LATER_SAID = re.compile(r"\b(?:next (?:week|month|year|monday|tuesday|wednesday|thursday|friday|saturday|sunday)|this (?:afternoon|evening|weekend)|"
|
LATER_SAID = re.compile(r"\b(?:next (?:week|month|year|monday|tuesday|wednesday|thursday|friday|saturday|sunday)|this (?:afternoon|evening|weekend)|"
|
||||||
r"after (?:lunch|dinner|the (?:break|show|talk|demo|photo|meeting))|"
|
r"after (?:lunch|dinner|the (?:break|show|talk|demo|photo|meeting))|"
|
||||||
r"(?:better|had better) not|it tried|if it|how long does it take|this morning|yesterday)\b|"
|
r"(?:better|had better) not|it tried|if it|how long does it take|this morning|yesterday)\b|"
|
||||||
r"(?:끝나고|끝나면|찍고 ?나서)\s|다음 ?(?:주|달|번)에?|(?:오기|먹기) 전에|(?:점심|저녁|쉬는 시간) (?:후에|뒤에|끝나고)|"
|
r"(?:끝나고|끝나면|찍고 ?나서|(?:끝난|마친|끝나는) (?:후|뒤|다음)에?)\s|다음 ?(?:주|달|번)에?|(?:오기|먹기) 전에|(?:점심|저녁|쉬는 시간) (?:후에|뒤에|끝나고)|"
|
||||||
r"(?:^|\s)아까(?:는|도)\s|더라(?:고|구)?요?\W*$", re.I)
|
r"(?:^|\s)아까(?:는|도)\s|더라(?:고|구)?요?\W*$", re.I)
|
||||||
# a later time, a past remark, "you better not": no order now ("쉬는 시간 끝나고 팔 뻗어", "아까는 ... 안 하더라")
|
# a later time, a past remark, "you better not": no order now ("쉬는 시간 끝나고 팔 뻗어", "아까는 ... 안 하더라")
|
||||||
|
|
||||||
@@ -953,10 +989,20 @@ def not_an_order(text, asked=True):
|
|||||||
t = unfill(wording.ko_plain(text or "")) # "날 따라오면 돼" is "날 따라와": no condition
|
t = unfill(wording.ko_plain(text or "")) # "날 따라오면 돼" is "날 따라와": no condition
|
||||||
rest = instead_of(t) # "don't put your arm out, my baby will grab it"
|
rest = instead_of(t) # "don't put your arm out, my baby will grab it"
|
||||||
return bool(to_someone_else(t) or CANT_GO.search(t) or DRINK.search(t) or IDIOMS.search(t) or CONDITION.search(t) or REMARK.search(t) or
|
return bool(to_someone_else(t) or CANT_GO.search(t) or DRINK.search(t) or IDIOMS.search(t) or CONDITION.search(t) or REMARK.search(t) 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
|
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))
|
ABOUT_IT.search(t) or LATER_SAID.search(t))
|
||||||
|
|
||||||
|
|
||||||
|
_TAKE_BACK = (r"아니(?:야|에요|요|오)?|아냐|아닐세|됐네|됐소|아닙니다|아니다|됐어|됐어요|됐습니다|됐다|괜찮아|괜찮아요|괜찮습니다|"
|
||||||
|
r"장난(?:이야|이에요|입니다|이다|임)?|농담(?:이야|이에요|입니다|이다|임)?|취소(?:할게|할게요|하겠습니다|해)?|"
|
||||||
|
r"하지 ?마(?:세요|십시오)?|하지 않으셔도 (?:돼요|됩니다)|안 ?(?:해도|하셔도) (?:돼|돼요|됩니다)|그만|"
|
||||||
|
r"just kidding|kidding|jk|never ?mind|forget (?:it|that)|scratch that|cancel (?:that|it)|nah|don'?t|not now")
|
||||||
|
TAKEN_BACK = re.compile( # the order taken back at the end: "따라와 주십시오, 아닙니다, 취소하겠습니다", "...장난이야~"
|
||||||
|
rf"[,.!~]\s*(?:(?:아|어|음|앗|아이고|에이|헐|no|oh|wait)\s*,?\s*)*(?:{_TAKE_BACK})(?:[\s,.!~]+(?:{_TAKE_BACK}|ㅋ+|ㅎ+))*[\s,.!~ㅋㅎ]*$",
|
||||||
|
re.I)
|
||||||
|
|
||||||
|
|
||||||
_VERBS = (r"go|come|move|turn|look|face|lift|raise|lower|wave|say|tell|follow|stop|halt|freeze|bring|fetch|get|take|pick|grab|"
|
_VERBS = (r"go|come|move|turn|look|face|lift|raise|lower|wave|say|tell|follow|stop|halt|freeze|bring|fetch|get|take|pick|grab|"
|
||||||
r"put|place|set|drop|give|hand|pass|reach|stretch|extend|hold|open|close|release|let (?:go|it|me)|back|drive|head|spin|rotate|show|"
|
r"put|place|set|drop|give|hand|pass|reach|stretch|extend|hold|open|close|release|let (?:go|it|me)|back|drive|head|spin|rotate|show|"
|
||||||
r"sing|play|keep|stay|wait|return|deliver|carry|make|do|try|find|check|stand|tilt|nod|shake|glance|swivel|center|"
|
r"sing|play|keep|stay|wait|return|deliver|carry|make|do|try|find|check|stand|tilt|nod|shake|glance|swivel|center|"
|
||||||
@@ -975,7 +1021,7 @@ _EN_ORDER = re.compile(
|
|||||||
rf"dinner|drink)|see(?! you\b))\b)|(?:can|could|would|will|wo?n'?t) you\b|would you mind\b|mind \w+ing\b|(?:i|we)(?:\s+|['’]d\s+)(?:want|need|"
|
rf"dinner|drink)|see(?! you\b))\b)|(?:can|could|would|will|wo?n'?t) you\b|would you mind\b|mind \w+ing\b|(?:i|we)(?:\s+|['’]d\s+)(?:want|need|"
|
||||||
rf"would like|like|wanna|would love|love) (?:you|lumi|the robot) to\b|i'?d (?:love|like) (?:it )?if you\b|it would be (?:great|nice|"
|
rf"would like|like|wanna|would love|love) (?:you|lumi|the robot) to\b|i'?d (?:love|like) (?:it )?if you\b|it would be (?:great|nice|"
|
||||||
rf"good|lovely) if you\b|it'?d be (?:great|nice|good|lovely) if you\b|(?:why don'?t you|how about you|maybe you could|"
|
rf"good|lovely) if you\b|it'?d be (?:great|nice|good|lovely) if you\b|(?:why don'?t you|how about you|maybe you could|"
|
||||||
rf"you (?:should|might want to))\b|i was wondering if you\b|(?:be a dear|do me a favou?r)\b|"
|
rf"you (?:should|might want to))\b|i was wondering if you\b|i(?: (?:order|command|instruct|beg|ask|am asking)|'m asking) you to\b|(?:be a dear|do me a favou?r)\b|"
|
||||||
rf"(?:{_VERBS})\b|\w+ing\b(?=.*\b(?:please|now)\b)|time to\b|on (?:you|your) go\b)", re.I)
|
rf"(?:{_VERBS})\b|\w+ing\b(?=.*\b(?:please|now)\b)|time to\b|on (?:you|your) go\b)", re.I)
|
||||||
_KO_ORDER = re.compile(
|
_KO_ORDER = re.compile(
|
||||||
r"(?:줘|줘요|주세요|주십시오|주시오|주게|주시게|주라|주렴|주시죠|줄래요?|주실래요?|주시겠어요|주시겠습니까|주실 수 있(?:어요|나요|"
|
r"(?:줘|줘요|주세요|주십시오|주시오|주게|주시게|주라|주렴|주시죠|줄래요?|주실래요?|주시겠어요|주시겠습니까|주실 수 있(?:어요|나요|"
|
||||||
@@ -1030,7 +1076,7 @@ def _clause_order(c, alone=True):
|
|||||||
return _ko_clause(c) or alone and len(c.split()) <= 5 and "?" not in c and not ko_told(c) and \
|
return _ko_clause(c) or alone and len(c.split()) <= 5 and "?" not in c and not ko_told(c) and \
|
||||||
not re.search(r"[가-힣](?:어|아|여|다|요|지|네|려|워)\W*$", c)
|
not re.search(r"[가-힣](?:어|아|여|다|요|지|네|려|워)\W*$", c)
|
||||||
if c.endswith("?"):
|
if c.endswith("?"):
|
||||||
return bool(re.match(rf"(?:please\s+)?(?:(?:{_VERBS})\b(?!s\b)(?!.*\b(?:or|is|are)\b)|(?:can|could|would|will|wo?n'?t) "
|
return bool(re.match(rf"(?:please\s+)?(?:(?:{_VERBS})\b(?!s\b)(?!.*\b(?:or|is|are)\b)|you can {_YOU_CAN}\b(?!.*\b(?:or|by yourself|alone)\b)|(?:can|could|would|will|wo?n'?t) "
|
||||||
r"(?:you|u)\b|would you mind\b|mind \w+ing\b|can i (?:have|get) (?:it|that|this|the)\b|can i take (?:it|that|this)\W*$|"
|
r"(?:you|u)\b|would you mind\b|mind \w+ing\b|can i (?:have|get) (?:it|that|this|the)\b|can i take (?:it|that|this)\W*$|"
|
||||||
r"why don'?t you\b|how about (?:you\b|\w+ing\b)|is it possible (?:for you )?to\b|could i trouble you\b)", c, re.I) or
|
r"why don'?t you\b|how about (?:you\b|\w+ing\b)|is it possible (?:for you )?to\b|could i trouble you\b)", c, re.I) or
|
||||||
re.search(r"\b(?:okay|ok|alright|please)\s*\?$", c, re.I) and not _SUBJECT.match(c))
|
re.search(r"\b(?:okay|ok|alright|please)\s*\?$", c, re.I) and not _SUBJECT.match(c))
|
||||||
@@ -1058,6 +1104,7 @@ def direct_order(text):
|
|||||||
(a statement, a story, a plan between people, a question about ability or habit) is read by the LLM with the talk
|
(a statement, a story, a plan between people, a question about ability or habit) is read by the LLM with the talk
|
||||||
before it. Each sentence / clause is checked; one order in it is enough (not_an_order weeds out the rest)."""
|
before it. Each sentence / clause is checked; one order in it is enough (not_an_order weeds out the rest)."""
|
||||||
t = re.sub(_LEAD, "", unfill(wording.ko_plain(text or "")).strip(), flags=re.I) # every speech level as 반말
|
t = re.sub(_LEAD, "", unfill(wording.ko_plain(text or "")).strip(), flags=re.I) # every speech level as 반말
|
||||||
|
t = re.sub(r"[\s~]*(?:[ㅋㅎ]{2,}|ㅠ+|ㅜ+)[\s~]*$|~+(?=\s*[?!.]*\s*$)", "", t) # "가 줄래~?", "고개 내려 ㅎㅎ"
|
||||||
t = re.sub(r"^(?:(?:hey |hi |ok |okay |yo |어이 )?(?:mister robot|lumi|loomi|rumi|robot|buddy|bro|dude|yeah|yes|yep|right|"
|
t = re.sub(r"^(?:(?:hey |hi |ok |okay |yo |어이 )?(?:mister robot|lumi|loomi|rumi|robot|buddy|bro|dude|yeah|yes|yep|right|"
|
||||||
r"(?:[루누류]미|루비|로봇)\s*(?:야|아|씨|님|군|선생님?|양반)?)[\s,!]+)+", "", t, flags=re.I)
|
r"(?:[루누류]미|루비|로봇)\s*(?:야|아|씨|님|군|선생님?|양반)?)[\s,!]+)+", "", t, flags=re.I)
|
||||||
clauses = [c.strip() for c in re.split(r"(?<=[.!?])\s+|[,:;]\s*|\s+(?:and|then|and then)\s+(?!a half\b)|…|\.{2,}|\s+[—–-]+\s*", t)
|
clauses = [c.strip() for c in re.split(r"(?<=[.!?])\s+|[,:;]\s*|\s+(?:and|then|and then)\s+(?!a half\b)|…|\.{2,}|\s+[—–-]+\s*", t)
|
||||||
@@ -1074,6 +1121,9 @@ def ko_told(t):
|
|||||||
return False # "배터리 얼마나 남았어?": a question, read elsewhere
|
return False # "배터리 얼마나 남았어?": a question, read elsewhere
|
||||||
if re.search(r"(?:는데|던데|더라고요?|더니|던걸)\W*$", t):
|
if re.search(r"(?:는데|던데|더라고요?|더니|던걸)\W*$", t):
|
||||||
return True # "어제 그 로봇은 손 흔들어 줬는데", "돌더니 손을 흔들더라고"
|
return True # "어제 그 로봇은 손 흔들어 줬는데", "돌더니 손을 흔들더라고"
|
||||||
|
m = re.search(r"(\S*[보가와해하오서])래요?\W*$", t) # "우리 애가 고개 숙여 보래요": an order told (-라고 해요)
|
||||||
|
if m and m.group(1) not in ("오", "그", "가", "이"): # not "오래요" (long), "그래요" (yes), "가래", "이래요"
|
||||||
|
return True
|
||||||
m = re.search(r"([가-힣])(?:어|어요|다|습니다|네|네요|지|죠|잖아|잖아요|더라|더라고요?)\W*$", t)
|
m = re.search(r"([가-힣])(?:어|어요|다|습니다|네|네요|지|죠|잖아|잖아요|더라|더라고요?)\W*$", t)
|
||||||
if m and (ord(m.group(1)) - 0xAC00) % 28 == 20 and m.group(1) not in "있겠": # ㅆ: 갔, 했, 줬, 흔들었
|
if m and (ord(m.group(1)) - 0xAC00) % 28 == 20 and m.group(1) not in "있겠": # ㅆ: 갔, 했, 줬, 흔들었
|
||||||
return True
|
return True
|
||||||
@@ -1081,7 +1131,7 @@ def ko_told(t):
|
|||||||
return bool(m and m.group(1) not in "줄릴" and (m.group(1) == "을" or (ord(m.group(1)) - 0xAC00) % 28 == 8))
|
return bool(m and m.group(1) not in "줄릴" and (m.group(1) == "을" or (ord(m.group(1)) - 0xAC00) % 28 == 8))
|
||||||
|
|
||||||
|
|
||||||
INSTEAD = re.compile(r"^.*?(?:[가-힣]지 ?말고\s*|\b(?:don'?t|do not)\b[^,.;!]*[,.;!]+\s*(?:(?:just|instead|but|rather)\b\W*)?)", re.I)
|
INSTEAD = re.compile(r"^.*?(?:[가-힣]지 ?말고\s*|(?<=[가-힣a-z0-9])\s+말고(?!도)\s+|\b(?:don'?t|do not)\b[^,.;!]*[,.;!]+\s*(?:(?:just|instead|but|rather)\b\W*)?)", re.I)
|
||||||
|
|
||||||
|
|
||||||
def instead_of(text):
|
def instead_of(text):
|
||||||
@@ -1110,6 +1160,9 @@ NOT_FOR_LLM = re.compile( # words the LLM must not turn into a motion although
|
|||||||
r"^\W*(?:go on|go ahead|come on)\W*,\s*(?:tell|ask|say|explain|keep|try|really|seriously|i'?m|you|that|it)\b|^\W*go figure\b|"
|
r"^\W*(?:go on|go ahead|come on)\W*,\s*(?:tell|ask|say|explain|keep|try|really|seriously|i'?m|you|that|it)\b|^\W*go figure\b|"
|
||||||
r"(?:더라|더라고|더라구|던데|려고|려구|거든|잖아|(?<!건)네|(?:한|간|온|본|준|된)대|" # "아까 뒤로 가더라", "물러나래": told, seen,
|
r"(?:더라|더라고|더라구|던데|려고|려구|거든|잖아|(?<!건)네|(?:한|간|온|본|준|된)대|" # "아까 뒤로 가더라", "물러나래": told, seen,
|
||||||
r"(?:하|가|오|와|보|봐|주|줘|해|돌|나|라|려)래)요?\W*$|" # reported, the speaker's plan; not "갈래?"
|
r"(?:하|가|오|와|보|봐|주|줘|해|돌|나|라|려)래)요?\W*$|" # reported, the speaker's plan; not "갈래?"
|
||||||
|
r"^\W*(?:(?:so|okay|ok|and|but|now)\W+)?(?:back to|going back to|getting back to|coming back to|returning to) "
|
||||||
|
r"(?:your|the|my|our|what|that)\b[^,]*,\s*(?:what|how|why|when|where|who|which|can|could|do|does|did|is|are|was|"
|
||||||
|
r"were|tell)\b|" # "back to your arm, what did you say?": a topic
|
||||||
r"\b(?:never ?mind|forget it|scratch that|cancel that)\b|\?\s*(?:nah|no|nope)\b|" # taken back at the end
|
r"\b(?:never ?mind|forget it|scratch that|cancel that)\b|\?\s*(?:nah|no|nope)\b|" # taken back at the end
|
||||||
r"\bgive (?:me|us) (?:a |one )?(?:sec|second|minute|moment|break|hint|clue|chance|call|ring)\b|\bgive it up for\b|"
|
r"\bgive (?:me|us) (?:a |one )?(?:sec|second|minute|moment|break|hint|clue|chance|call|ring)\b|\bgive it up for\b|"
|
||||||
r"\bbring it on\b|\bbring back memories\b|\bfollow (?:the|my|our|your) (?:money|rules|instructions|signs?|steps|advice|"
|
r"\bbring it on\b|\bbring back memories\b|\bfollow (?:the|my|our|your) (?:money|rules|instructions|signs?|steps|advice|"
|
||||||
@@ -1159,19 +1212,37 @@ ARM_TALK = re.compile( # words about the arm / hand that order nothing now (A1
|
|||||||
r"\b(?:did|have) (?:you|u)\b.*\b(?:earlier|before|yesterday|last time|ever)\b|\bearlier\b|\b(?:it|he|she|lumi|the robot) "
|
r"\b(?:did|have) (?:you|u)\b.*\b(?:earlier|before|yesterday|last time|ever)\b|\bearlier\b|\b(?:it|he|she|lumi|the robot) "
|
||||||
r"(?:refused|tried|failed|forgot|wanted|used) to\b|\bfly to the moon\b|\bwhen pigs fly\b|\byeah,? right\b|\bdid the wa\w*\b|"
|
r"(?:refused|tried|failed|forgot|wanted|used) to\b|\bfly to the moon\b|\bwhen pigs fly\b|\byeah,? right\b|\bdid the wa\w*\b|"
|
||||||
r"\bpolicy\b|\bin (?:english|korean)\b|\bwhat does .* mean\b|"
|
r"\bpolicy\b|\bin (?:english|korean)\b|\bwhat does .* mean\b|"
|
||||||
r"퍽이나|리가 (?:있|없)|수 ?있으면 ?(?:좋겠|대박|최고|멋|재밌)|만약에?|줄은 ?알|는 ?거 ?해도 ?(?:돼|되)|"
|
r"퍽이나|리가 (?:있|없)|수 ?있으면 ?(?:좋겠|대박|최고|멋|재밌)|만약에?|줄 ?(?:은 |도 )?(?:알|아(?:세요|십니까|노|니|나|요|냐|는가|는지|나요)|압니까|아시)|는 ?거 ?해도 ?(?:돼|되)|"
|
||||||
r"는 ?거 ?(?:진짜 |너무 |정말 |완전 )?(?:신기|멋있|멋지|귀엽|웃기|재밌|재미있)|기도 ?해\s*\?|수 ?있겠다|"
|
r"는 ?거 ?(?:진짜 |너무 |정말 |완전 |억수로 |엄청 |되게 |참 |아주 )?(?:신기|멋있|멋지|귀엽|웃기|재밌|재미있|제법)|기도 ?해\s*\?|수 ?있겠다|"
|
||||||
|
r"\bor not\s*\?|\bi (?:just|only) ask(?:ing)?\b|\b(?:in general|generally|usually|normally)\b|보통|평소에?|원래 (?:할 ?수|하)|\b(?:you|u) know how (?:to )?\w+|더군(?:요)?\W*$|"
|
||||||
r"파이팅|화이팅|\bfighting\b|영어로|한국어로|무슨 ?뜻|뜻이 ?뭐|얘기 ?들었|들어 ?봤|본 ?적|해 ?봤어\s*\?|봤어\s*\?|"
|
r"파이팅|화이팅|\bfighting\b|영어로|한국어로|무슨 ?뜻|뜻이 ?뭐|얘기 ?들었|들어 ?봤|본 ?적|해 ?봤어\s*\?|봤어\s*\?|"
|
||||||
r"[가-힣]지 ?(?:맙|마유|마소|마이소|마셈|마시오|마십시오|말라|말랑께|말어)|[가-힣]지 ?마(?=[가-힣]+(?:야|아)(?:\s|\W|$))", re.I)
|
r"[가-힣]지 ?(?:맙|마유|마소|마이소|마셈|마시오|마십시오|말라|말랑께|말어)|[가-힣]지 ?마(?=[가-힣]+(?:야|아)(?:\s|\W|$))", re.I)
|
||||||
|
|
||||||
|
|
||||||
HELD_BACK = re.compile( # the whole sentence asks for no motion now (A2): it starts with a no, a later time, or is taken back
|
HELD_BACK = re.compile( # the whole sentence asks for no motion now (A2): it starts with a no, a later time, or is taken back
|
||||||
r"^\W*(?:(?:hey|so|um+|uh+|okay|ok|lumi|well|robot|please)\W+)*(?:don'?t|do not|never)\b(?!\s+(?:look|stare|watch|stop|move)\b)|"
|
r"^\W*(?:(?:hey|so|um+|uh+|okay|ok|lumi|well|robot|please)\W+)*(?:don'?t|do not|never)\b(?!\s*mind\b)(?!\s+(?:look|stare|watch|stop|move)\b)|"
|
||||||
r"(?:^|\s)(?:밥|점심|저녁|커피|이거)\s*(?:다\s*)?(?:먹|마시)고(?:\s|$)|(?:^|\s)(?:끝나|다\s*하)고(?:\s|$)|"
|
r"(?:^|\s)(?:밥|점심|저녁|커피|이거)\s*(?:다\s*)?(?:먹|마시)고(?:\s|$)|(?:^|\s)(?:끝나|다\s*하)고(?:\s|$)|"
|
||||||
r"[,.!?]\s*(?:hmm,?\s*|oh,?\s*|ah,?\s*)?(?:forget it|never ?mind|cancel that|no,? don'?t)[\s.!]*$|"
|
r"[,.!?]\s*(?:hmm,?\s*|oh,?\s*|ah,?\s*)?(?:forget it|never ?mind|cancel that|no,? don'?t)[\s.!]*$|"
|
||||||
r"[,.!?]\s*(?:아\s*)?(?:됐어|됐다|취소|하지 ?마)[\s.!]*$|"
|
r"[,.!?]\s*(?:아\s*)?(?:됐어|됐다|취소|하지 ?마)[\s.!]*$|"
|
||||||
|
r"[,.!?~]\s*(?:(?:아|어|음|에이|아이고)\s*)?(?:(?:아니(?:야|요|에요|다|오)?|아닙니다|아냐|아녀|아이다|no)[\s,.!~]*)*" # taken back at
|
||||||
|
r"(?:(?:아냐|아니야|죄송합니다|죄송해요|미안해요?|sorry)\W*)?(?:됐(?:어|다|어요|습니다|슈|어유|다 아이가|소|구먼)|"
|
||||||
|
r"취소(?:할게요?|하겠습니다|요|해(?: ?(?:줘|주세요|주십시오|주이소))?)?|" # every level
|
||||||
|
r"(?:하지|안 ?하) ?않?(?:으셔도|으세도|아도|셔도|해도|하셔도) (?:돼|됩니다|돼요|괜찮(?:아|아요|습니다))|안 ?(?:하셔도|해도) (?:돼|됩니다|돼요)|"
|
||||||
|
r"괜찮(?:아|아요|습니다)|그냥 ?(?:있어|있어요|계세요|둬|둬요|놔둬|놔둬요|들고 있어|들고 계세요)|장난(?:이야|이에요|입니다|이지|임)|농담(?:이야|이에요|입니다|이지|임)|just kidding|kidding|jk)"
|
||||||
|
r"[\s.!~ㅋㅎ]*$|"
|
||||||
|
r"(?:^|\s)(?:나중에|이따가?|있다가|(?:행사|공연|발표|회의|수업)(?:가|이)? 끝난 ?(?:후|뒤|다음)에?)\W|" # later
|
||||||
|
r"(?<!괜찮으)(?<!괜찮으시)(?<!가능하)(?<!가능하시)(?<!원하)(?<!원하시)(?<!좋으)(?<![되돼])(?<=[가-힣])(?:으믄|믄)\s|" # "음악 나오믄 …"
|
||||||
|
r"\bif i (?:say|tell you|count|clap|give)\b|\b(?:a (?:minute|moment|second|while)|\w+ (?:minutes?|seconds?|hours?)) ago\b|"
|
||||||
|
r"\bno need to\b|\byou (?:don'?t|do not) (?:have|need) to\b|^\W*(?:(?:robot|lumi|hey)\W+)*(?:you|u) (?:not|no) (?!only\b)\w+|"
|
||||||
|
r"^\W*(?:(?:robot|lumi|hey|so|okay|ok)\W+)*no\s+(?!(?:problem|worries|way|more|need|one|thanks)\b)(?=(?:hold|offer|hand|give|"
|
||||||
|
r"put|set|wave|reach|pick|take|grab|place|move|go|turn|look|lift|fold|open|close|make|head|drive|scoot|roll|come|bring|"
|
||||||
|
r"follow|fetch|carry|return|raise|lower|spin|rotate)\b)|"
|
||||||
|
r"(?:는|은) ?거 ?(?:(?:진짜|너무|정말|완전|억수로|엄청|되게|참|아주|겁나|넘|좀)\s*)?(?:신기|멋있|멋지|귀엽|웃기|재밌|재미있|제법)|"
|
||||||
|
r"(?<!주)(?:드라|더라|더군|던데)(?:고|구)?(?:요)?\W*$|" # a remark: "… 가는 거 겁나 귀엽드라"
|
||||||
|
r"(?:^|\s)우리\s.*(?:갈까|가 ?볼까)(?:요)?(?![가-힣])|(?<![가-힣])여보(?![가-힣세])|[\s,](?:여+[—–-]*\s*)?(?:여보|자기야|얘들아|애들아)[\s.?!~…]*$|" # a plan between people
|
||||||
r"\b(?:yeah right|like you could|as if you could|at all)\b|\bafter (?:this|that|lunch|dinner|the show|the talk)\b|"
|
r"\b(?:yeah right|like you could|as if you could|at all)\b|\bafter (?:this|that|lunch|dinner|the show|the talk)\b|"
|
||||||
r"(?:^|\s)(?:형|누나|언니|오빠|엄마|아빠|얘들아)(?:\s|,)|(?<!보)지\s*(?:마|말)(?:라|랑께|라니까|아|어|래|게|요|세요|시오|십시오)?(?![가-힣])", re.I)
|
r"(?:^|\s)(?:형|누나|언니|오빠|엄마|아빠|얘들아)(?:\s|,)|(?<!보)지\s*(?:마|말)(?:라|랑께|라니까|아|어|래|게|요|세요|시오|십시오|이소|유|소|셈|십쇼|어유|어요)?(?![가-힣])|"
|
||||||
|
r"(?:하지|[가-힣]지) 않(?:으셔도|으셔두|아도|아두) (?:돼|되|됩니다|돼요|괜찮)|안 ?(?:하셔도|해도|하셔두|해두) (?:돼|되|됩니다|돼요|괜찮)", re.I)
|
||||||
# also sarcasm / an ability ("yeah right, like you could go ..."), later, words to a family member, a Korean no
|
# also sarcasm / an ability ("yeah right, like you could go ..."), later, words to a family member, a Korean no
|
||||||
|
|
||||||
|
|
||||||
@@ -1193,7 +1264,7 @@ def intent(text, markers=()):
|
|||||||
r"\b(can|could) you (pick( up)?|lift|hold|grab|take) (a|an|any)\b|" # "can you pick up a bottle?"
|
r"\b(can|could) you (pick( up)?|lift|hold|grab|take) (a|an|any)\b|" # "can you pick up a bottle?"
|
||||||
r"^\s*(what|when|which|at what|do you|does|is it(?! possible)|are you)\b|몇|언제|얼마|" # "at what level do you go back?"
|
r"^\s*(what|when|which|at what|do you|does|is it(?! possible)|are you)\b|몇|언제|얼마|" # "at what level do you go back?"
|
||||||
rf"({_OBJ})(은|는)\s.*수 ?있|(루미가|로봇이)\s.*수 ?있|는 ?거 ?(돼|되나|가능)|" # "물컵은 가져다줄 수 있어요?"
|
rf"({_OBJ})(은|는)\s.*수 ?있|(루미가|로봇이)\s.*수 ?있|는 ?거 ?(돼|되나|가능)|" # "물컵은 가져다줄 수 있어요?"
|
||||||
r"어떻게|왜|혼자|스스로|\bby yourself\b|\bsomeone\b|줄 ?알아|할 ?줄|\bcome here often\b|"
|
r"어떻게|왜|혼자|스스로|\bby yourself\b|\bsomeone\b|줄 ?알아|[을를] 줄 ?아(?:세요|십니까|시나요|나요?|니|노|요)?\s*\?|할 ?줄|\bcome here often\b|"
|
||||||
r"^\W*(?:even|only|also|and|but|so)?\s*(?:with|without|if|unless|while)\b.*\?\s*$", # "even with the lift down?"
|
r"^\W*(?:even|only|also|and|but|so)?\s*(?:with|without|if|unless|while)\b.*\?\s*$", # "even with the lift down?"
|
||||||
re.sub(_LEAD, "", CALLING.sub("", t), flags=re.I)) or LATER.search(CALLING.sub("", t)) # "Lumi, is it
|
re.sub(_LEAD, "", CALLING.sub("", t), flags=re.I)) or LATER.search(CALLING.sub("", t)) # "Lumi, is it
|
||||||
# hard to ...?", "Lumi Lumi, are you still following me?"
|
# hard to ...?", "Lumi Lumi, are you still following me?"
|
||||||
@@ -1218,21 +1289,25 @@ def intent(text, markers=()):
|
|||||||
return None # "go to the stage... wait, not the stage, the entrance": which?
|
return None # "go to the stage... wait, not the stage, the entrance": which?
|
||||||
if action == "waist":
|
if action == "waist":
|
||||||
if asks or visitor or "?" in t and not re.search(r"\b(?:can|could|would|will) (?:you|u)\b|줄래|주실래|줄 ?수|주시겠|"
|
if asks or visitor or "?" in t and not re.search(r"\b(?:can|could|would|will) (?:you|u)\b|줄래|주실래|줄 ?수|주시겠|"
|
||||||
r"있겠니|주겠니", t) or \
|
r"있겠니|주겠니|줘\s*\?|[가-힣] 수 ?있(?:을까|어|어요|나요|으세요|으신가요)", t) or \
|
||||||
re.search(r"\b(?:don'?t|do not|never|no need to)\b|[가-힣]지 ?마(?:세요|요|라)?(?![가-힣])", t):
|
re.search(r"\b(?:don'?t|do not|never|no need to)\b|[가-힣]지 ?마(?:세요|요|라)?(?![가-힣])", t):
|
||||||
return None # "how far can your waist turn?", "don't turn your waist"
|
return None # "how far can your waist turn?", "don't turn your waist"
|
||||||
if re.search(r"\b(?:front|forward|center|centre|straight|middle|back to (?:the )?front)\b|정면|가운데|원위치|원래대로|"
|
if re.search(r"\b(?:front|forward|center|centre|straight|middle|back to (?:the )?front)\b|정면|가운데|원위치|원래대로|"
|
||||||
r"앞(?:으로|쪽)|펴|곧게", t):
|
r"앞(?:으로|쪽)|펴|곧게", t):
|
||||||
return ("waist", "center")
|
return ("waist", "center")
|
||||||
side = re.findall(r"\bleft\b|\bright\b|왼쪽|오른쪽|좌측|우측", t)
|
side = re.findall(r"\bleft\b|\bright\b|왼쪽|오른쪽|좌측|우측|레프트|라이트", t)
|
||||||
if len(set(side)) != 1:
|
if len(set(side)) != 1:
|
||||||
return None # which way? the LLM asks
|
return None # which way? the LLM asks
|
||||||
side = "left" if side[0] in ("left", "왼쪽", "좌측") else "right"
|
side = "left" if side[0] in ("left", "왼쪽", "좌측", "레프트") else "right"
|
||||||
deg = re.search(r"(\d+)\s*(?:degrees?|도|°)", t)
|
deg = re.search(r"(\d+)\s*(?:degrees?|도|°)", t)
|
||||||
ko = not deg and re.search(rf"(?<![가-힣\d])({wording._SINO})\s*도(?![가-힣])", t)
|
ko = not deg and re.search(rf"(?<![가-힣\d])({wording._SINO})\s*도(?![가-힣])", t)
|
||||||
n = deg.group(1) if deg else wording.sino(ko.group(1)) if ko else None
|
n = deg.group(1) if deg else wording.sino(ko.group(1)) if ko else None
|
||||||
|
if not n and re.search(r"\bdegrees?\b|°|(?:[일이삼사오육칠팔구십백]|\d)\s*도|\d", t):
|
||||||
|
return None # "상체오른쪽으로십오도": an angle not read, asked
|
||||||
return ("waist", f"{side} {n}" if n else side)
|
return ("waist", f"{side} {n}" if n else side)
|
||||||
if action == "look_away":
|
if action == "look_away":
|
||||||
|
if re.search(r"아래|위|천장|하늘|바닥|발|밑|쪽|왼|오른|\b(?:down|up|floor|ceiling|left|right|there)\b", t):
|
||||||
|
return None # "발 밑 바라보지 마세요": not there, not away from me
|
||||||
return None if asks or "?" in t else ("look", "away") # "don't look at me", "쳐다보지 마"
|
return None if asks or "?" in t else ("look", "away") # "don't look at me", "쳐다보지 마"
|
||||||
if action in ("arm", "grip_open", "grip_close", "wave") and ARM_TALK.search(t):
|
if action in ("arm", "grip_open", "grip_close", "wave") and ARM_TALK.search(t):
|
||||||
return None # "I heard you can wave", "주먹 쥐고 파이팅!" (A1)
|
return None # "I heard you can wave", "주먹 쥐고 파이팅!" (A1)
|
||||||
@@ -1375,6 +1450,8 @@ def intent(text, markers=()):
|
|||||||
return ("move", f"{driving.direction(driving.clean(t))} {n:g}")
|
return ("move", f"{driving.direction(driving.clean(t))} {n:g}")
|
||||||
if action == "make_way" and re.search(r"\bover (?:there|dare|dere|thar)\b|\bthat (?:spot|place|way)\b|\bwhere i\b", t):
|
if action == "make_way" and re.search(r"\bover (?:there|dare|dere|thar)\b|\bthat (?:spot|place|way)\b|\bwhere i\b", t):
|
||||||
return None # "move over there": the spot pointed at (pointing.py), no back-off
|
return None # "move over there": the spot pointed at (pointing.py), no back-off
|
||||||
|
if action == "make_way" and re.search(r"(?<![가-힣])옆(?:으로|쪽으로|쪽)|\bsideways\b|\bto (?:the|one) side\b", t):
|
||||||
|
return None # "옆으로 조금만 비켜": which side is not said, asked (never back)
|
||||||
if action == "make_way":
|
if action == "make_way":
|
||||||
return ("move", "back 1") # owner: a checked 1 m back-off (lumi.move_by)
|
return ("move", "back 1") # owner: a checked 1 m back-off (lumi.move_by)
|
||||||
if action in ("move", "come_back", "go_point") and re.search(r"\barms?\b|팔", t):
|
if action in ("move", "come_back", "go_point") and re.search(r"\barms?\b|팔", t):
|
||||||
@@ -1445,7 +1522,7 @@ FIX_CANCEL = re.compile(r"^\W*(?:never ?mind|forget (?:it|that|about it)|cancel(
|
|||||||
r"말아 ?줘|가지 마(?:세요)?|not need(?:ed)?|no,? no|아니 ?아니|그냥 (?:있어|둬)(?:요)?|기다려(?:요)?)"
|
r"말아 ?줘|가지 마(?:세요)?|not need(?:ed)?|no,? no|아니 ?아니|그냥 (?:있어|둬)(?:요)?|기다려(?:요)?)"
|
||||||
r"(?:\W+(?:it'?s (?:fine|ok(?:ay)?|alright)|no worries|thanks?|thank you|sorry|we'?ll [\w ]+|"
|
r"(?:\W+(?:it'?s (?:fine|ok(?:ay)?|alright)|no worries|thanks?|thank you|sorry|we'?ll [\w ]+|"
|
||||||
r"i'?ll [\w ]+|괜찮아요?))*\W*$")
|
r"i'?ll [\w ]+|괜찮아요?))*\W*$")
|
||||||
_FIX_DIR = r"\b(?:left|right|forward|ahead|back(?:wards?)?|up|down)\b|왼쪽|오른쪽|앞|뒤|위|아래"
|
_FIX_DIR = r"\b(?:back ?up|left|right|forward|ahead|back(?:wards?)?|backward|retreat|reverse|up|down|raise|lower)\b|올려|내려|올리|내리|왼쪽|오른쪽|왼편|오른편|좌측|우측|전진|후진|앞|뒤|위|아래"
|
||||||
|
|
||||||
|
|
||||||
def _fix_kinds(t, markers):
|
def _fix_kinds(t, markers):
|
||||||
@@ -1501,7 +1578,13 @@ def self_correct(text, markers=()):
|
|||||||
re.search(r"\b(?:stop|halt|freeze|don'?t move)\b|멈춰|정지|그만(?!두|둬)|스톱|움직이지 ?마|거기 ?서", text, re.I):
|
re.search(r"\b(?:stop|halt|freeze|don'?t move)\b|멈춰|정지|그만(?!두|둬)|스톱|움직이지 ?마|거기 ?서", text, re.I):
|
||||||
return text # a message to say may hold any words; a stop always wins
|
return text # a message to say may hold any words; a stop always wins
|
||||||
# ("그만둬" / "그만두게" is a take-back: below)
|
# ("그만둬" / "그만두게" is a take-back: below)
|
||||||
t = wording.ko_plain(wording.norm(text, markers)) # "왼쪽 보세요, 아 아니 정면이요": every speech level as 반말
|
cut = re.sub(r"(?<=\S)(?=[—–]+\s*(?:아니|아\s|잘못|no\b|nope\b|wait\b|scratch\b|actually\b))", " ", text, flags=re.I)
|
||||||
|
# ^ "135도 돌아— 아니 왼편으로": a cut-off, not norm's stutter ("돌아— 아니" read as "아— 아" said twice)
|
||||||
|
t = wording.ko_plain(wording.norm(cut, markers)) # "왼쪽 보세요, 아 아니 정면이요": every speech level as 반말
|
||||||
|
if TAKEN_BACK.search(t) or re.search(r"[,.!?]\s*(?:아니(?:야|요)?\s*)?그냥 ?(?:있어|계세요|둬|놔둬|들고 있어)(?:요)?\W*$", t):
|
||||||
|
return "" # "이제 팔 접어 좀. 아니야 그냥 있어": taken back
|
||||||
|
if DRINK.search(t) and FIX.search(t):
|
||||||
|
return None # "사과 가져와 아니 아니 커피 한 잔 가져와": a drink, never a cup
|
||||||
t = re.sub(r"\s*(?:[—–…]+|--|\.{3})\s*(?:(?:no|actually|wait|oh|아니|아)\W+)*(?:keep it|hold (?:it|on to it)|leave it|"
|
t = re.sub(r"\s*(?:[—–…]+|--|\.{3})\s*(?:(?:no|actually|wait|oh|아니|아)\W+)*(?:keep it|hold (?:it|on to it)|leave it|"
|
||||||
r"just keep it|never ?mind|forget it|그냥 (?:둬|놔둬|들고 있어)(?:요)?|(?:아니\s*)?됐어(?:요)?)(?:\W+(?:keep it|"
|
r"just keep it|never ?mind|forget it|그냥 (?:둬|놔둬|들고 있어)(?:요)?|(?:아니\s*)?됐어(?:요)?)(?:\W+(?:keep it|"
|
||||||
r"hold (?:it|on to it)|just keep it|그냥 (?:둬|놔둬)(?:요)?))*\W*$", ", never mind", t) # "give it to me — never
|
r"hold (?:it|on to it)|just keep it|그냥 (?:둬|놔둬)(?:요)?))*\W*$", ", never mind", t) # "give it to me — never
|
||||||
@@ -1541,6 +1624,13 @@ def self_correct(text, markers=()):
|
|||||||
continue
|
continue
|
||||||
first, *rest = steps._SPLIT.split(right, maxsplit=1)
|
first, *rest = steps._SPLIT.split(right, maxsplit=1)
|
||||||
lk, rk = _fix_kinds(left, markers), _fix_kinds(first, markers)
|
lk, rk = _fix_kinds(left, markers), _fix_kinds(first, markers)
|
||||||
|
from assistant import chain
|
||||||
|
if not rest and chain._restated(first, left) and _reads(left, markers) and \
|
||||||
|
all(w in left for w in re.findall(r"[가-힣]+", wording.ko_plain(first))[:-1]
|
||||||
|
if w not in ("좀", "혹시", "그럼", "그냥", "다시", "제발")) and \
|
||||||
|
not set(rk) - {"direction"} and not re.search(r"\d|왼|오른|좌|우측|앞|뒤로|\b(?:left|right|forward|back)\b", first):
|
||||||
|
t = left # "좌측으로 20센티 움직여 줘, 아니 움직이실래요?": the same order
|
||||||
|
continue # said again more politely, not a new one
|
||||||
tail = re.sub(r"\s+", " ", "".join(
|
tail = re.sub(r"\s+", " ", "".join(
|
||||||
ch for ch in re.sub("|".join(x.group(0).replace(".", r"\.") for k in rk for x in rk[k]) or r"(?!)", " ", first)))
|
ch for ch in re.sub("|".join(x.group(0).replace(".", r"\.") for k in rk for x in rk[k]) or r"(?!)", " ", first)))
|
||||||
tail = re.sub(r"^(?:\s*(?:the|a|an|one|to|으로|로|을|를|에|만|instead|then|please|is|it'?s)\b\s*)+|"
|
tail = re.sub(r"^(?:\s*(?:the|a|an|one|to|으로|로|을|를|에|만|instead|then|please|is|it'?s)\b\s*)+|"
|
||||||
@@ -1557,6 +1647,10 @@ def self_correct(text, markers=()):
|
|||||||
return f"{keep}, {first}" if keep else first
|
return f"{keep}, {first}" if keep else first
|
||||||
if rk and tail and set(rk) >= set(_fix_kinds(clauses[-1], markers)) and _reads(first, markers):
|
if rk and tail and set(rk) >= set(_fix_kinds(clauses[-1], markers)) and _reads(first, markers):
|
||||||
new = instead() # "go to start, no, go to end", "start로 가, 아니 end로 가서 줘"
|
new = instead() # "go to start, no, go to end", "start로 가, 아니 end로 가서 줘"
|
||||||
|
elif "direction" in rk and tail and _reads(first, markers) and \
|
||||||
|
{x.group(0) for x in rk["direction"]} != {x.group(0) for x in lk.get("direction", [])}:
|
||||||
|
new = instead() # "오른쪽으로 135도 돌아, 아 잘못 말했다, 몸통째 왼쪽으로 돌려": a new
|
||||||
|
# order said in full, nothing of the first one kept
|
||||||
elif not rk and re.fullmatch(r"\d+(?:\.\d+)?", first) and (nums := list(re.finditer(r"\d+(?:\.\d+)?", left))):
|
elif not rk and re.fullmatch(r"\d+(?:\.\d+)?", first) and (nums := list(re.finditer(r"\d+(?:\.\d+)?", left))):
|
||||||
x = nums[-1] # "turn left 45 degrees, no, 30": the number
|
x = nums[-1] # "turn left 45 degrees, no, 30": the number
|
||||||
fixed = left[:x.start()] + first + left[x.end():]
|
fixed = left[:x.start()] + first + left[x.end():]
|
||||||
@@ -1653,6 +1747,13 @@ def _as_place(name):
|
|||||||
return name if name in ("here", None) else {"marker": name}
|
return name if name in ("here", None) else {"marker": name}
|
||||||
|
|
||||||
|
|
||||||
|
_OBJ_ADJ = rf"(?:(?:{_COL}|작은|큰|왼쪽|오른쪽|가까운|먼|제일|가장)\s*)*+" # possessive: no backtracking
|
||||||
|
_AT_OBJ_EN = rf"\b(?:{_OBJ})s?,? (?:that'?s |that is |which is |sitting |lying |standing |left )?(?:on|at|by|near) (?:the )?$"
|
||||||
|
_AT_OBJ_KO = (rf"\s*(?:(?:위|쪽)\s*)?(?:에|의)\s*(?:(?:있는|있던|놓인|놓여\s*있는|둔|올려\s*둔|올려진|올라간|올라가\s*있는)\s*)?"
|
||||||
|
rf"{_OBJ_ADJ}(?:{_OBJ})|\s*(?:(?:에|의)\s*)?(?:있는|있던|놓인|놓여\s*있는|둔)\s*(?:거|것|걸)")
|
||||||
|
# ^ where the thing is ("the cup on p2", "p2에 있는 빨간 컵", "피원 컵", "p1의 컵"): the source, not where it goes
|
||||||
|
|
||||||
|
|
||||||
def _mentions(text, markers):
|
def _mentions(text, markers):
|
||||||
"""What the words name: {"object", "colour", "prefer", "source", "dest", "finish"}, only the fields mentioned.
|
"""What the words name: {"object", "colour", "prefer", "source", "dest", "finish"}, only the fields mentioned.
|
||||||
"object" / "source" / "dest" is None when the word is there but unknown."""
|
"object" / "source" / "dest" is None when the word is there but unknown."""
|
||||||
@@ -1668,7 +1769,10 @@ def _mentions(text, markers):
|
|||||||
before, after, place = t[:m.start()], t[m.end():], _resolve(m, markers)
|
before, after, place = t[:m.start()], t[m.end():], _resolve(m, markers)
|
||||||
if re.search(r"\bfrom (the )?$", before) or re.match(r"\s*에서", after) \
|
if re.search(r"\bfrom (the )?$", before) or re.match(r"\s*에서", after) \
|
||||||
or (re.search(r"\b(go|drive|head|come) (over )?to (the )?$", before) # "go to p1 and get the cup"
|
or (re.search(r"\b(go|drive|head|come) (over )?to (the )?$", before) # "go to p1 and get the cup"
|
||||||
and re.match(r"\s*(,|and|then)\s*(get|fetch|take|pick|grab|bring)", after)):
|
and re.match(r"\s*(,|and|then)\s*(get|fetch|take|pick|grab|bring)", after)) \
|
||||||
|
or re.search(_AT_OBJ_EN, before) or re.match(_AT_OBJ_KO, after) \
|
||||||
|
or (re.match(rf"\s+{_OBJ_ADJ}(?:{_OBJ})", after) and not re.search(r"\b(to|into|onto) (the )?$", before)):
|
||||||
|
# ^ "the cup on p2", "p2에 있는 컵", "피원 컵을", "p1 red cup bring me"
|
||||||
out["source"] = _as_place(place)
|
out["source"] = _as_place(place)
|
||||||
elif re.search(r"\b(to|into) (the )?$|\b(bring|fetch|give|get)( it| that| this)? $", before) \
|
elif re.search(r"\b(to|into) (the )?$|\b(bring|fetch|give|get)( it| that| this)? $", before) \
|
||||||
or re.match(r"\s*(으로|로|에다|에|한테)(?!서)", after) or place == "here":
|
or re.match(r"\s*(으로|로|에다|에|한테)(?!서)", after) or place == "here":
|
||||||
@@ -1685,6 +1789,13 @@ def _mentions(text, markers):
|
|||||||
out["dest"] = None
|
out["dest"] = None
|
||||||
if "dest" not in out and re.search(r"\b(bring|get|fetch|give) (it |that |this )?(to )?me\b|\bto me\b|가져와|가지고 ?와|갖다 ?줘|가져다 ?(?:줘|주세요|줄래)", t):
|
if "dest" not in out and re.search(r"\b(bring|get|fetch|give) (it |that |this )?(to )?me\b|\bto me\b|가져와|가지고 ?와|갖다 ?줘|가져다 ?(?:줘|주세요|줄래)", t):
|
||||||
out["dest"] = "here"
|
out["dest"] = "here"
|
||||||
|
if "dest" not in out and (re.search(r"\b(?:bring|fetch)(?:ing)?\b", t) and isinstance(out.get("source"), dict)
|
||||||
|
and not re.search(r"\b(?:to|for) (?!me\b|us\b)\w", t)
|
||||||
|
or re.search(r"(?:갖다|가져다|갖고|가지고)\s*(?:좀\s*)?(?:줘|주|조|드려|드리)", t)
|
||||||
|
and not any(p not in ("나", "저", "내", "제") for p in
|
||||||
|
re.findall(r"([가-힣]+?)\s*(?:한테|에게|께)(?!서)", t))):
|
||||||
|
out["dest"] = "here" # "fetch the cup from p2", "p2에서 컵 갖다 주시겠어요?": to the one who asks, not to
|
||||||
|
# "Minsu" ("민수한테 갖다 줘", "bring it to Minsu": a person is asked about)
|
||||||
if re.search(rf"\b(put|place|leave|set) (it|that|this|the \w+)\b.*\b(on|onto) (the )?({_TABLE})\b|\bplace\b"
|
if re.search(rf"\b(put|place|leave|set) (it|that|this|the \w+)\b.*\b(on|onto) (the )?({_TABLE})\b|\bplace\b"
|
||||||
rf"|놔|놓아|놓고|둬", t):
|
rf"|놔|놓아|놓고|둬", t):
|
||||||
out["finish"] = "place"
|
out["finish"] = "place"
|
||||||
@@ -1800,6 +1911,12 @@ UNCLEAR_RETRY = ("\n\n(These words may be short, broken or odd, but they mean so
|
|||||||
"you can't do it and why. Choose unclear only if they really mean nothing.)")
|
"you can't do it and why. Choose unclear only if they really mean nothing.)")
|
||||||
|
|
||||||
|
|
||||||
|
ASKS_AGAIN = re.compile(r"\bdidn'?t (?:quite )?(?:catch|understand|get)\b|\b(?:could|can|would) you (?:please )?(?:say|repeat) "
|
||||||
|
r"(?:that|it|them)\b|\bsay (?:that|it) again\b|\bnot sure what you(?:'re| are)? (?:mean|referring)|"
|
||||||
|
r"\bplease clarify\b|\bcould you (?:please )?clarify\b|잘 ?못 알아들|다시 (?:한 ?번 ?)?말씀해|"
|
||||||
|
r"\bwhat do you mean by\b|\bwhich \w+ do you mean\b|이해하지 못했|무슨 말씀이신지|무슨 뜻인지 (?:잘 )?모르|"
|
||||||
|
r"(?:어떤|무슨|어느) \S+(?:을|를)? 말씀하시는|불분명", re.I)
|
||||||
|
# a reply that asks to hear the words again
|
||||||
UNSURE_ANSWER = re.compile(r"^\W*(?:maybe|perhaps|not really|kind of|sort of|i don'?t know|글쎄요?|아마(?:도)?|몰라요?|모르겠어요?)\W*$",
|
UNSURE_ANSWER = re.compile(r"^\W*(?:maybe|perhaps|not really|kind of|sort of|i don'?t know|글쎄요?|아마(?:도)?|몰라요?|모르겠어요?)\W*$",
|
||||||
re.I) # an answer to Lumi's question, not filler
|
re.I) # an answer to Lumi's question, not filler
|
||||||
|
|
||||||
@@ -1868,7 +1985,7 @@ SUPPORTS = {**{c: c for c in objects.COCO if c != "person" and c not in OBJECTS.
|
|||||||
"책상": "dining table", "식탁": "dining table", "의자": "chair", "소파": "couch", "벤치": "bench", "침대": "bed"} # word -> camera class
|
"책상": "dining table", "식탁": "dining table", "의자": "chair", "소파": "couch", "벤치": "bench", "침대": "bed"} # word -> camera class
|
||||||
|
|
||||||
|
|
||||||
MISSPELT = {"dinning": "dining", "dinner table": "dining table", "dinining": "dining", "tabel": "table",
|
MISSPELT = {"dinning": "dining", "dinner table": "dining table", "dinining": "dining", "tabel": "table", "talbe": "table",
|
||||||
"tabe": "table", "tabble": "table", "chiar": "chair", "chari": "chair", "char": "chair", "sofaa": "sofa"}
|
"tabe": "table", "tabble": "table", "chiar": "chair", "chari": "chair", "char": "chair", "sofaa": "sofa"}
|
||||||
# typed / heard support words -> the word (place_on)
|
# typed / heard support words -> the word (place_on)
|
||||||
PREFER = {"lower": "low", "low": "low", "lowest": "low", "shorter": "low", "smaller": "small", "small": "small",
|
PREFER = {"lower": "low", "low": "low", "lowest": "low", "shorter": "low", "smaller": "small", "small": "small",
|
||||||
@@ -1903,7 +2020,7 @@ def pick_prefer(text):
|
|||||||
if m:
|
if m:
|
||||||
return m.group(2), t[:m.end(1)] + t[m.end():]
|
return m.group(2), t[:m.end(1)] + t[m.end():]
|
||||||
m = re.search(rf"(?:(?:제일|가장|더)\s*)?(작은|큰|왼쪽(?:에\s*있는|의)?|오른쪽(?:에\s*있는|의)?|가까운|가까이\s*있는|먼|"
|
m = re.search(rf"(?:(?:제일|가장|더)\s*)?(작은|큰|왼쪽(?:에\s*있는|의)?|오른쪽(?:에\s*있는|의)?|가까운|가까이\s*있는|먼|"
|
||||||
rf"멀리\s*있는)\s*(?=(?:(?:{_COL})\s*)?(?:{_OBJ}))", t)
|
rf"멀리\s*있는)\s*(?=(?:(?:{_COL})\s*)?(?:{_OBJ})|(?:거|것|걸)(?![가-힣]))", t)
|
||||||
if m:
|
if m:
|
||||||
return next(v for k, v in PICK_PREFER_KO if m.group(1).startswith(k)), t[:m.start()] + t[m.end():]
|
return next(v for k, v in PICK_PREFER_KO if m.group(1).startswith(k)), t[:m.start()] + t[m.end():]
|
||||||
return None, text
|
return None, text
|
||||||
@@ -1971,7 +2088,8 @@ RECEIVE_EN = re.compile(
|
|||||||
rf"|\bi(?:'m| am)\s+(?:giving|handing)\s+you\b|\bi (?:have|got|brought) (?:something|a \w+|this|it) for you\b", re.I)
|
rf"|\bi(?:'m| am)\s+(?:giving|handing)\s+you\b|\bi (?:have|got|brought) (?:something|a \w+|this|it) for you\b", re.I)
|
||||||
RECEIVE_KO = re.compile(
|
RECEIVE_KO = re.compile(
|
||||||
r"(?<!에서 )(?<!한테 )(?<!한테서 )(?<!에게서 )받아(?!들|서 ?(?:가|와)| ?적)|받으세요|받아요|받을래|"
|
r"(?<!에서 )(?<!한테 )(?<!한테서 )(?<!에게서 )받아(?!들|서 ?(?:가|와)| ?적)|받으세요|받아요|받을래|"
|
||||||
r"(?:드릴게|드릴께|줄게|줄께|드리려고|주려고|드릴 ?거|줄 ?거)(?!.*(?:줘|주세요))|"
|
r"(?<![아어여해와봐워켜꺼려펴쳐져겨셔혀며녀벼떠써러라사] )(?<![아어여해와봐워켜꺼려펴쳐져겨셔혀며녀벼떠써러라사])" # not "불러 줄게",
|
||||||
|
r"(?:드릴게|드릴께|줄게|줄께|드리려고|주려고|드릴 ?거|줄 ?거)(?!.*(?:줘|주세요))|" # "알려 드릴게요": another verb, for you
|
||||||
rf"(?:(?<![가-힣]){_THIS_KO}(?:\s*(?:{_COL}))?(?:\s*(?:{_OBJ}))?(?:을|를)?(?=\s*(?:좀\s*)?(?:가져가|들고|쥐고|들어|맡아|잡아))(?!\s*(?:좀\s*)?잡아)|(?<![가-힣]){_THIS_KO}(?:을|를)?|(?:내|제) 손에 (?:있는|든) (?:거|것|(?:\S+\s+)?\S+))\s*(?:좀\s*)?"
|
rf"(?:(?<![가-힣]){_THIS_KO}(?:\s*(?:{_COL}))?(?:\s*(?:{_OBJ}))?(?:을|를)?(?=\s*(?:좀\s*)?(?:가져가|들고|쥐고|들어|맡아|잡아))(?!\s*(?:좀\s*)?잡아)|(?<![가-힣]){_THIS_KO}(?:을|를)?|(?:내|제) 손에 (?:있는|든) (?:거|것|(?:\S+\s+)?\S+))\s*(?:좀\s*)?"
|
||||||
r"(?:가져가|들고 ?있어|쥐고 ?있어|들어 ?줘|들어 ?주세요|잡아(?!당)|맡아)|"
|
r"(?:가져가|들고 ?있어|쥐고 ?있어|들어 ?줘|들어 ?주세요|잡아(?!당)|맡아)|"
|
||||||
r"(?:이거|이것|이걸|요거)\s*(?:좀\s*)?(?:hold|take|catch|keep)\s*(?:좀\s*)?(?:해|하세요)|"
|
r"(?:이거|이것|이걸|요거)\s*(?:좀\s*)?(?:hold|take|catch|keep)\s*(?:좀\s*)?(?:해|하세요)|"
|
||||||
@@ -2006,7 +2124,9 @@ HAND_Q = re.compile(r"^\W*(?:what|how|why|when|where|which|who|do|does|did|is|ar
|
|||||||
r"(?<!줄 )(?<!주실 )(?<!받을 )수 ?있(?:어|나|니|을까|습니까)|\bif i\b", re.I)
|
r"(?<!줄 )(?<!주실 )(?<!받을 )수 ?있(?:어|나|니|을까|습니까)|\bif i\b", re.I)
|
||||||
MULTI = re.compile(r"\b(?:and then|then|after that|go to|drive to|come back|bring it to (?!me\b))\b|그리고|가서|다음에|"
|
MULTI = re.compile(r"\b(?:and then|then|after that|go to|drive to|come back|bring it to (?!me\b))\b|그리고|가서|다음에|"
|
||||||
r"(?:으로|로) ?(?:가|와)", re.I)
|
r"(?:으로|로) ?(?:가|와)", re.I)
|
||||||
FLOOR = re.compile(r"(?<!not on the )(?<!not the )(?<!not on )\b(?:floor|ground)\b(?!\s*(?:but|instead))|바닥(?!\s*(?:에\s*)?말고)", re.I) # the arm reaches table height, never the floor
|
FLOOR = re.compile(r"(?<!not on the )(?<!not the )(?<!not on )\b(?:floor|ground)\b(?!\s*(?:but|instead))|바닥(?!\s*(?:에\s*)?말고)|"
|
||||||
|
r"(?<![가-힣])땅(?:바닥)?(?:에|으로|위)|(?:의자|책상|테이블|탁자|소파|벤치)\s*(?:밑|아래)|"
|
||||||
|
r"\bunder(?:neath)? (?:the |that |this |a )?(?:chair|table|desk|bench|sofa)\b", re.I) # the arm reaches table height, never the floor
|
||||||
_PLACE_AFTER = r"(?![\s_]*(?:bottle|cup|mug|glass|co[rn]\w*|bar|shop|zone|area|machine|table|코너|바|숍|샵|머신|존|테이블|병|컵))"
|
_PLACE_AFTER = r"(?![\s_]*(?:bottle|cup|mug|glass|co[rn]\w*|bar|shop|zone|area|machine|table|코너|바|숍|샵|머신|존|테이블|병|컵))"
|
||||||
DRINK = re.compile(rf"\b(?:coffee|tea|juice|beer|wine|latte|soda|cola|coke|drink|milk|americano|espresso|cappuccino|"
|
DRINK = re.compile(rf"\b(?:coffee|tea|juice|beer|wine|latte|soda|cola|coke|drink|milk|americano|espresso|cappuccino|"
|
||||||
rf"smoothie|lemonade)(?:e?s)?\b{_PLACE_AFTER}|(?:아메리카노|에스프레소|카푸치노|스무디|레모네이드|녹차|홍차|보리차|유자차|밀크티)|"
|
rf"smoothie|lemonade)(?:e?s)?\b{_PLACE_AFTER}|(?:아메리카노|에스프레소|카푸치노|스무디|레모네이드|녹차|홍차|보리차|유자차|밀크티)|"
|
||||||
@@ -2047,15 +2167,15 @@ REFUSE_OPEN = ("I won't open my hand while I'm holding something: it would fall.
|
|||||||
|
|
||||||
# ---------- while holding: any request to hand the held thing over (the arm goes forward to `give`; whoever is in
|
# ---------- while holding: any request to hand the held thing over (the arm goes forward to `give`; whoever is in
|
||||||
# front takes it, the speaker or the person they point at: no person is aimed at or driven to) ----------
|
# front takes it, the speaker or the person they point at: no person is aimed at or driven to) ----------
|
||||||
_GV = r"(?:give|gib|givv?e?|hand|pass|deliver|bring)"
|
_GV = r"(?:give|gib|givv?e?|gi+ve|gve|hand|pass|deliver|bring)"
|
||||||
_GIVE_TO = (r"(?:me|us|him|her|them|my \w+|this \w+|that \w+|the \w+(?: \w+)?|(?:the )?(?:left|right) (?:one|person|guy|lady))")
|
_GIVE_TO = (r"(?:me|us|him|her|them|my \w+|this \w+|that \w+|the \w+(?: \w+)?|(?:the )?(?:left|right) (?:one|person|guy|lady))")
|
||||||
GIVE_HELD_EN = re.compile(
|
GIVE_HELD_EN = re.compile(
|
||||||
rf"\b{_GV}\s+(?:{_GIVE_TO}\s+)?(?:{_IT}|that one|this one|the (?:{_OBJ})s?|(?:(?:{_COL})\s+)?(?:{_OBJ})s?|what you(?:'?re| are)? hold(?:ing)?)\b"
|
rf"\b{_GV}\s+(?:{_GIVE_TO}\s+)?(?:{_IT}|that one|this one|the (?:{_OBJ})s?|(?:(?:{_COL})\s+)?(?:{_OBJ})s?|what you(?:'?re| are)? hold(?:ing)?)\b"
|
||||||
r"(?!\s+(?:a|an|up|try|rest|go|shot|chance|break)\b)"
|
r"(?!\s+(?:a|an|up|try|rest|go|shot|chance|break)\b)"
|
||||||
rf"|\b{_GV}\s+(?:{_IT}\s+)?(?:over|back)\b|\b{_GV}\s+(?:{_IT}\s+)?to\s+(?!the (?:\w+ )?(?:table|chair|desk|floor)\b)\w"
|
rf"|^\W*(?:that|this|the \w+) one to me\b|\b{_GV}\s+(?:{_IT}\s+)?(?:over|back)\b|\b{_GV}\s+(?:{_IT}\s+)?to\s+(?!the (?:\w+ )?(?:table|chair|desk|floor)\b)\w"
|
||||||
rf"|\b{_GV}\s+(?:me|us)\b(?!\s+(?:a|an|some|your|his|her|their|directions|time|space|the (?!(?:{_OBJ})s?\b|thing|one)\w+)\b)"
|
rf"|\b{_GV}\s+(?:me|us)\b(?!\s+(?:a|an|some|your|his|her|their|directions|time|space|the (?!(?:{_OBJ})s?\b|thing|one)\w+)\b)"
|
||||||
rf"|\b(?:{_GV}|passed|handed)\s+(?:\w+\s+){{0,3}}?to (?:me|us)\b|\b(?:pop|drop|put|release|let go of|place)\b.*\b(?:in|into) my hands?\b|\brelease it to me\b"
|
rf"|\b(?:{_GV}|passed|handed)\s+(?:\w+\s+){{0,3}}?to (?:me|us)\b|\b(?:pop|drop|put|release|let go of|place)\b.*\b(?:in|into) my hands?\b|\brelease it to me\b"
|
||||||
r"|\b(?:give|hand|pass|gib|giv)(?: (?:it|me|over|it over|that|it to me))?\s*(?:해|하|좀|부탁|플리즈|가자)|\bgimme\b|\b(?:can|may|could) (?:i|my \w+)(?: please)? (?:have|get|take) (?:it|that|this|the \w+)\b|"
|
r"|(?<!your )(?<!my )(?<!the )(?<!a )(?<!his )(?<!her )(?<!our )(?<!ur )\b(?:give|hand|pass|gib|giv)(?: (?:it|me|over|it over|that|it to me))?\s*(?:해|하|좀|부탁|플리즈|가자)|\bgimme\b|\b(?:can|may|could) (?:i|my \w+)(?: please)? (?:have|get|take) (?:it|that|this|the \w+)\b|"
|
||||||
r"\bi'?d (?:like|love) to (?:have|take) (?:it|that|this)\b|\bi want (?:it|that|this|what you|the (?:\w+ ){1,2}you'?re holding)\b|"
|
r"\bi'?d (?:like|love) to (?:have|take) (?:it|that|this)\b|\bi want (?:it|that|this|what you|the (?:\w+ ){1,2}you'?re holding)\b|"
|
||||||
r"\bi'?ll take (?:it|that|this)\b(?! from here)|\bwould you mind (?:handing|giving|passing)\b|\blet me (?:have|take|hold) (?:it|that|this)\b|"
|
r"\bi'?ll take (?:it|that|this)\b(?! from here)|\bwould you mind (?:handing|giving|passing)\b|\blet me (?:have|take|hold) (?:it|that|this)\b|"
|
||||||
r"\b(?:that'?s|it'?s) mine\b|^\W*(?:the \w+,?\s+)?to me\b|^\W*over here\b|^\W*(?:okay,? )?(?:and )?now me\W*$", re.I)
|
r"\b(?:that'?s|it'?s) mine\b|^\W*(?:the \w+,?\s+)?to me\b|^\W*over here\b|^\W*(?:okay,? )?(?:and )?now me\W*$", re.I)
|
||||||
@@ -2063,7 +2183,7 @@ GIVE_HELD_KO = re.compile(
|
|||||||
r"(?<![가-힣])(건네 ?|넘겨 ?|돌려 ?|전해 ?)?(?:줘|줘요|주세요|주게|주시게|주시오|주이소|주라|주렴|주십시오|주시겠(?:어요|습니까)|줄래요?|"
|
r"(?<![가-힣])(건네 ?|넘겨 ?|돌려 ?|전해 ?)?(?:줘|줘요|주세요|주게|주시게|주시오|주이소|주라|주렴|주십시오|주시겠(?:어요|습니까)|줄래요?|"
|
||||||
r"주실래요?|주실 수 있(?:어요|나요|을까요)|줄 수 있(?:어|어요|니|나요)|드려|드려요|드리세요|드리게|드리시오|내놔|내놓아|"
|
r"주실래요?|주실 수 있(?:어요|나요|을까요)|줄 수 있(?:어|어요|니|나요)|드려|드려요|드리세요|드리게|드리시오|내놔|내놓아|"
|
||||||
r"내놓으세요|넘겨|건네|줘도 ?돼요?|주면 ?돼요?|주시면 ?돼요?|주랑께|주쇼|주이소|주십쇼|주(?:시)?면 ?안 ?(?:돼|될까)요?|(?:(?<=한테 )|(?<=에게 )|(?<=거 ))도(?=\W*$)|주셨으면 ?(?:해요|좋겠어요)|"
|
r"내놓으세요|넘겨|건네|줘도 ?돼요?|주면 ?돼요?|주시면 ?돼요?|주랑께|주쇼|주이소|주십쇼|주(?:시)?면 ?안 ?(?:돼|될까)요?|(?:(?<=한테 )|(?<=에게 )|(?<=거 ))도(?=\W*$)|주셨으면 ?(?:해요|좋겠어요)|"
|
||||||
r"전해라|전해요|건네요|건네라|넘기세요|넘겨라|넘겨요|(?:(?<=나 )|(?<=저 )|(?<=이리 ))도(?=\W*$))(?:\s*봐요?)?(?:잉|예|유|용)?(?![가-힣])|"
|
r"전해라|전해요|건네요|건네라|건네게|건네시게|넘기세요|넘겨라|넘겨요|(?:(?<=나 )|(?<=저 )|(?<=이리 ))도(?=\W*$))(?:\s*봐요?)?(?:잉|예|유|용)?(?![가-힣])|"
|
||||||
r"(?:제가|내가)\s*(?:받을|가져갈)(?:게|께)요?")
|
r"(?:제가|내가)\s*(?:받을|가져갈)(?:게|께)요?")
|
||||||
GIVE_HELD_NOT = re.compile( # a cancel, a past, a place word, "not yet": never a hand-over
|
GIVE_HELD_NOT = re.compile( # a cancel, a past, a place word, "not yet": never a hand-over
|
||||||
r"\b(?:never ?mind|cancel|forget it|keep (?:it|holding)|not yet|yet|hold on|wait|gave|given|giving|gives|put|place|set|"
|
r"\b(?:never ?mind|cancel|forget it|keep (?:it|holding)|not yet|yet|hold on|wait|gave|given|giving|gives|put|place|set|"
|
||||||
@@ -2073,12 +2193,12 @@ 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|[가-힣](?<![들쥐이말])고\s|그리고|다음에|가서", re.I) # one part of several: the chain's
|
r"\band\b(?! (?:give|hand|pass|now)\b)|\b(?:then|after that|also)\b|[가-힣](?<![들쥐이말])고\s|그리고|다음에|가서", re.I) # one part of several: the chain's
|
||||||
_OTHER_CLAUSE = re.compile(r"[,.;]\s*(?:and |because |since |cause )?(?:he|she|they)(?:'s|'re| is| are| was| will|'ll| has| "
|
_OTHER_CLAUSE = re.compile(r"[,.;]\s*(?:and |because |since |cause )?(?:he|she|they)(?:'s|'re| is| are| was| will|'ll| has| "
|
||||||
r"needs?| wants?| goes| going)\b.*$|[,.]\s*(?:그분|그 ?사람|저 ?분|이 ?분|걔|그 ?친구|그녀)\S*\s.*$", re.I)
|
r"needs?| wants?| goes| going)\b.*$|[,.]\s*(?:그분|그 ?사람|저 ?분|이 ?분|걔|그 ?친구|그녀)\S*\s.*$", re.I)
|
||||||
_KO_VERB_BEFORE = re.compile(r"(?:아|어|여|해|와|봐|워|켜|꺼|려|펴|쳐|져|겨|셔|혀|며|녀|벼|떠|써|러|라)$") # "뻗어 줘", "가져와 줘", "인사 해 줘": another verb's request
|
_KO_VERB_BEFORE = re.compile(r"(?:아|어|여|해|와|봐|워|켜|꺼|려|펴|쳐|져|겨|셔|혀|며|녀|벼|떠|써|러|라|춰|꿔|뤄)$|^가$") # "뻗어 줘", "가져와 줘", "인사 해 줘": another verb's request
|
||||||
_KO_NOT_VERB = {"이리", "여기", "거기", "저기", "좀", "나", "저", "날", "빨리", "어서", "얼른"}
|
_KO_NOT_VERB = {"이리", "여기", "거기", "저기", "좀", "나", "저", "날", "빨리", "어서", "얼른"}
|
||||||
|
|
||||||
|
|
||||||
PLACE_HELD_EN = re.compile( # while holding: put it down here / on a table, in any wording ("rest it on the table", "put to table")
|
PLACE_HELD_EN = re.compile( # while holding: put it down here / on a table, in any wording ("rest it on the table", "put to table")
|
||||||
rf"\b(?:put|pot|putt|set|place|leave|lay|rest|lower|drop|let)\s+(?!(?:your|my|his|her|our)\b)(?:(?:it|that|this|them|"
|
rf"\b(?:put|pot|putt|set|place|leave|lay|rest|lower|drop|let|pop|plop|stick)\s+(?!(?:your|my|his|her|our)\b)(?:(?:it|that|this|them|"
|
||||||
rf"the (?:\w+ ){{0,2}}?\w+|(?:(?:{_COL})\s+)?(?:{_OBJ})s?)\s+)?(?:(?:right|gently|carefully|slowly|softly)\s+)*"
|
rf"the (?:\w+ ){{0,2}}?\w+|(?:(?:{_COL})\s+)?(?:{_OBJ})s?)\s+)?(?:(?:right|gently|carefully|slowly|softly)\s+)*"
|
||||||
rf"(?:down|dawn|(?:on|onto|to)\s+(?:the |that |this |a )?(?:\w+ )?(?:{_SUP_EN})s?\b|on(?:to)? (?:the |that |this )?\w+ (?:{_SUP_EN})|here|there|여기|거기|(?:{_SUP_KO}))"
|
rf"(?:down|dawn|(?:on|onto|to)\s+(?:the |that |this |a )?(?:\w+ )?(?:{_SUP_EN})s?\b|on(?:to)? (?:the |that |this )?\w+ (?:{_SUP_EN})|here|there|여기|거기|(?:{_SUP_KO}))"
|
||||||
rf"|\b(?:setting|putting|placing|leaving|lowering)\s+(?:it|that|this|the \w+)\s+(?:down|on)\b"
|
rf"|\b(?:setting|putting|placing|leaving|lowering)\s+(?:it|that|this|the \w+)\s+(?:down|on)\b"
|
||||||
@@ -2110,11 +2230,25 @@ CONTEXT_CLAUSE = re.compile( # a visitor's aside around a hand request: no req
|
|||||||
r"(?:애들|아이들|손주|손녀|손자|우리 애|엄마|아빠)(?:이|가) (?:좋아해|좋아하|신기해|보고 있)\S*|기록할게요?|영상 찍고 있어요?|사진 찍을게요?|"
|
r"(?:애들|아이들|손주|손녀|손자|우리 애|엄마|아빠)(?:이|가) (?:좋아해|좋아하|신기해|보고 있)\S*|기록할게요?|영상 찍고 있어요?|사진 찍을게요?|"
|
||||||
r"다들 보게|손님들 보시게|처음 봐서 (?:그런데|신기해서요?)|잘 안 보여서요?|시연 중이라서요?|demo 중이라서요?|생일이라서 그런데|"
|
r"다들 보게|손님들 보시게|처음 봐서 (?:그런데|신기해서요?)|잘 안 보여서요?|시연 중이라서요?|demo 중이라서요?|생일이라서 그런데|"
|
||||||
r"테스트야|신기하다|이쁘네|감사합니다|고마워요?|(?:바쁘신데 )?죄송한데요?|실례지만|손주 왔다|(?:엄마|아빠|할머니|친구) 보여 주게|"
|
r"테스트야|신기하다|이쁘네|감사합니다|고마워요?|(?:바쁘신데 )?죄송한데요?|실례지만|손주 왔다|(?:엄마|아빠|할머니|친구) 보여 주게|"
|
||||||
r"(?:영상|사진|video|비디오) 찍게|부탁 좀 할게요|응\??|everyone'?s watching|i take (?:a )?photo|(?:okay,? )?next thing|thanks a lot|"
|
r"(?:영상|사진|video|비디오) 찍게|부탁 좀 할게요|응\??|(?:알았|알겠)(?:지|죠|어|어요|나|니)\??|everyone'?s watching|i take (?:a )?photo|(?:okay,? )?next thing|thanks a lot|"
|
||||||
r"애들이 보고 싶대|)\W*$", re.I)
|
r"애들이 보고 싶대|)\W*$", re.I)
|
||||||
CONTEXT_LEAD = re.compile(r"^\W*(?:(?:영상|사진|video|비디오|다들|모두|애들|손님들)\s*(?:을\s*)?(?:찍고|보고) 있으니까|"
|
CONTEXT_LEAD = re.compile(r"^\W*(?:(?:영상|사진|video|비디오|다들|모두|애들|손님들)\s*(?:을\s*)?(?:찍고|보고) 있으니까|"
|
||||||
r"(?:one more thing(?: before we leave)?|(?:okay,? )?next thing|test \w+|for the demo|attention lumi|command|"
|
r"(?:one more thing(?: before we leave)?|(?:okay,? )?next thing|test \w+|for the demo|attention lumi|command|"
|
||||||
r"teacher said i can ask you|prove you'?re smart|테스트 하나|온 김에|since you'?re here)\s*[:,]?)\s+", re.I)
|
r"teacher said i can ask you|prove you'?re smart|go ahead and|테스트 하나|온 김에|since you'?re here|(?:자\s*)?제자리에\s*[,!]|"
|
||||||
|
r"(?:so |okay |ok )?(?:going |getting |coming )?back to (?:your|the|my|our|that|this) [\w ]{1,25}?[,.]"
|
||||||
|
r"(?=\s*(?:so |and |um |uh )?(?:what|how|why|where|when|who|which|did|do|does|can|could|is|are|was|were)\b[^.!]*\?))"
|
||||||
|
r"\s*[:,]?)\s+", re.I) # "back to your arm, what did you say?": a topic, no order
|
||||||
|
|
||||||
|
|
||||||
|
POLITE_IF = re.compile( # a polite condition before a request: "괜찮으시면 손 흔들어 주세요", "if you don't mind, wave"
|
||||||
|
r"^\W*(?:(?:lumi|루미야?|루미 ?씨|로봇아?)\W+)?(?:혹시\s*)?(?:괜찮으시면|괜찮으면|괜찮다면|괜찮으시다면|실례가 안 된다면|실례가 안 되면|"
|
||||||
|
r"불편하지 않으시면|불편하지 않으면|가능하시면|가능하면|가능하다면|시간 (?:되시면|되면|괜찮으시면)|"
|
||||||
|
r"if you don'?t mind|if (?:it'?s|that'?s) (?:ok|okay|alright|all right)(?: with you)?|if you (?:can|could|would)|"
|
||||||
|
r"if possible|if you please)\s*[,:]?\s+", re.I)
|
||||||
|
MIND_ING = re.compile(r"^\W*(?:(?:lumi|robot)\W+)?(?:would|do|will|wouldn'?t) you mind\s+(?!if\b|not\b|me\b)([a-z]+?)(ing)\b", re.I)
|
||||||
|
_ING_BASE = {"shak": "shake", "wav": "wave", "com": "come", "mov": "move", "stopp": "stop", "giv": "give", "tak": "take",
|
||||||
|
"putt": "put", "rais": "raise", "driv": "drive", "gett": "get", "stepp": "step", "hand": "hand", "scoot": "scoot",
|
||||||
|
"lower": "lower", "clos": "close", "releas": "release", "plac": "place", "leav": "leave", "retriev": "retrieve"}
|
||||||
|
|
||||||
|
|
||||||
def strip_asides(text):
|
def strip_asides(text):
|
||||||
@@ -2127,6 +2261,9 @@ def strip_asides(text):
|
|||||||
kept = [x for x in parts if not CONTEXT_CLAUSE.match(x)]
|
kept = [x for x in parts if not CONTEXT_CLAUSE.match(x)]
|
||||||
t = " ".join(kept) if kept else t
|
t = " ".join(kept) if kept else t
|
||||||
t = CONTEXT_LEAD.sub("", t)
|
t = CONTEXT_LEAD.sub("", t)
|
||||||
|
t = POLITE_IF.sub("", t) or t
|
||||||
|
t = re.sub(r"주시면\s*안\s*(?=될|되)", "주면 안 ", t) # "가 주시면 안 될까요?" = "가 주면 안 될까요?"
|
||||||
|
t = MIND_ING.sub(lambda m: _ING_BASE.get(m.group(1).lower(), m.group(1)), t) # "would you mind shaking hands?"
|
||||||
t = HAND_FRAME.sub("", t) or t
|
t = HAND_FRAME.sub("", t) or t
|
||||||
return t.strip() or text or ""
|
return t.strip() or text or ""
|
||||||
|
|
||||||
@@ -2144,7 +2281,9 @@ def hand_text(text):
|
|||||||
t = CONTEXT_LEAD.sub("", t)
|
t = CONTEXT_LEAD.sub("", t)
|
||||||
t = re.sub(r"^\W*(?:(?:go on then|go on|come on|okay then|alright then|do it|ok robot|okay robot)\W+)+", "", t, flags=re.I)
|
t = re.sub(r"^\W*(?:(?:go on then|go on|come on|okay then|alright then|do it|ok robot|okay robot)\W+)+", "", t, flags=re.I)
|
||||||
t = re.sub(r"(?<![가-힣])(이리|그거|이거|저거|저한테|나한테|여기|나|저)(?=줘|주세요|주십시오|주이소|주라|주게|넘겨|건네)", r"\1 ", t)
|
t = re.sub(r"(?<![가-힣])(이리|그거|이거|저거|저한테|나한테|여기|나|저)(?=줘|주세요|주십시오|주이소|주라|주게|넘겨|건네)", r"\1 ", t)
|
||||||
return NA_SLIP.sub(r"\1 놔", t)
|
t = re.sub(r"(한테|에게|께)(?=줘|주[세십시이라게]|드려|드리|건네|넘겨)", r"\1 ", t) # "grandma한테주십시오"
|
||||||
|
t = re.sub(r"기브 ?미", "give me", re.sub(r"그랜마|그랜드마", "grandma", re.sub(r"주십시요", "주십시오", t))) # Konglish, a slip
|
||||||
|
return NA_SLIP.sub(r"\1 놔", re.sub(r"\blemme\b", "let me", t, flags=re.I)) # "lemme have it"
|
||||||
|
|
||||||
|
|
||||||
BODY_PART = re.compile(r"몸|키(?![가-힣])|키를|고개|머리|허리|상체|목을|리프트|\b(?:lift|height|body|head|waist|torso|yourself)\b", re.I)
|
BODY_PART = re.compile(r"몸|키(?![가-힣])|키를|고개|머리|허리|상체|목을|리프트|\b(?:lift|height|body|head|waist|torso|yourself)\b", re.I)
|
||||||
@@ -2192,12 +2331,19 @@ def give_clause(text):
|
|||||||
return cut if re.search(r"\b(?:give|hand|pass|bring|deliver)\b|줘|주세요|주시|드려|건네", cut) else text or ""
|
return cut if re.search(r"\b(?:give|hand|pass|bring|deliver)\b|줘|주세요|주시|드려|건네", cut) else text or ""
|
||||||
|
|
||||||
|
|
||||||
|
ACT_KO = r"인사|말씀|전화|연락|부탁|안내|설명|감사|사과|축하|문자|메일|답장|도움|소개|보고|양해|대답|답|이야기|얘기|약속|결과"
|
||||||
|
# nouns of an act, not a thing: "인사 드려", "전화 줘", "연락 줘" hand nothing over
|
||||||
|
|
||||||
|
|
||||||
def held_give(text, markers=()):
|
def held_give(text, markers=()):
|
||||||
"""With something in the hand: the words ask to hand it over, to the speaker or someone near ("give it to me",
|
"""With something in the hand: the words ask to hand it over, to the speaker or someone near ("give it to me",
|
||||||
"gib me please", "give it to the lady next to me", "그거 me 줘", "pass 해 줘 그거", "우리 손녀한테 주시오"). Not a
|
"gib me please", "give it to the lady next to me", "그거 me 줘", "pass 해 줘 그거", "우리 손녀한테 주시오"). Not a
|
||||||
condition, a cancel, a past, words to someone else, a trip to a marker ("bring it to James at booth A")."""
|
condition, a cancel, a past, words to someone else, a trip to a marker ("bring it to James at booth A")."""
|
||||||
if re.search(r"^\W*(?:(?:okay|ok|alright|네|그럼|자)\W+)*(?:제가|내가)\s*(?:받을|가져갈)(?:게|께)요?\W*$", CALLING.sub("", text or "")):
|
if re.search(r"^\W*(?:(?:okay|ok|alright|네|그럼|자)\W+)*(?:제가|내가)\s*(?:받을|가져갈)(?:게|께)요?\W*$", CALLING.sub("", text or "")):
|
||||||
return True # "제가 가져갈게요": I'll take it (from the hand)
|
return True # "제가 가져갈게요": I'll take it (from the hand)
|
||||||
|
if re.fullmatch(rf"\W*(?:(?:그거|이거|저거|그걸|이걸)\s+)?(?:우리\s+|저\s+|이\s+)?(?!(?:{ACT_KO})\s)[가-힣]+\s+(?:좀\s+)?(?:(?:그거|이거)\s+)?드려\W*", # not "인사 드려", "전화 드려"
|
||||||
|
CALLING.sub("", wording.ko_plain(text or "")).strip()):
|
||||||
|
return True # "할머니 드려라", "선생님 드리세요": 드리다 gives to the one named
|
||||||
if not text or re.search(r'["“”]', text) or to_someone_else(re.sub(r"^(\W*루미야)(?=\S)", r"\1 ", text)) or \
|
if not text or re.search(r'["“”]', text) or to_someone_else(re.sub(r"^(\W*루미야)(?=\S)", r"\1 ", text)) or \
|
||||||
NOT_A_THING.search(text):
|
NOT_A_THING.search(text):
|
||||||
return False # "야 그 컵 나 줘 봐": said to a friend; "give me the news"
|
return False # "야 그 컵 나 줘 봐": said to a friend; "give me the news"
|
||||||
@@ -2205,6 +2351,7 @@ def held_give(text, markers=()):
|
|||||||
if not text or not_an_order(text):
|
if not text or not_an_order(text):
|
||||||
return False
|
return False
|
||||||
t = CALLING.sub("", _norm(give_clause(NA_SLIP.sub(r"\1 놔", instead_of(text))), markers).strip())
|
t = CALLING.sub("", _norm(give_clause(NA_SLIP.sub(r"\1 놔", instead_of(text))), markers).strip())
|
||||||
|
t = wording.ko_plain(t) # "선생님께 드려라", "할머니께 드리시게", "이리 좀 조": every level as 반말
|
||||||
in_hand = re.search(r"\b(?:pop|drop|put|release|let go of|place)\b.*\b(?:in|into) my hands?\b", t) and \
|
in_hand = re.search(r"\b(?:pop|drop|put|release|let go of|place)\b.*\b(?:in|into) my hands?\b", t) and \
|
||||||
not re.search(r"\b(?:don'?t|do not|never)\b", t)
|
not re.search(r"\b(?:don'?t|do not|never)\b", t)
|
||||||
if not in_hand and GIVE_HELD_NOT.search(t) or HAND_Q.search(t) and not re.search(r"(?:줄|주실) 수 ?있|^\W*(?:can|may|could) i\b", t):
|
if not in_hand and GIVE_HELD_NOT.search(t) or HAND_Q.search(t) and not re.search(r"(?:줄|주실) 수 ?있|^\W*(?:can|may|could) i\b", t):
|
||||||
@@ -2218,6 +2365,11 @@ def held_give(text, markers=()):
|
|||||||
return True
|
return True
|
||||||
for m in GIVE_HELD_KO.finditer(t):
|
for m in GIVE_HELD_KO.finditer(t):
|
||||||
before = t[:m.start()].split()
|
before = t[:m.start()].split()
|
||||||
|
if m.group(1) == "돌려 " and re.search(r"쪽|왼|오른|좌|우|뒤로|고개|머리|몸|허리|\d", t[:m.start()]) or \
|
||||||
|
re.search(r"(?:^|\s)손(?:을)?(?:\s+(?:좀|쫌|한번|살짝))?\s*$", t[:m.start()]) or \
|
||||||
|
before and re.fullmatch(rf"(?:{ACT_KO})(?:을|를)?", before[-1]):
|
||||||
|
continue # "오른쪽으로 돌려 줘": a turn; "손 좀 줘": hold the arm out (reach);
|
||||||
|
# "전화 드려": an act
|
||||||
if m.group(1) or not before or before[-1] in _KO_NOT_VERB or not _KO_VERB_BEFORE.search(before[-1]):
|
if m.group(1) or not before or before[-1] in _KO_NOT_VERB or not _KO_VERB_BEFORE.search(before[-1]):
|
||||||
return True
|
return True
|
||||||
return False
|
return False
|
||||||
@@ -2232,11 +2384,14 @@ def hand_request(text, holding, b=None, markers=(), whole=True):
|
|||||||
if re.search(r'["“”]', text or "") or NOT_A_THING.search(text or ""):
|
if re.search(r'["“”]', text or "") or NOT_A_THING.search(text or ""):
|
||||||
return None # '"give it to me" is a nice English phrase', "give me the news"
|
return None # '"give it to me" is a nice English phrase', "give me the news"
|
||||||
text = hand_text(instead_of(text))
|
text = hand_text(instead_of(text))
|
||||||
t = CALLING.sub("", _norm(text, markers).strip()) # "루미야, 이리 줘", "혹시 저 줘요", "um, put it down"
|
t = CALLING.sub("", wording.ko_plain(_norm(text, markers)).strip()) # "루미야, 이리 줘", "혹시 저 줘요", "um, put it down"
|
||||||
if holding and re.search(r"\bi mean\b|\S\W*\bsorry\b", t):
|
if holding and re.search(r"\bi mean\b|\S\W*\bsorry\b", t):
|
||||||
return None # "place it— give it, I mean": a correction, the LLM reads it
|
return None # "place it— give it, I mean": a correction, the LLM reads it
|
||||||
if holding and OPEN_HAND.search(t) and not IN_MY_HAND.search(t) and not re.search(r"\b(?:don'?t|do not|never)\b|지 ?마", t):
|
if holding and OPEN_HAND.search(t) and not IN_MY_HAND.search(t) and not re.search(r"\b(?:don'?t|do not|never)\b|지 ?마", t):
|
||||||
return ("refuse", REFUSE_OPEN) # "손을 펴 주십시오", "그리퍼 열어 줘" with a cup: it would fall
|
return ("refuse", REFUSE_OPEN) # "손을 펴 주십시오", "그리퍼 열어 줘" with a cup: it would fall
|
||||||
|
if holding and FLOOR.search(t) and re.search(r"\b(?:put|place|set|drop|lay|leave|rest)\b|내려 ?놔|내려 ?놓|놔|놓|둬|두세|두십|두어", t) and \
|
||||||
|
not re.search(r"\b(?:don'?t|do not|never)\b|지 ?마|말고", t) and not held_back(text) and not not_an_order(text):
|
||||||
|
return ("refuse", REFUSE_FLOOR) # "바닥에 내려놔 주이소", "의자 밑에 놔": the arm can't reach down there
|
||||||
if holding and held_give(text, markers):
|
if holding and held_give(text, markers):
|
||||||
return ("give", None) # any request for the held thing, to the speaker or someone near
|
return ("give", None) # any request for the held thing, to the speaker or someone near
|
||||||
if holding and held_place(text, markers):
|
if holding and held_place(text, markers):
|
||||||
@@ -2288,7 +2443,8 @@ def hand_request(text, holding, b=None, markers=(), whole=True):
|
|||||||
if not holding and re.search(LET_GO, t):
|
if not holding and re.search(LET_GO, t):
|
||||||
return None # "놔", "drop it" with the hand empty: open it (intent)
|
return None # "놔", "drop it" with the hand empty: open it (intent)
|
||||||
if (PLACE_EN.search(t) or PLACE_KO.search(t)) and "팔" not in t and not re.fullmatch(r"\W*leave (?:it|that|this)\W*", t) and \
|
if (PLACE_EN.search(t) or PLACE_KO.search(t)) and "팔" not in t and not re.fullmatch(r"\W*leave (?:it|that|this)\W*", t) and \
|
||||||
not re.search(r"손\s*(?:을\s*)?(?:(?:좀|얼른|이제|다시|빨리|어서)\s*)*(?:내려|거둬)", t) and not BODY_PART.search(t):
|
not re.search(r"손\s*(?:을\s*)?(?:(?:좀|쫌|쪼까|쪼끔|조금|살짝|얼른|이제|다시|빨리|어서)\s*)*(?:내려|거둬)", t) and \
|
||||||
|
not BODY_PART.search(t) and not re.search(r"\barms?\b", t): # "손쫌내려줘유", "you put down arm please"
|
||||||
# not "팔 거둬" / "팔 내려" (the arm), not a bare "leave it" (never mind)
|
# not "팔 거둬" / "팔 내려" (the arm), not a bare "leave it" (never mind)
|
||||||
if named and not holding:
|
if named and not holding:
|
||||||
return None # "put the cup on the table": the put intent / a mission
|
return None # "put the cup on the table": the put intent / a mission
|
||||||
@@ -2336,12 +2492,22 @@ def correction(text, history):
|
|||||||
def parse_correction(text, task, markers=(), field=None):
|
def parse_correction(text, task, markers=(), field=None):
|
||||||
"""'no, from p2' / 'not the apple, the cup' / 'to p3' / 'put it on the table' / 'just hold it' -> (task, changed).
|
"""'no, from p2' / 'not the apple, the cup' / 'to p3' / 'put it on the table' / 'just hold it' -> (task, changed).
|
||||||
field: the field a bare answer is about ("source" / "dest"), when Lumi just asked for it ("p2" -> that field)."""
|
field: the field a bare answer is about ("source" / "dest"), when Lumi just asked for it ("p2" -> that field)."""
|
||||||
m, task = _mentions(text, markers), dict(task)
|
m, task, t = _mentions(text, markers), dict(task), _norm(text, markers)
|
||||||
if field in ("source", "dest") and not {"source", "dest"} & set(m):
|
if field in ("source", "dest") and not {"source", "dest"} & set(m):
|
||||||
p = re.search(_place_re(markers), _norm(text, markers))
|
p = re.search(_place_re(markers), t)
|
||||||
if p:
|
if p:
|
||||||
m[field] = _as_place(_resolve(p, markers))
|
m[field] = _as_place(_resolve(p, markers))
|
||||||
changed = [k for k, v in m.items() if task.get(k) != v and not (k == "colour" and "object" not in m)]
|
ps = [_as_place(_resolve(p, markers)) for p in re.finditer(_place_re(markers), t)]
|
||||||
|
if not {"source", "dest"} & set(m) and len(ps) == 2 and re.search(r"\bnot\b|말고|아니고|아니라", t):
|
||||||
|
k = next((k for k in ("source", "dest") if task.get(k) == ps[0]), None) # "not p1, p2": the one it was
|
||||||
|
if k:
|
||||||
|
m[k] = ps[1]
|
||||||
|
col = re.search(rf"(?<![a-z가-힣])({_COL})\s*(?:ones?\b|1\b|거|것|걸|색|으로|로)", t)
|
||||||
|
if col and "object" not in m and "colour" not in m:
|
||||||
|
m["colour"] = COLOURS[col.group(1)] # "no, the blue one", "아니 파란 거": the same thing in blue
|
||||||
|
if "prefer" not in m and (pr := pick_prefer(re.sub(r"\bthe 1\b", "the one", t))[0]):
|
||||||
|
m["prefer"] = pr # "the one on the left", "왼쪽 거", "the smaller one"
|
||||||
|
changed = [k for k, v in m.items() if task.get(k) != v and not (k == "colour" and "object" not in m and not col)]
|
||||||
for k in changed:
|
for k in changed:
|
||||||
task[k] = m[k]
|
task[k] = m[k]
|
||||||
return task, changed
|
return task, changed
|
||||||
@@ -2518,7 +2684,8 @@ FRAGMENT_WORDS = 4 # "Which one?", "얼마?", "Where is it used?": a
|
|||||||
# a fragment that names what it asks ("몇 살이라고요?") gets no hint
|
# a fragment that names what it asks ("몇 살이라고요?") gets no hint
|
||||||
OWN_TOPIC = re.compile(r"살|나이|이름|\bold\b|\bname\b|\bage\b|\btall\b|\bheavy\b|\bweigh", re.I)
|
OWN_TOPIC = re.compile(r"살|나이|이름|\bold\b|\bname\b|\bage\b|\btall\b|\bheavy\b|\bweigh", re.I)
|
||||||
SAME_ABOUT = re.compile(r"^\W*(?:and|so|what about|how about|and what about)\s+(your\s+[a-z]+(?:\s+[a-z]+)?)\W*$", re.I)
|
SAME_ABOUT = re.compile(r"^\W*(?:and|so|what about|how about|and what about)\s+(your\s+[a-z]+(?:\s+[a-z]+)?)\W*$", re.I)
|
||||||
KO_SAME_ABOUT = re.compile(r"^\W*(?:그럼\s*|그리고\s*)?(?:네\s*|너\s*|루미\s*)?(?!(?:너|루미|당신|저|나|그거|이거|그건|여기|거기)(?:은|는))([가-힣]{1,6}?)(?:은|는)요?\s*\?+\s*$")
|
KO_SAME_ABOUT = re.compile(r"^\W*(?:그럼\s*|그리고\s*)?(?:네\s*|너\s*|루미\s*)?(?!(?:너|루미|당신|저|나|그거|이거|그건|여기|거기)(?:은|는))([가-힣A-Za-z]{1,8}?)(?:은|는)\s*"
|
||||||
|
r"(?:요|어때요?|어때유|어떻습니까|어떤가요|어떠세요|어떻노)?\s*\?+\s*$")
|
||||||
# the question before asked again about a part of Lumi ("팔은요?")
|
# the question before asked again about a part of Lumi ("팔은요?")
|
||||||
FRAGMENT_CHARS = 160 # chars of the last answer's first sentence shown with a fragment
|
FRAGMENT_CHARS = 160 # chars of the last answer's first sentence shown with a fragment
|
||||||
_PLEASE = r"(?:\W+(?:please|lumi|then|now|해 ?줘|해 ?봐|해요|해 ?주세요|해|요|봐|줘))*\W*$"
|
_PLEASE = r"(?:\W+(?:please|lumi|then|now|해 ?줘|해 ?봐|해요|해 ?주세요|해|요|봐|줘))*\W*$"
|
||||||
@@ -2568,8 +2735,16 @@ BYE_WORDS = re.compile(r"\b(?:bye|goodbye|see you|gotta go|i (?:have|need) to go
|
|||||||
|
|
||||||
def topic_turn(history):
|
def topic_turn(history):
|
||||||
"""The last turn that said something of its own: a back-channel ("헐 대박", "Oh, I see.") and Lumi's short reply
|
"""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."""
|
to it are passed over, so "really?" / "where is it?" after them asks about the answer before. So are a motion
|
||||||
|
done ("ACTION: wave") and an order for later ("when we're done, go to the stage"): "are you sure?" after them
|
||||||
|
asks about the talk before them. So is a turn Lumi did not catch ("Sorry, could you say that again?"): "확실해?"
|
||||||
|
after it asks about the answer before it."""
|
||||||
for q, a in reversed(history[-4:]):
|
for q, a in reversed(history[-4:]):
|
||||||
|
act = re.match(r"\s*\**ACTION\**\s*:\s*(\w+)", a)
|
||||||
|
if act and (act.group(1) in MOTIONS or act.group(1) == "unclear") or ASKS_AGAIN.search(a) or \
|
||||||
|
CONDITION.search(q) and a.startswith("ACTION: none") and \
|
||||||
|
re.search(r"\b(?:go|come|follow|turn|move|wave)\b|[가와](?:\s*줘|요|라|주세요)?\W*$|따라", q, re.I):
|
||||||
|
continue
|
||||||
if about_answer(q) or not (is_backchannel(q) or UNDERSTOOD.search(q) and len(q.split()) <= 4):
|
if about_answer(q) or not (is_backchannel(q) or UNDERSTOOD.search(q) and len(q.split()) <= 4):
|
||||||
return q, a
|
return q, a
|
||||||
return history[-1]
|
return history[-1]
|
||||||
@@ -2620,9 +2795,9 @@ WEATHER_WORDS = re.compile(r"\b(?:how's|what's|looking|look|and|so|then|too|also
|
|||||||
r"어때유|우째|되노|됩니까|되나요|될까요|돼|어떤가요|어떻게|좀", re.I) # the rest of "and the weather on Friday then?"
|
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)|"
|
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"any|how)\b.{0,25}\b(?:rain\w*|snow\w*|windy|umbrella|jacket|coat)\b[\w\s]*\W*$|"
|
||||||
r"^\W*(?:그럼\s*)?(?:비|눈|소나기|미세먼지|황사|바람)(?:은|는|도|가|이)?\s*(?:와|와요|오나요?|올까요?|옵니까|오니|오노|와유|"
|
r"^\W*(?:그럼\s*)?(?:비|눈|소나기|미세먼지|황사|바람)(?:은|는|도|가|이)?\s*(?:안 ?)?(?:와|와요|오나요?|올까요?|옵니까|오니|오노|와유|"
|
||||||
r"어때요?|어떻습니까|많이 불어요?|불어요?|심해요?|나빠요?|있어요?)?[\s?.!~요]*$|"
|
r"어때요?|어떻습니까|많이 불어요?|불어요?|심해요?|나빠요?|있어요?)?[\s?.!~요]*$|"
|
||||||
r"^\W*우산\s*(?:챙겨야|가져가야|필요)", re.I) # a weather question that names no day or place;
|
r"^\W*우산\s*(?:챙겨야|가져가야|필요)|^\W*(?:and |so )?what(?:'s| is| will be) the (?:high|low)\b", re.I) # a weather question that names no day or place;
|
||||||
# "is it cold?" / "추워요?" is answered from the weather just said (the LLM)
|
# "is it cold?" / "추워요?" is answered from the weather just said (the LLM)
|
||||||
PARTICLES = re.compile(r"^[은는도요의에이가서엔]+$") # "월요일은요" less the day
|
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)
|
CHECKING = re.compile(r"^\W*(?:let me (?:check|see|look)|one moment|just a moment|확인해 ?볼게요|잠시만요?)\W*$", re.I)
|
||||||
@@ -2649,6 +2824,14 @@ LOOKUP_ACTION = re.compile(r"^\s*(?:\**ACTION\**\s*:\s*)?(?:search|weather)(?: (
|
|||||||
# written instead of the answer (the routing prompt is its system prompt): never said
|
# written instead of the answer (the routing prompt is its system prompt): never said
|
||||||
NONE_LINE = re.compile(r"\s*(?:\**ACTION\**\s*:\s*)?none\b", re.I) # "ACTION: none -" (or "none" alone)
|
NONE_LINE = re.compile(r"\s*(?:\**ACTION\**\s*:\s*)?none\b", re.I) # "ACTION: none -" (or "none" alone)
|
||||||
LOOKUP_PEEK = 8 # chars of the line after "ACTION: none" read before it is spoken: "search ..." is the action
|
LOOKUP_PEEK = 8 # chars of the line after "ACTION: none" read before it is spoken: "search ..." is the action
|
||||||
|
CHANGES = re.compile(r"지금|오늘|요즘|최근|최신|어제|내일|올해|작년|이번|현재|뉴스|가격|시세|환율|주가|점수|결과|날씨|대통령|"
|
||||||
|
r"대표|회장|장관|감독|우승|이겼|"
|
||||||
|
r"\b(?:now|today|tonight|latest|newest|current|currently|recent|yesterday|tomorrow|this (?:year|week|month)|"
|
||||||
|
r"news|price|cost|score|won|weather|president|ceo|minister|coach|champion)\b", re.I)
|
||||||
|
# words of a question whose answer changes: a model's "search" stands
|
||||||
|
LOOKS_UP = re.compile(r"찾아|검색|확인|알아보|살펴|모르|몰라|잠시|잠깐|정보가|\b(?:look|check|search|find|moment|sec|"
|
||||||
|
r"not sure|don't know|do not know)\b", re.I)
|
||||||
|
# a first sentence that promises a lookup or doesn't know: the search stands
|
||||||
SPOKEN_TARGET = re.compile(r"^\W*(?:i\b|i'll|i will|let me|sure|okay|ok\b|one moment|just a moment|잠시|잠깐|찾아|확인)", re.I)
|
SPOKEN_TARGET = re.compile(r"^\W*(?:i\b|i'll|i will|let me|sure|okay|ok\b|one moment|just a moment|잠시|잠깐|찾아|확인)", re.I)
|
||||||
# "search I'll look that up": words for the visitor, not the query
|
# "search I'll look that up": words for the visitor, not the query
|
||||||
LOOKUP_ANSWER = """Search results found just now on the internet (they may hold ads and unrelated parts):
|
LOOKUP_ANSWER = """Search results found just now on the internet (they may hold ads and unrelated parts):
|
||||||
@@ -2678,10 +2861,17 @@ def route_system(markers=(), now=None):
|
|||||||
(f"\nWhat you are doing now: {now}" if now else "")
|
(f"\nWhat you are doing now: {now}" if now else "")
|
||||||
|
|
||||||
|
|
||||||
|
SELF_THINGS = re.compile(r"(?i:speed|price|name|age|height|weight|charge|charging|voice|model|sensors?|battery|"
|
||||||
|
r"memory|software|hardware|maker|owner|job|songs?)$|(?:속도|가격|값|이름|나이|키|높이|무게|몸무게|충전|목소리|"
|
||||||
|
r"모델|센서|배터리|메모리|소프트웨어|하드웨어|주인|직업|정체|성능|기능|크기|힘|시력|청력|노래)$")
|
||||||
|
# the subject of a question that is Lumi's own ("속도는 얼마예요?"): its notes stay
|
||||||
_PRONOUN_KO = r"그거|이거|저거|그것|이것|저것|거기|여기|저기|그분|이분|저분|걔|얘|쟤|너|넌|니|네|당신|루미|저|나|우리|저희|어디|무엇|뭐|누구|언제|얼마|어느|어떤|그게|이게|저게"
|
_PRONOUN_KO = r"그거|이거|저거|그것|이것|저것|거기|여기|저기|그분|이분|저분|걔|얘|쟤|너|넌|니|네|당신|루미|저|나|우리|저희|어디|무엇|뭐|누구|언제|얼마|어느|어떤|그게|이게|저게"
|
||||||
OWN_SUBJECT = re.compile(rf"(?<=\S )(?!I\b|Lumi\b|OK\b|Okay\b)[A-Z][a-z]+|(?<![가-힣A-Za-z])(?!(?:{_PRONOUN_KO})(?:은|는|이|가)(?![가-힣]))"
|
OWN_SUBJECT = re.compile(rf"(?<=\S )(?!I\b|Lumi\b|OK\b|Okay\b)[A-Z][a-z]+|(?<![가-힣A-Za-z])(?!(?:{_PRONOUN_KO})(?:은|는|이|가)(?![가-힣]))"
|
||||||
r"[가-힣A-Za-z]{2,}(?:은|는|이|가)(?=[\s?!.~,]|요|$)")
|
r"[가-힣A-Za-z]{2,}(?:은|는|이|가)(?=[\s?!.~,]|요|$)")
|
||||||
# a short question that names its own subject ("BTS는 언제 데뷔했어요?", "Who was Sejong?")
|
# a short question that names its own subject ("BTS는 언제 데뷔했어요?", "Who was Sejong?")
|
||||||
|
EN_SUBJECT = re.compile(r"\b(?i:do|does|did|can|could|are|is|were|was|will|would)\s+(?:the\s+|an?\s+)?"
|
||||||
|
r"(?!(?:you|i|we|they|he|she|it|people|there|this|that|these|those|your|my|our|me|not|so|very)\b)"
|
||||||
|
r"([a-z]{3,})\b") # "Why do whales sing?": the whales (world_talk; lower case, so not OWN_SUBJECT)
|
||||||
|
|
||||||
|
|
||||||
class Brain:
|
class Brain:
|
||||||
@@ -2778,16 +2968,25 @@ class Brain:
|
|||||||
for q, a in self.window():
|
for q, a in self.window():
|
||||||
messages += [{"role": "user", "content": q}, {"role": "assistant", "content": a}]
|
messages += [{"role": "user", "content": q}, {"role": "assistant", "content": a}]
|
||||||
follow = _follow_examples(text, self.history) # with them, fewer plain examples (a shorter prompt)
|
follow = _follow_examples(text, self.history) # with them, fewer plain examples (a shorter prompt)
|
||||||
|
world = self.world_talk(text)
|
||||||
if follow and not LUMI_TOPIC.search("{} {}".format(core(topic_turn(self.history)[0]), topic_turn(self.history)[1])):
|
if follow and not LUMI_TOPIC.search("{} {}".format(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
|
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
|
# on Lumi ("When was I built? 2 years") only misled
|
||||||
|
elif follow and about_answer(text) and len(hits) > 1: # "really?" / "why?": the answer is in the talk, its
|
||||||
|
notes = _notes(hits[:1]) # reason in the best chunk (~200 tokens less, ~0.25 s)
|
||||||
|
elif world: # "부엉이는 고개를 몇 도까지 돌려요?": notes on Lumi's own head
|
||||||
|
notes = "(none needed: not about you)" # turned the owl into Lumi ("제 고개는 180도까지")
|
||||||
|
if len(world) > 1: # "심장은 몇 개고?" after the octopus: the octopus's hearts
|
||||||
|
world = [f"{world[0]} (its {', '.join(world[1:])}, when that is a part or a kind of it)"]
|
||||||
|
world = (f"(This is about {', '.join(world)}, not about you: never answer it with your own head, eyes, arms or "
|
||||||
|
f"body.)\n") if world else "" # "부엉이 목 그거 을매나 돌아가노?" got "제 머리는 180도까지" with no notes
|
||||||
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)}"
|
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"{follow}"
|
||||||
f"Now it is {now_line()}.\n\n" + memory.turn_lines(self, text) +
|
f"Now it is {now_line()}.\n\n" + memory.turn_lines(self, text) +
|
||||||
f"Visitor: {text}\n\n" + self._fragment_hint(text) +
|
f"Visitor: {text}\n\n" + self._fragment_hint(text) + world +
|
||||||
f"(Reply in {lang}.)"})
|
f"(Reply in {lang}.)"})
|
||||||
buf, full, header, said, muted = "", "", None, [], False
|
buf, full, header, said, muted = "", "", None, [], False
|
||||||
stream, retried = _stream(messages), False
|
stream, retried, skip_head, held = _stream(messages), False, False, None
|
||||||
try:
|
try:
|
||||||
for piece in iter(lambda: next(stream, None), None):
|
for piece in iter(lambda: next(stream, None), None):
|
||||||
full += piece
|
full += piece
|
||||||
@@ -2808,7 +3007,8 @@ class Brain:
|
|||||||
buf = rest
|
buf = rest
|
||||||
if NONE_LINE.match(first) and LOOKUP_ACTION.match(rest.lstrip()):
|
if NONE_LINE.match(first) and LOOKUP_ACTION.match(rest.lstrip()):
|
||||||
first = re.search(r"search|weather", rest).group(0) # read as the action, never said
|
first = re.search(r"search|weather", rest).group(0) # read as the action, never said
|
||||||
header = self._after(self._action(first, text, markers), text)
|
raw = self._action(first, text, markers)
|
||||||
|
header = self._after(raw, text)
|
||||||
if header is None: # the model skipped the ACTION line
|
if header is None: # the model skipped the ACTION line
|
||||||
header, buf = self._after({"action": "none", "target": ""}, text), first + " " + buf
|
header, buf = self._after({"action": "none", "target": ""}, text), first + " " + buf
|
||||||
if header["action"] == "unclear" and not retried and \
|
if header["action"] == "unclear" and not retried and \
|
||||||
@@ -2820,6 +3020,9 @@ class Brain:
|
|||||||
stream = _stream(messages)
|
stream = _stream(messages)
|
||||||
continue
|
continue
|
||||||
muted = bool(header.pop("held", None)) # a motion the words did not order: talk only
|
muted = bool(header.pop("held", None)) # a motion the words did not order: talk only
|
||||||
|
if raw and raw["action"] == header["action"] == "search" and not CHANGES.search(text):
|
||||||
|
held = header # "윤초는 뭐예요?" -> "search" with the answer after it:
|
||||||
|
else: # its first sentence decides (below)
|
||||||
yield header
|
yield header
|
||||||
if header.get("say"): # the model's words don't fit the action any more
|
if header.get("say"): # the model's words don't fit the action any more
|
||||||
said.append(header.pop("say"))
|
said.append(header.pop("say"))
|
||||||
@@ -2831,7 +3034,23 @@ class Brain:
|
|||||||
yield said[0]
|
yield said[0]
|
||||||
buf, full = "", f"{first}\n{said[0]}"
|
buf, full = "", f"{first}\n{said[0]}"
|
||||||
break
|
break
|
||||||
|
if held: # settled knowledge the model answered anyway: said, not
|
||||||
|
if len(SENTENCE_END.split(buf)) < 2: # looked up; "Let me check." keeps the search
|
||||||
|
continue
|
||||||
|
header, held = self._settled(held, buf, text), None
|
||||||
|
yield header
|
||||||
|
if skip_head: # the retry's own action line: the header stands
|
||||||
|
if "\n" not in buf:
|
||||||
|
continue
|
||||||
|
head, rest = buf.split("\n", 1)
|
||||||
|
buf, skip_head = (rest if re.match(r"\s*\**ACTION", head) else buf), False
|
||||||
parts = SENTENCE_END.split(buf)
|
parts = SENTENCE_END.split(buf)
|
||||||
|
if not said and not retried and len(parts) > 1 and self._asks_again(header, parts[0], text):
|
||||||
|
stream.close() # "Sorry, I didn't catch that." to clear words: once more
|
||||||
|
retried, skip_head, buf, full = True, True, "", ""
|
||||||
|
messages[-1]["content"] += UNCLEAR_RETRY
|
||||||
|
stream = _stream(messages)
|
||||||
|
continue
|
||||||
for sentence in parts[:-1]:
|
for sentence in parts[:-1]:
|
||||||
if muted != "said" and sentence.strip() and not (said and HELP_OFFER.search(sentence)):
|
if muted != "said" and sentence.strip() and not (said and HELP_OFFER.search(sentence)):
|
||||||
said.append(spoken(sentence.strip(), lang))
|
said.append(spoken(sentence.strip(), lang))
|
||||||
@@ -2848,12 +3067,25 @@ class Brain:
|
|||||||
yield {"action": "none", "target": ""}
|
yield {"action": "none", "target": ""}
|
||||||
header = {}
|
header = {}
|
||||||
buf += " Sorry, could you say that again?"
|
buf += " Sorry, could you say that again?"
|
||||||
|
if held: # the whole reply was one sentence
|
||||||
|
header, held = self._settled(held, buf, text), None
|
||||||
|
yield header
|
||||||
if header is None: # very short reply on a single line (or two)
|
if header is None: # very short reply on a single line (or two)
|
||||||
first, _, rest = buf.partition("\n")
|
first, _, rest = buf.partition("\n")
|
||||||
header = self._after(self._action(first, text, markers), text)
|
header = self._after(self._action(first, text, markers), text)
|
||||||
muted = bool(header and header.pop("held", None))
|
muted = bool(header and header.pop("held", None))
|
||||||
yield header or {"action": "none", "target": ""}
|
yield header or {"action": "none", "target": ""}
|
||||||
buf = rest if header else buf
|
buf = rest if header else buf
|
||||||
|
if skip_head and re.match(r"\s*\**ACTION", buf):
|
||||||
|
buf = buf.partition("\n")[2]
|
||||||
|
if not said and not retried and buf.strip() and self._asks_again(header, buf, text):
|
||||||
|
try: # a one-sentence "say it again?" to clear words
|
||||||
|
again = _chat(messages[:-1] + [dict(messages[-1], content=messages[-1]["content"] + UNCLEAR_RETRY)])
|
||||||
|
again = "\n".join(ln for ln in again.splitlines() if not re.match(r"\s*\**ACTION", ln)).strip()
|
||||||
|
if again and not ASKS_AGAIN.search(again):
|
||||||
|
buf = full = again
|
||||||
|
except Exception: # noqa: BLE001 - say the first reply then
|
||||||
|
pass
|
||||||
if buf.strip() and not (said and HELP_OFFER.search(buf)):
|
if buf.strip() and not (said and HELP_OFFER.search(buf)):
|
||||||
said.append(spoken(buf.strip(), lang))
|
said.append(spoken(buf.strip(), lang))
|
||||||
cut = muted and self._unpromise(said, lang)
|
cut = muted and self._unpromise(said, lang)
|
||||||
@@ -2870,6 +3102,24 @@ class Brain:
|
|||||||
full = "ACTION: none -\n" + " ".join(said)
|
full = "ACTION: none -\n" + " ".join(said)
|
||||||
self.history.append((text, full.strip()))
|
self.history.append((text, full.strip()))
|
||||||
|
|
||||||
|
@staticmethod
|
||||||
|
def _settled(search, words, text):
|
||||||
|
"""The model chose search for words with nothing that changes, then answered in its first sentence ("윤초는
|
||||||
|
지구 자전과 ... 맞추는 1초예요."): that answer is said, action none. A first sentence that promises a lookup or
|
||||||
|
doesn't know ("확인해 볼게요.", "Let me check.") keeps the search."""
|
||||||
|
first = SENTENCE_END.split(words.strip())[0].strip()
|
||||||
|
asked = set(re.findall(r"\w+", text.lower()))
|
||||||
|
echo = len(asked & set(re.findall(r"\w+", first.lower()))) >= 0.6 * len(asked)
|
||||||
|
return search if not first or LOOKS_UP.search(first) or LOOKUP_ACTION.match(first) or echo or \
|
||||||
|
first.endswith("?") or re.search(r"궁금|\bwonder|good question|좋은 질문", first, re.I) \
|
||||||
|
else {"action": "none", "target": ""} # the query written out, "궁금하시군요." then "잠시만요": a lookup
|
||||||
|
|
||||||
|
def _asks_again(self, header, sentence, text):
|
||||||
|
"""The model talks (action none) but asks to hear clear words again ("I'm not sure what you mean, could you
|
||||||
|
say it again?" to "Why the 15th?"): it is asked once more with UNCLEAR_RETRY."""
|
||||||
|
return bool(header) and header.get("action") == "none" and bool(ASKS_AGAIN.search(sentence)) and \
|
||||||
|
(has_meaning(text) or bool(self.history) and about_answer(text)) and not other_latin_language(text)
|
||||||
|
|
||||||
@staticmethod
|
@staticmethod
|
||||||
def _unpromise(said, lang):
|
def _unpromise(said, lang):
|
||||||
"""The last sentence promises a motion that was not ordered: it is replaced by a short "Okay." when it is the
|
"""The last sentence promises a motion that was not ordered: it is replaced by a short "Okay." when it is the
|
||||||
@@ -2882,6 +3132,21 @@ class Brain:
|
|||||||
said.pop()
|
said.pop()
|
||||||
return "dropped"
|
return "dropped"
|
||||||
|
|
||||||
|
def world_talk(self, text):
|
||||||
|
"""The words (or the question they follow) name a subject of their own that is not Lumi, its parts or the
|
||||||
|
companies ("부엉이는 ...?", "How high is Mount Fuji?"): Lumi's notes are left out. A subject that is one of
|
||||||
|
Lumi's own things ("속도는 얼마예요?", "이름이 뭐예요?") keeps them. Returns those subjects, the question before first ([] when none)."""
|
||||||
|
def named(t):
|
||||||
|
return [m.group(0) for m in OWN_SUBJECT.finditer(core(t))] + [m.group(1) for m in EN_SUBJECT.finditer(core(t))]
|
||||||
|
qs = [topic_turn(self.history)[0]] + [h[0] for h in reversed(self.history[-3:])] if self.history else [""]
|
||||||
|
q = next((x for x in qs if named(x)), qs[0]) # "문어 피는?" "왜?" "심장은?": the octopus, two turns back
|
||||||
|
both = re.sub(r"(?<=[A-Za-z])(?=[가-힣])", " ", f"{text} {q}") # "Gemma는": the word for LUMI_TOPIC
|
||||||
|
if LUMI_TOPIC.search(both) or COMPANY_TALK.search(both):
|
||||||
|
return []
|
||||||
|
subjects = [w for t in (q, text) if t for w in named(t)]
|
||||||
|
return list(dict.fromkeys(re.sub(r"[은는가]$", "", w) for w in subjects # "부엉이" keeps its 이
|
||||||
|
if not SELF_THINGS.match(w[:-1] if HANGUL.search(w) else w)))
|
||||||
|
|
||||||
def _fragment_hint(self, text):
|
def _fragment_hint(self, text):
|
||||||
"""For a bare fragment ("얼마?", "Which one?", "Where is it used?"): what it follows, so the model reads it
|
"""For a bare fragment ("얼마?", "Which one?", "Where is it used?"): what it follows, so the model reads it
|
||||||
as about the last answer's subject, not about itself or a price."""
|
as about the last answer's subject, not about itself or a price."""
|
||||||
@@ -2894,9 +3159,11 @@ class Brain:
|
|||||||
return f"(This follows your answer \"{last[:FRAGMENT_CHARS * 2]}\": if it said you can do something, do it now: its ACTION line is that action (wave, sing, look ...), not none.)\n"
|
return f"(This follows your answer \"{last[:FRAGMENT_CHARS * 2]}\": if it said you can do something, do it now: its ACTION line is that action (wave, sing, look ...), not none.)\n"
|
||||||
part = SAME_ABOUT.match(text) or KO_SAME_ABOUT.match(text)
|
part = SAME_ABOUT.match(text) or KO_SAME_ABOUT.match(text)
|
||||||
if last and part: # "What about your cameras?" / "카메라는요?" after "can I wipe you?"
|
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 "
|
return (f"(The visitor's question \"{self.history[-1][0]}\" goes on, now about {part.group(1)}: the same "
|
||||||
f"that question for it, not other facts about it.)\n")
|
f"question for {part.group(1)}, or {part.group(1)} of the thing just talked about (\"height는요?\" "
|
||||||
if last: # past a back-channel ("헐 대박") to the answer before it
|
f"after a tower: its height), whichever fits; not other facts.)\n")
|
||||||
|
if self.history: # past a back-channel ("헐 대박") to the answer before it,
|
||||||
|
# also past a motion done without words ("are u sure" after a lift)
|
||||||
last = " ".join(ln for ln in topic_turn(self.history)[1].splitlines() if not re.match(r"\s*\**ACTION", ln)).strip()
|
last = " ".join(ln for ln in topic_turn(self.history)[1].splitlines() if not re.match(r"\s*\**ACTION", ln)).strip()
|
||||||
c = core(text) # "루미 양반, 언제야?" asks "언제야?", not about Lumi
|
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 \
|
if last and (THANKS_ONLY.match(c) or THANKS_ONLY.match(re.split(r"[,:]\s*", c)[-1])) and \
|
||||||
@@ -2904,11 +3171,20 @@ class Brain:
|
|||||||
return "(Only thanks for your answer, not a goodbye: say you're welcome in a few words; no goodbye, no question.)\n"
|
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]):
|
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"
|
return "(A goodbye with one more question: answer the question; no goodbye in your words yet.)\n"
|
||||||
|
if re.search(r"\bthanks?\b|thank you|고마|고맙|감사|땡큐", text, re.I) and len(re.split(r"(?<=[,.!~])\s*", text.strip())) > 1 and \
|
||||||
|
(text.rstrip().endswith("?") or SHORT_Q.search(re.split(r"(?<=[,.!~])\s*", text.strip())[-1])):
|
||||||
|
return "(Thanks and then a new question: answer the question itself now, a few words of thanks back at most.)\n"
|
||||||
|
if self.history and SAID_BEFORE.search(text) and not re.search(r"\btold me to\b|\byou said you(?:'d| would| will| can)\b", text, re.I):
|
||||||
|
return ("(The visitor says your earlier answer was different: say again, in one or two sentences, the facts you "
|
||||||
|
"gave earlier in this talk about the thing they name (its numbers, names, reasons), and keep them; never "
|
||||||
|
"ask which part, never change them.)\n")
|
||||||
if last and about_answer(text): # "why?", "how do you know?", "진짜?" after a refusal too
|
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; "
|
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"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")
|
f"things it listed, never just \"that\" / \"those\"), no new fact.)\n")
|
||||||
pronoun = NAMED_BEFORE.search(c) or REFERS_BACK.search(c) # "when was it built?", "how old are they?"
|
pronoun = NAMED_BEFORE.search(c) or REFERS_BACK.search(c) or \
|
||||||
|
re.match(r"\W*(?:(?:and|so|but|why|how about|what about)\W+)?the\s+\w+\W*$", c, re.I)
|
||||||
|
# "when was it built?", "how old are they?", "Why the name?"
|
||||||
if not last or len(c.split()) > (FOLLOW_UP_WORDS + 2 if pronoun else FRAGMENT_WORDS) or not SHORT_Q.search(c) \
|
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:
|
or is_backchannel(c) or ABOUT_YOU.search(c) or (OWN_TOPIC.search(c) or OWN_SUBJECT.search(c)) and not pronoun:
|
||||||
return ""
|
return ""
|
||||||
@@ -2918,7 +3194,8 @@ class Brain:
|
|||||||
"""The action line checked against the turn before: a song only when one is asked for (or asked again),
|
"""The action line checked against the turn before: a song only when one is asked for (or asked again),
|
||||||
"and down?" right after a look looks down, a follow-up question ("how old is he?", "거기 입장료는?") right
|
"and down?" right after a look looks down, a follow-up question ("how old is he?", "거기 입장료는?") right
|
||||||
after a lookup is looked up too."""
|
after a lookup is looked up too."""
|
||||||
if header and header["action"] == "sing" and (sing.NOT_ASKED.search(text) or sing.list_asked(text)):
|
if header and header["action"] == "sing" and (sing.NOT_ASKED.search(text) or sing.list_asked(text) or
|
||||||
|
SAID_BEFORE.search(text) or re.search(r"노래\s*(?:얘기|이야기)", text)):
|
||||||
return {"action": "none", "target": ""} # "Don't sing.", "어제 노래방 갔어요.", "what songs can you sing?"
|
return {"action": "none", "target": ""} # "Don't sing.", "어제 노래방 갔어요.", "what songs can you sing?"
|
||||||
if header and GO_AGAIN.match(text): # "다시 가." right after "move forward 1": that move again;
|
if header and GO_AGAIN.match(text): # "다시 가." right after "move forward 1": that move again;
|
||||||
done = self._redo("again") if self.history else None # with no trip before it is no come back
|
done = self._redo("again") if self.history else None # with no trip before it is no come back
|
||||||
@@ -3251,6 +3528,10 @@ class Brain:
|
|||||||
action, target = rule
|
action, target = rule
|
||||||
if action == "stop" and "?" in text:
|
if action == "stop" and "?" in text:
|
||||||
action = "none" # "how do I stop you?": a question about stopping
|
action = "none" # "how do I stop you?": a question about stopping
|
||||||
|
tail = re.split(r"근데|그런데|아 맞다|\bbut\b|\bby the way\b|\bone more (?:thing|question)\b", text, flags=re.I)
|
||||||
|
if action == "end" and len(tail) > 1 and re.search(r"\w{2}", tail[-1]) and not BYE_WORDS.search(tail[-1]) and \
|
||||||
|
not re.search(r"가 ?봐야|이만|leav|head (?:out|off)|\bgo now\b|\bget going\b", tail[-1], re.I):
|
||||||
|
action = model if model in ("search", "weather") else "none" # "갈게요 아 근데 라이다 있어": asked more
|
||||||
if action == "end" and "?" in re.split(r"(?<=[.!?~])\s+", text.strip())[-1]:
|
if action == "end" and "?" in re.split(r"(?<=[.!?~])\s+", text.strip())[-1]:
|
||||||
action = model if model in ("search", "weather") else "none" # "갈게요, 근데 후지산은 얼마나 높아?": its
|
action = model if model in ("search", "weather") else "none" # "갈게요, 근데 후지산은 얼마나 높아?": its
|
||||||
target = target if action != "none" else "" # lookup stays (else "search 후지산 높이" was said aloud)
|
target = target if action != "none" else "" # lookup stays (else "search 후지산 높이" was said aloud)
|
||||||
|
|||||||
+39
-1
@@ -29,13 +29,15 @@ FETCHING = re.compile(r"\b(?:bring|fetch|deliver|carry)\b|가져|갖다", re.I)
|
|||||||
_FILL = re.compile(rf"(?:{steps._FILL}|루미야?|lumi|hey|do me a favou?r|부탁(?:해|해요|할게)?|dear|sir|ma'?am|madam|buddy|"
|
_FILL = re.compile(rf"(?:{steps._FILL}|루미야?|lumi|hey|do me a favou?r|부탁(?:해|해요|할게)?|dear|sir|ma'?am|madam|buddy|"
|
||||||
r"my friend|robot|로봇아?|선생님?|yo|bro|dude|okay lumi|ok lumi|robot please|루미 ?씨|로봇 양반|여보세요|"
|
r"my friend|robot|로봇아?|선생님?|yo|bro|dude|okay lumi|ok lumi|robot please|루미 ?씨|로봇 양반|여보세요|"
|
||||||
r"go ahead|okay\?|ok\?|right\?|thanks|thank you|yes|yeah|yep|yes\?|네|응|그래|will ya|will you|won'?t you|"
|
r"go ahead|okay\?|ok\?|right\?|thanks|thank you|yes|yeah|yep|yes\?|네|응|그래|will ya|will you|won'?t you|"
|
||||||
r"can\?|can|do it|do it now|just do it|alright\?|please\?|혹시|아 뭐라 그래야 되지|뭐라 그래야 되지|뭐더라|"
|
r"can\?|can|do it|do it now|just do it|alright\?|please\?|over here\??|this way\??|어디 ?한번|어디 ?보자|얼마나 걸리나|(?:pls |please )?(?:eh|huh|da|see|ya|yah|innit)\??|혹시|아 뭐라 그래야 되지|뭐라 그래야 되지|뭐더라|"
|
||||||
r"(?:아\s*)?영어로 ?뭐더라|(?:아\s*)?뭐라고 ?하지|"
|
r"(?:아\s*)?영어로 ?뭐더라|(?:아\s*)?뭐라고 ?하지|"
|
||||||
r"(?:거기서?\s*)?(?:서|가만히)\s*있(?:어|게|으세요|으십시오)\s*(?:줄래|줄 ?수 ?있어요?|주실래요|주세요|줘|줘잉|주라|"
|
r"(?:거기서?\s*)?(?:서|가만히)\s*있(?:어|게|으세요|으십시오)\s*(?:줄래|줄 ?수 ?있어요?|주실래요|주세요|줘|줘잉|주라|"
|
||||||
r"주면 ?안 ?될까요?|주면 ?좋겠어요?|주실 ?수 ?있어요?|주십시오|주이소)?|"
|
r"주면 ?안 ?될까요?|주면 ?좋겠어요?|주실 ?수 ?있어요?|주십시오|주이소)?|"
|
||||||
r"(?:거기서?\s*)?기다려\s*(?:줄래|주세요|줘)?)", re.I) # tags, hesitations, "...가서 서 있어 줄래?"
|
r"(?:거기서?\s*)?기다려\s*(?:줄래|주세요|줘)?)", re.I) # tags, hesitations, "...가서 서 있어 줄래?"
|
||||||
RELATIVE = re.compile(r"^\W*(?:where|which|who|that|when)\s+(?:the|my|your|his|her|our|their|a|an|this|that|these|those|"
|
RELATIVE = re.compile(r"^\W*(?:where|which|who|that|when)\s+(?:the|my|your|his|her|our|their|a|an|this|that|these|those|"
|
||||||
r"people|everyone|it|he|she|they|we|i)\b", re.I) # "look right, where the door is": no question
|
r"people|everyone|it|he|she|they|we|i)\b", re.I) # "look right, where the door is": no question
|
||||||
|
SPEED_Q = re.compile(r"속도|몇으로|얼마나 (?:빨리|빠르게|천천히)|\bhow (?:fast|quick(?:ly)?|slow(?:ly)?)\b|\bwhat speed\b", re.I)
|
||||||
|
GREET = re.compile(r"인사|작별|\b(?:hello|hi|goodbye|bye)\b", re.I) # a greeting made by waving
|
||||||
PAST = re.compile(r"\byou (?:got|went|were|did|turned|looked|moved|came|said|told)\b|\b(?:earlier|before|yesterday)\b", re.I)
|
PAST = re.compile(r"\byou (?:got|went|were|did|turned|looked|moved|came|said|told)\b|\b(?:earlier|before|yesterday)\b", re.I)
|
||||||
BANK_KINDS = {"look", "lift", "turn", "move", "come", "come_back", "follow", "wave", "arm", "go_to"} # a part the
|
BANK_KINDS = {"look", "lift", "turn", "move", "come", "come_back", "follow", "wave", "arm", "go_to"} # a part the
|
||||||
# keyword rules miss, read by the intent bank (same slot rules)
|
# keyword rules miss, read by the intent bank (same slot rules)
|
||||||
@@ -43,6 +45,22 @@ CHAIN_ONLY = {"look", "lift", "wave", "come", "come_back", "follow"} # a part
|
|||||||
# a sentence the mission reader reads whole is still a chain
|
# a sentence the mission reader reads whole is still a chain
|
||||||
|
|
||||||
|
|
||||||
|
BACKGROUND = re.compile(r"[가-힣](?:는|은|인|던)(?:데|디)(?:요)?\W*$") # "…말하는데," a clause that only sets the scene
|
||||||
|
SELF_PROMISE = re.compile(r"(?:^|\W)(?:i'?ll|i will|let me|i'?m going to|i can) (?:hold|take|keep|get|catch|grab) (?:it|that|this|them)\W*$|"
|
||||||
|
r"(?:^|\W)(?:내가|제가) (?:들|받|잡)(?:게|을게|을게요|게요|을께)\W*$", re.I) # the speaker's part
|
||||||
|
|
||||||
|
|
||||||
|
def _restated(words, before):
|
||||||
|
"""A Korean part that says the order before it again in another level ("손 거둬!", "아 거두시겠어요?")."""
|
||||||
|
from assistant import wording
|
||||||
|
said = [w for w in re.findall(r"\w+", wording.ko_plain(words)) if not re.fullmatch(r"(?:줘|봐|주|좀|요)[가-힣]?|허허|하하|호호|헤헤|아|어", w)]
|
||||||
|
if not said or len(said) > 3 or not re.fullmatch(r"[가-힣]{2,}|[가와]", said[-1]):
|
||||||
|
return False
|
||||||
|
last = said[-1]
|
||||||
|
return any(last == w or len(w) > 1 and (w.startswith(last) or last.startswith(w))
|
||||||
|
for w in re.findall(r"\w+", wording.ko_plain(before)) if re.fullmatch(r"[가-힣]+", w))
|
||||||
|
|
||||||
|
|
||||||
def _rule(words, markers):
|
def _rule(words, markers):
|
||||||
"""brain.intent of a part, also of a Korean -고 form ("나 보고" read as "나 봐")."""
|
"""brain.intent of a part, also of a Korean -고 form ("나 보고" read as "나 봐")."""
|
||||||
rule = brain.intent(words, markers)
|
rule = brain.intent(words, markers)
|
||||||
@@ -57,6 +75,8 @@ def _rule(words, markers):
|
|||||||
from assistant import intent_bank # "glance to your right", "고개 숙이고": the bank, by meaning
|
from assistant import intent_bank # "glance to your right", "고개 숙이고": the bank, by meaning
|
||||||
got = intent_bank.read(ko, markers)
|
got = intent_bank.read(ko, markers)
|
||||||
rule = got if got and got[0] in BANK_KINDS else None
|
rule = got if got and got[0] in BANK_KINDS else None
|
||||||
|
if rule and rule[0] == "come_back" and re.fullmatch(r"\W*(?:루미야?\s*)?(?:원래 ?자리|제자리)(?:에|로)?\W*", words):
|
||||||
|
rule = None # "제자리에, 손 내밀어": "ready", no drive back
|
||||||
return rule
|
return rule
|
||||||
|
|
||||||
|
|
||||||
@@ -69,6 +89,9 @@ def parts(text):
|
|||||||
for p in _SPLIT.split(cut):
|
for p in _SPLIT.split(cut):
|
||||||
out += [q for q in steps._SPLIT_KO.split(p) if q.strip()]
|
out += [q for q in steps._SPLIT_KO.split(p) if q.strip()]
|
||||||
out = [re.sub(r"§(\d+)§", lambda m: f'"{says[int(m.group(1))]}"', p).strip(" ,.!") for p in out]
|
out = [re.sub(r"§(\d+)§", lambda m: f'"{says[int(m.group(1))]}"', p).strip(" ,.!") for p in out]
|
||||||
|
for i in range(len(out) - 1, 0, -1): # "뒤로 물러서 줘": 서 is the verb's, 줘 no part of its own
|
||||||
|
if re.fullmatch(r"(?:줘|줘요|주세요|주십시오|줄래요?\??|주실래요?\??|주라|주게|주이소|봐|봐요|보세요)\W*", out[i]):
|
||||||
|
out[i - 1] += " " + out.pop(i)
|
||||||
return [p for p in out if p and not re.fullmatch(rf"(?:{_FILL.pattern}|\W)+", p, re.I)]
|
return [p for p in out if p and not re.fullmatch(rf"(?:{_FILL.pattern}|\W)+", p, re.I)]
|
||||||
|
|
||||||
|
|
||||||
@@ -90,6 +113,8 @@ def plan(text, markers=(), cant=None):
|
|||||||
return None # "turn around and look": the head looks behind
|
return None # "turn around and look": the head looks behind
|
||||||
out = []
|
out = []
|
||||||
for p in ps:
|
for p in ps:
|
||||||
|
if SELF_PROMISE.search(p) or out and _restated(p, out[-1][1]) or brain.GREET_ONLY.match(p): # "hello robot, …"
|
||||||
|
continue # "흰색 머그컵 잡아!, 아 잡아 줄 수 있어요?": the order once
|
||||||
got, unread = steps.rules(p, markers)
|
got, unread = steps.rules(p, markers)
|
||||||
rule = _rule(p, markers)
|
rule = _rule(p, markers)
|
||||||
if got and not unread and not (rule and rule[0] in ("look", "lift", "wave", "come", "come_back", "follow")):
|
if got and not unread and not (rule and rule[0] in ("look", "lift", "wave", "come", "come_back", "follow")):
|
||||||
@@ -100,6 +125,13 @@ def plan(text, markers=(), cant=None):
|
|||||||
out.append(["quick", p, rule])
|
out.append(["quick", p, rule])
|
||||||
elif RELATIVE.search(p):
|
elif RELATIVE.search(p):
|
||||||
return None # a part that tells more about the one before
|
return None # a part that tells more about the one before
|
||||||
|
elif BACKGROUND.search(p):
|
||||||
|
continue # "이장이 말하는디, 팔 제자리로 해", "I'll hold it, give it here"
|
||||||
|
elif out and out[-1][0] in ("quick", "steps") and _restated(p, out[-1][1]):
|
||||||
|
continue # "손 거둬!, 아 거두시겠어요?": the same order again, politely
|
||||||
|
elif out and out[-1][0] == "quick" and out[-1][2][0] == "wave" and re.search(r"(?:면서|며|서)\W*$", out[-1][1]) and \
|
||||||
|
GREET.search(p) and not rule:
|
||||||
|
continue # "손 흔들면서 인사하고 고개 숙여": the wave is the greeting
|
||||||
elif ASK.search(p) or rule and rule[0] in ("weather", "search") or cant is not None and cant.match(p):
|
elif ASK.search(p) or rule and rule[0] in ("weather", "search") or cant is not None and cant.match(p):
|
||||||
out.append(["talk", p, None])
|
out.append(["talk", p, None])
|
||||||
else:
|
else:
|
||||||
@@ -112,6 +144,12 @@ def plan(text, markers=(), cant=None):
|
|||||||
said[i] and said[i] == said[i - 1]))]
|
said[i] and said[i] == said[i - 1]))]
|
||||||
if len(out) < 2:
|
if len(out) < 2:
|
||||||
return None # "wave, wave, wave!": one wave, said with feeling
|
return None # "wave, wave, wave!": one wave, said with feeling
|
||||||
|
if any(k == "talk" and SPEED_Q.search(p) and i and re.search(r"고$|\b(?:holding|carrying|with)\b", out[i - 1][1], re.I)
|
||||||
|
for i, (k, p, _) in enumerate(out)):
|
||||||
|
return None # "컵 들고 몇으로 가?": how fast it goes so, no order
|
||||||
|
if any(k == "quick" and w[0] == "wave" and re.search(r"(?<!가)서$", p) and i + 1 < len(out) and
|
||||||
|
GREET.search(out[i + 1][1]) for i, (k, p, w) in enumerate(out)):
|
||||||
|
return None # "손 흔들어서 작별 인사 해 줘": the wave is the greeting
|
||||||
kinds = [k for k, _, _ in out]
|
kinds = [k for k, _, _ in out]
|
||||||
if "talk" not in kinds and "quick" not in kinds or "steps" not in kinds and "quick" not in kinds:
|
if "talk" not in kinds and "quick" not in kinds or "steps" not in kinds and "quick" not in kinds:
|
||||||
return None # all steps: a mission (read back); all talk: the LLM
|
return None # all steps: a mission (read back); all talk: the LLM
|
||||||
|
|||||||
@@ -113,6 +113,10 @@ def read(text, markers=(), goal=None):
|
|||||||
ends = [m.end() for r in (_BACK_UP_RE, _AROUND, _BACK, _RETRY) for m in r.finditer(t)]
|
ends = [m.end() for r in (_BACK_UP_RE, _AROUND, _BACK, _RETRY) for m in r.finditer(t)]
|
||||||
if not ends or _NOT_ORDER.search(t):
|
if not ends or _NOT_ORDER.search(t):
|
||||||
return None
|
return None
|
||||||
|
if brain.to_someone_else(text) or brain.held_back(re.sub(r"(?:포기하|멈추|그만두)지 ?마\w*|\bdon.?t (?:give up|stop)\b", " ", text)) or brain.ARM_TALK.search(text) or \
|
||||||
|
re.search(r"(?:라고|자고|하라고|가라고) ?(?:했|하더|그러)|(?:나|니|까|냐|어)\s+(?![루누]미|로봇)[가-힣]{2}(?:아|야)\s*\?\s*$|봤(?:냐|니|어요?|나요)\s*\?|(?<![가-힣])아까(?![가-힣])|\b(?:also|too)\W*$", text):
|
||||||
|
return None # "아까 저 아저씨가 다시 가라고 했어", "재시도해부러" said after "-믄", "Maria, you go back",
|
||||||
|
# "다른 길 있나 민수야?" (asked to Minsu), "여러분, 돌아와 보세요"
|
||||||
if _TAKEN_BACK.search(t, max(ends)) or _FIXED.search(t, max(ends)):
|
if _TAKEN_BACK.search(t, max(ends)) or _FIXED.search(t, max(ends)):
|
||||||
return None # "try again. never mind", "go around— no, not need"
|
return None # "try again. never mind", "go around— no, not need"
|
||||||
fixed = list(_FIXED.finditer(t))
|
fixed = list(_FIXED.finditer(t))
|
||||||
|
|||||||
+10
-6
@@ -24,13 +24,13 @@ SPAN_M = 0.2 # m; "한 뼘", one hand span; estimate
|
|||||||
STEP_M = 0.5 # m; one step ("two steps", "한 걸음", "반 걸음"); estimate of a person's step
|
STEP_M = 0.5 # m; one step ("two steps", "한 걸음", "반 걸음"); estimate of a person's step
|
||||||
TURN_MORE_DEG = 15.0 # deg; "a bit more" right after a turn: this much further the same way
|
TURN_MORE_DEG = 15.0 # deg; "a bit more" right after a turn: this much further the same way
|
||||||
|
|
||||||
DIRS = (("back", r"\bback(?:wards?)?\b(?! down\b)|\bbackward\b|\breverse\b|^(?:let'?s )?(?:bake|big)\b(?= \d| half| a )|뒤로|뒤쪽|후진|"
|
DIRS = (("back", r"\bback(?:wards?)?\b(?! down\b)|\bbackward\b|\breverse\b|\bretreat\b|^(?:let'?s )?(?:bake|big)\b(?= \d| half| a )|뒤로|뒤쪽|후진|"
|
||||||
r"물러"), # whisper's "let's bake / big one meter"
|
r"물러"), # whisper's "let's bake / big one meter"
|
||||||
("forward", r"\bforwards?\b|\bahead\b|앞으로|앞쪽|전진"),
|
("forward", r"\bforwards?\b|\bahead\b|앞으로|앞쪽|전진"),
|
||||||
("left", r"\b(?:to the |to your )?left\b|왼쪽|왼편|웬쪽|좌측"),
|
("left", r"\b(?:to the |to your )?left\b|왼 ?쪽|왼편|웬쪽|좌측"),
|
||||||
("right", r"(?<!all )\b(?:to the |to your )?right\b(?! now| away| here| there| back)|오른쪽|오른편|우측"))
|
("right", r"(?<!all )\b(?:to the |to your )?right\b(?! now| away| here| there| back)|오른 ?쪽|오른편|우측"))
|
||||||
VERB = re.compile(r"\b(?:move|go|come|drive|step|scoot|scooch|shift|inch|roll|back (?:up|off)|reverse|get)\b|"
|
VERB = re.compile(r"\b(?:move|go|come|drive|step|scoot|scooch|shift|inch|roll|back (?:up|off)|reverse|get)\b|"
|
||||||
r"가|와|이동|움직|물러|빠져|후진|전진|비켜")
|
r"(?<![신인는])가|와|이동|움직|물러|빠져|후진|전진|비켜") # not "…있으신가요?"
|
||||||
NEAR_THING = re.compile(r"(?:테이블|책상|탁자|의자|소파|문|벽|창문)\s*(?:앞|옆|뒤)|"
|
NEAR_THING = re.compile(r"(?:테이블|책상|탁자|의자|소파|문|벽|창문)\s*(?:앞|옆|뒤)|"
|
||||||
r"(?<![가-힣])(?!(?:루미야?|조금만?|살짝|다시|그냥|이제|저기요?|여기|거기|약간|천천히|빨리|얼른|어서|그럼|근데|"
|
r"(?<![가-힣])(?!(?:루미야?|조금만?|살짝|다시|그냥|이제|저기요?|여기|거기|약간|천천히|빨리|얼른|어서|그럼|근데|"
|
||||||
r"그리고|좀|더|한|두|세|반|쭉|바로|똑바로|계속|한번|한 번|일단|먼저|자|아주|많이|쪼끔|쬐끔|요만큼|뼘|걸음|발짝|발자국|미터|센티|센치|밀리)만?(?:\s|$))(?:[가-힣][가-힣_]{0,9}|(?<![a-z0-9_.])(?!(?:m|cm|mm|lumi|loomi|rumi|hey|ok|okay|please)\b)[a-z][a-z0-9_]*)\s*"
|
r"그리고|좀|더|한|두|세|반|쭉|바로|똑바로|계속|한번|한 번|일단|먼저|자|아주|많이|쪼끔|쬐끔|요만큼|뼘|걸음|발짝|발자국|미터|센티|센치|밀리)만?(?:\s|$))(?:[가-힣][가-힣_]{0,9}|(?<![a-z0-9_.])(?!(?:m|cm|mm|lumi|loomi|rumi|hey|ok|okay|please)\b)[a-z][a-z0-9_]*)\s*"
|
||||||
@@ -52,12 +52,13 @@ SPANS = re.compile(rf"(?:(?<![\w.]){_COUNT}\s*)?뼘")
|
|||||||
TINY = re.compile(r"\b(?:tiny|teeny|wee|hair|hairs?breadth|smidge|smidgen|tad|touch|nudge|slightly|little tiny)\b|"
|
TINY = re.compile(r"\b(?:tiny|teeny|wee|hair|hairs?breadth|smidge|smidgen|tad|touch|nudge|slightly|little tiny)\b|"
|
||||||
r"\bfew (?:centimet(?:er|re)s|cm)\b|\binch (?:forward|back|left|right|ahead)|"
|
r"\bfew (?:centimet(?:er|re)s|cm)\b|\binch (?:forward|back|left|right|ahead)|"
|
||||||
r"살짝|아주 조금|쪼끔|쬐끔|약간|요만큼|조금만 살짝")
|
r"살짝|아주 조금|쪼끔|쬐끔|약간|요만큼|조금만 살짝")
|
||||||
LITTLE = re.compile(r"\b(?:a little|a bit|little bit|bit)\b|조금|쪼금") # "좀" is "please" as often as "a bit"
|
LITTLE = re.compile(r"\b(?:a little|a bit|little bit|bit)\b|조금|쪼금|쪼매|쫌만") # "좀" is "please" as often as "a bit"
|
||||||
VAGUE = re.compile(r"\b(?:more|less|longer|further|farther|bit more|bit less) than\b|(?:^|\s)몇\s*(?:미터|센티|m\b|걸음)|\bsome (?:meters?|metres?)\b|\bto (?:m|meters?|metres?)\b|"
|
VAGUE = re.compile(r"\b(?:more|less|longer|further|farther|bit more|bit less) than\b|(?:^|\s)몇\s*(?:미터|센티|m\b|걸음)|\bsome (?:meters?|metres?)\b|\bto (?:m|meters?|metres?)\b|"
|
||||||
r"\b(?:some|like|uh|um)\s*$|(?<![가-힣])[이삼사오육칠팔구]?[십백][일이삼사오육칠팔구]?\s*(?:만\s*)?"
|
r"\b(?:some|like|uh|um)\s*$|(?<![가-힣])[이삼사오육칠팔구]?[십백][일이삼사오육칠팔구]?\s*(?:만\s*)?"
|
||||||
r"(?:가|와|이동|움직|후진|전진)") # an amount half said: asked, never a guess
|
r"(?:가|와|이동|움직|후진|전진)") # an amount half said: asked, never a guess
|
||||||
NUM_WORD = re.compile(r"\b(?:eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|"
|
NUM_WORD = re.compile(r"\b(?:eleven|twelve|thirteen|fourteen|fifteen|sixteen|seventeen|eighteen|nineteen|twenty|"
|
||||||
r"thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|dozen|couple|several|few|half)\b")
|
r"thirty|forty|fifty|sixty|seventy|eighty|ninety|hundred|thousand|dozen|couple|several|few|half)\b")
|
||||||
|
UNIT_WORD = re.compile(r"미터|센티|센치|밀리|(?<![a-z])(?:cm|mm|meters?|metres?|centimet(?:er|re)s?|millimet(?:er|re)s?)(?![a-z])")
|
||||||
KO_NUM_WORD = re.compile(r"(?<![가-힣])(?:하나|둘|셋|넷|다섯|여섯|일곱|여덟|아홉|열|스물|서른|마흔|쉰)(?:만|쯤|정도)?(?![가-힣])")
|
KO_NUM_WORD = re.compile(r"(?<![가-힣])(?:하나|둘|셋|넷|다섯|여섯|일곱|여덟|아홉|열|스물|서른|마흔|쉰)(?:만|쯤|정도)?(?![가-힣])")
|
||||||
# "앞으로 다섯만 가": a count with no unit, asked
|
# "앞으로 다섯만 가": a count with no unit, asked
|
||||||
KO_COUNT = re.compile(KO_NUM_WORD.pattern + r"|(?<![가-힣])[이삼사오육칠팔구]?[십백][일이삼사오육칠팔구]?(?:만|쯤|정도)?(?![가-힣])|"
|
KO_COUNT = re.compile(KO_NUM_WORD.pattern + r"|(?<![가-힣])[이삼사오육칠팔구]?[십백][일이삼사오육칠팔구]?(?:만|쯤|정도)?(?![가-힣])|"
|
||||||
@@ -122,6 +123,9 @@ def amount(t):
|
|||||||
return 0.25, True # "a quarter of a meter"
|
return 0.25, True # "a quarter of a meter"
|
||||||
if VAGUE.search(t):
|
if VAGUE.search(t):
|
||||||
return "?", False # "more than a meter", "to meters" (two?), "move back some"
|
return "?", False # "more than a meter", "to meters" (two?), "move back some"
|
||||||
|
m = re.search(r"(?<![\w.])(\d+) ?m ?([1-9]0)(?:만|쯤|정도)?(?![\d.]|\s*(?:m|cm|mm|센|밀|도|times|번)(?![a-z]))", t)
|
||||||
|
if m:
|
||||||
|
return int(m.group(1)) + int(m.group(2)) / 100, True # "1미터 50": 1.5 m
|
||||||
m = re.search(r"(?<![\w.])(\d+(?:\.\d+)?) m(?![a-z])", t)
|
m = re.search(r"(?<![\w.])(\d+(?:\.\d+)?) m(?![a-z])", t)
|
||||||
if m:
|
if m:
|
||||||
return float(m.group(1)), True
|
return float(m.group(1)), True
|
||||||
@@ -135,7 +139,7 @@ def amount(t):
|
|||||||
if m and not re.search(r"\b(?:few|couple|several|some)\b", t):
|
if m and not re.search(r"\b(?:few|couple|several|some)\b", t):
|
||||||
n = m.group(1)
|
n = m.group(1)
|
||||||
return (float(n) if n and n[0].isdigit() else _NATIVE.get(n, 1)) * unit, False
|
return (float(n) if n and n[0].isdigit() else _NATIVE.get(n, 1)) * unit, False
|
||||||
if re.search(r"(?<![a-z\d.])\d", t) or NUM_WORD.search(t) or KO_NUM_WORD.search(t):
|
if re.search(r"(?<![a-z\d.])\d", t) or NUM_WORD.search(t) or KO_NUM_WORD.search(t) or UNIT_WORD.search(t):
|
||||||
return "?", False # "move back 20", "two feet", "a couple of metres",
|
return "?", False # "move back 20", "two feet", "a couple of metres",
|
||||||
# "오른쪽으로30가게"
|
# "오른쪽으로30가게"
|
||||||
if LITTLE.search(t):
|
if LITTLE.search(t):
|
||||||
|
|||||||
+60
-13
@@ -34,18 +34,18 @@ FILLS = 3 # place / object fills made of each template (the same e
|
|||||||
# ---------- guards: words the bank never reads ----------
|
# ---------- guards: words the bank never reads ----------
|
||||||
NEGATION = re.compile(r"\b(?:don'?t|do not|never|no need|not now|no more|stop \w+ing|quit \w+ing|without|forget it|"
|
NEGATION = re.compile(r"\b(?:don'?t|do not|never|no need|not now|no more|stop \w+ing|quit \w+ing|without|forget it|"
|
||||||
r"never ?mind|scratch that|cancel that)\b|취소|아니다|됐다|"
|
r"never ?mind|scratch that|cancel that)\b|취소|아니다|됐다|"
|
||||||
r"[가-힣]지 ?마(?:세요|요|라|십시오)?(?![가-힣])|하지 ?말|말고|[가-힣]지 ?(?:말아|말라|마시|마셔|말게)|필요 ?없|안 ?(?:해|돼|가|와)(?:도)?\b|그만", re.I)
|
r"[가-힣]지 ?마(?:세요|요|라|십시오|쇼|소|이소|시오|셔)?(?:잉|요)?(?![가-힣])|하지 ?말|말고|[가-힣]지 ?(?:말아|말라|마시|마셔|말게)|필요 ?없|안 ?(?:해|돼|가|와)(?:도)?\b|그만", re.I)
|
||||||
LATER = re.compile(r"\b(?:when|whenever|if|unless|after|before|once|until|till|as soon as|later|tomorrow|tonight|"
|
LATER = re.compile(r"\b(?:when|whenever|if|unless|after|before|once|until|till|as soon as|later|tomorrow|tonight|"
|
||||||
r"next time|in (?:\w+ ){0,2}(?:minute|hour|second|min|sec)s?|in a (?:while|bit)|soon)\b|분 ?(?:뒤|후|있다)|"
|
r"next time|some ?day|one day|in (?:\w+ ){0,2}(?:minute|hour|second|min|sec)s?|in a (?:while|bit)|soon)\b|분 ?(?:뒤|후|있다)|"
|
||||||
r"[가-힣](?<![정화측반전표라장내외평단그러])면(?:\s|$)|(?:하|으|오|가|되|끝나|있으|오시)면|나중에|이따|내일|"
|
r"[가-힣](?<![정화측반전표라장내외평단그러])면(?:\s|$)|(?:하|으|오|가|되|끝나|있으|오시)면|나중에|이따|내일|"
|
||||||
r"다음에|있다가|(?:^|\s)(?:후|뒤|전)에(?![서가-힣])|때(?:에)?\s|다음 ?(?:주|달|번|시간)에?|"
|
r"다음에|있다가|(?:^|\s)(?:후|뒤|전)에(?![서가-힣])|때(?:에)?\s|다음 ?(?:주|달|번|시간)에?|"
|
||||||
r"(?:^|\s)(?:\d{1,2}|한|두|세|네|다섯|여섯|일곱|여덟|아홉|열|열한|열두) ?시(?:에|쯤|까지)|"
|
r"(?:^|\s)(?:\d{1,2}|한|두|세|네|다섯|여섯|일곱|여덟|아홉|열|열한|열두) ?시(?:에|쯤|까지)|"
|
||||||
r"\b(?:next (?:week|month|year|monday|tuesday|wednesday|thursday|friday|saturday|sunday)|"
|
r"\b(?:next (?:week|month|year|monday|tuesday|wednesday|thursday|friday|saturday|sunday)|"
|
||||||
r"at (?:\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)(?::\d\d)? ?(?:o'?clock|pm|am|p\.m\.|a\.m\.))", re.I)
|
r"at (?:\d{1,2}|one|two|three|four|five|six|seven|eight|nine|ten|eleven|twelve)(?::\d\d)? ?(?:o'?clock|pm|am|p\.m\.|a\.m\.))", re.I)
|
||||||
ABILITY = re.compile(r"\b(?:are you able|able to|know how to|how (?:do|can|could|would) you|is it possible|can you even|"
|
ABILITY = re.compile(r"\b(?:are you able|able to|know how|i heard you can|heard (?:that )?you can|how (?:do|can|could|would) you|is it possible|can you even|"
|
||||||
r"capable of|do you (?:know|have)|can robots?|could robots?)\b|"
|
r"capable of|do you (?:know|have)|can robots?|could robots?)\b|"
|
||||||
r"\bcan you (?:\w+ )?(?:things|anything|objects|stuff|people|by yourself)\b|\b(?:can|could) you \w+(?: up)? (?:a|an|any)\b.*\?|"
|
r"\bcan you (?:\w+ )?(?:things|anything|objects|stuff|people|by yourself)\b|\b(?:can|could) you \w+(?: up)? (?:a|an|any)\b.*\?|"
|
||||||
r"\bshow me (?:you can|how)\b|기능|\bfunction\b|\bfeature\b|보여 ?(?:줄|주실|주세요|줘)|할 ?줄|줄 ?알|(?<!줄 )(?<!주실 )(?<!주 )(?<!줄)(?<!주실)수 ?있(?:어|어요|니|나요|습니까|을까)\s*\??$|가능해|가능한가|가능하", re.I)
|
r"\bshow me (?:you can|how)\b|기능|\bfunction\b|\bfeature\b|줄 ?(?:은|도)? ?(?:알|아|압|안)|보여 ?(?:줄|주실|주세요|줘)|할 ?줄|줄 ?알|(?<!줄 )(?<!주실 )(?<!주 )(?<!줄)(?<!주실)수 ?있(?:어|어요|니|나요|습니까|을까)\s*\??$|가능해|가능한가|가능하", re.I)
|
||||||
WONDER = re.compile(r"\bi wonder\b|\bwonder(?:ing)? (?:if|whether|how)\b|\bi bet\b|\b(?:i )?guess (?:it|the robot)\b|"
|
WONDER = re.compile(r"\bi wonder\b|\bwonder(?:ing)? (?:if|whether|how)\b|\bi bet\b|\b(?:i )?guess (?:it|the robot)\b|"
|
||||||
r"\b(?:can|could|does|did|will|would|is|was) (?:it|this|that|the robot|this robot|that robot|he|she|this thing)\b|"
|
r"\b(?:can|could|does|did|will|would|is|was) (?:it|this|that|the robot|this robot|that robot|he|she|this thing)\b|"
|
||||||
r"\b(?:it|the robot|this robot|this thing) (?:can|could|does|will|is able)\b|\bcan it\b|"
|
r"\b(?:it|the robot|this robot|this thing) (?:can|could|does|will|is able)\b|\bcan it\b|"
|
||||||
@@ -56,7 +56,7 @@ WONDER = re.compile(r"\bi wonder\b|\bwonder(?:ing)? (?:if|whether|how)\b|\bi bet
|
|||||||
# "can it wave? I wonder", "does it follow people?", "이거 손 흔들 수 있나?", "얘 따라오나 봐"
|
# "can it wave? I wonder", "does it follow people?", "이거 손 흔들 수 있나?", "얘 따라오나 봐"
|
||||||
NOT_TO_LUMI = re.compile(
|
NOT_TO_LUMI = re.compile(
|
||||||
r"\bshall we\b|\bwe(?:'re| are) (?:heading|going|off|gonna)\b|\bwe (?:should|could|can|will|might|must|need to)\b|\bwe'll\b|"
|
r"\bshall we\b|\bwe(?:'re| are) (?:heading|going|off|gonna)\b|\bwe (?:should|could|can|will|might|must|need to)\b|\bwe'll\b|"
|
||||||
r"\byou and (?:i|me)\b|\bmy plan\b|\bour plan\b|우리(?!.*악수).*(?:자|까|래|기로)\s*[??.!~]*$|" # plans between people
|
r"\byou and (?:i|me)\b|\bmy plan\b|\bour plan\b|우리끼리|우리(?!.*악수).*(?:자|까|래|기로)\s*[??.!~]*$|" # plans between people
|
||||||
r"\bimagine\b|\bsuppose\b|\bwhat if\b|\bwould you ever\b|\bif you were\b|\bpretend\b|\bhypothetical|"
|
r"\bimagine\b|\bsuppose\b|\bwhat if\b|\bwould you ever\b|\bif you were\b|\bpretend\b|\bhypothetical|"
|
||||||
r"만약|[가-힣](?:라면|다면)|어떨까|겠다\s*[!.~]*$|" # hypotheticals
|
r"만약|[가-힣](?:라면|다면)|어떨까|겠다\s*[!.~]*$|" # hypotheticals
|
||||||
r"\battention\b|\bladies and gentlemen\b|\b(?:visitors|guests|attendees|passengers)(?: are)? (?:please|should|must|may|"
|
r"\battention\b|\bladies and gentlemen\b|\b(?:visitors|guests|attendees|passengers)(?: are)? (?:please|should|must|may|"
|
||||||
@@ -70,6 +70,8 @@ QUESTION = re.compile(r"^\W*(?:(?:hey|so|um+|uh+|lumi|okay|ok)\W+)*(?:what|where
|
|||||||
r"어디|뭐|무엇|왜|언제|누구|어떻게|몇|어느|무슨|어떤|얼마|[가-힣]까\s*[??]+\s*$|봤(?:어|니|나|냐|어요|습니까)|본 ?적|"
|
r"어디|뭐|무엇|왜|언제|누구|어떻게|몇|어느|무슨|어떤|얼마|[가-힣]까\s*[??]+\s*$|봤(?:어|니|나|냐|어요|습니까)|본 ?적|"
|
||||||
r"\bhave you (?:been|gone|ever)\b|(?:어|아|해|여)도 ?(?:돼|되|될까|괜찮)|"
|
r"\bhave you (?:been|gone|ever)\b|(?:어|아|해|여)도 ?(?:돼|되|될까|괜찮)|"
|
||||||
r"알려 ?(?:줘|주|줄)|설명해|가르쳐|말해 ?(?:줘|봐|주)|\btell me\b|\bexplain\b|\bdescribe\b|"
|
r"알려 ?(?:줘|주|줄)|설명해|가르쳐|말해 ?(?:줘|봐|주)|\btell me\b|\bexplain\b|\bdescribe\b|"
|
||||||
|
r"상태(?:야|예요|에요|니|냐|입니까|인가요)?\s*\??\s*$|(?:open|오픈|열림|닫힘)(?:이야|이에요|이니|인가요|입니까)|"
|
||||||
|
r"\b(?:is|are) (?:your|the) (?:hand|gripper|fingers?|arm|head)s? (?:open|closed|up|down|out)\b|"
|
||||||
r"정확도|얼마나|을매나|속도|(?:열려|닫혀|켜져|꺼져|접혀|펴져) ?있(?:어|어요|니|나요|습니까)?\s*[??]", re.I)
|
r"정확도|얼마나|을매나|속도|(?:열려|닫혀|켜져|꺼져|접혀|펴져) ?있(?:어|어요|니|나요|습니까)?\s*[??]", re.I)
|
||||||
# "그리퍼 열려 있어요?": a state asked, no motion # "팔 정확도 알려 줘": a question, no motion
|
# "그리퍼 열려 있어요?": a state asked, no motion # "팔 정확도 알려 줘": a question, no motion
|
||||||
OTHER_SENSE = re.compile(r"instagram|insta\b|\bsns\b|\baccount\b|\bsubscribe\b|인스타|계정|채널|구독|팔로우 ?해 ?주세요|"
|
OTHER_SENSE = re.compile(r"instagram|insta\b|\bsns\b|\baccount\b|\bsubscribe\b|인스타|계정|채널|구독|팔로우 ?해 ?주세요|"
|
||||||
@@ -81,7 +83,8 @@ REPEAT = re.compile(r"^\W*(?:(?:\w+\W+){0,2})?(?:again|one more time|once more|d
|
|||||||
# "again", "한 번만 더 해 줘": what again is the history's (driving.read, the LLM)
|
# "again", "한 번만 더 해 줘": what again is the history's (driving.read, the LLM)
|
||||||
SEVERAL = re.compile(r"\b(?<!hundred )and\b(?! a half\b)|\bwait\w*|\bcorrection\b|\binstead\b|"
|
SEVERAL = re.compile(r"\b(?<!hundred )and\b(?! a half\b)|\bwait\w*|\bcorrection\b|\binstead\b|"
|
||||||
r"\b(?:look|turn|go|move|wave|come|follow|pick|take|put|lift|raise|lower|reach|grab|bring)\b[^,]*,\s*(?:(?:\w+\W+){0,2})?(?:look|turn|go|move|wave|come|follow|pick|take|put|lift|raise|lower|reach|grab|bring|tell|say|sing|show|ask|answer|check)\b|\b(?:then|after that|also|plus|while|no|not|wait|stay|sleep|sorry|i mean|actually|rather)\b|;|"
|
r"\b(?:look|turn|go|move|wave|come|follow|pick|take|put|lift|raise|lower|reach|grab|bring)\b[^,]*,\s*(?:(?:\w+\W+){0,2})?(?:look|turn|go|move|wave|come|follow|pick|take|put|lift|raise|lower|reach|grab|bring|tell|say|sing|show|ask|answer|check)\b|\b(?:then|after that|also|plus|while|no|not|wait|stay|sleep|sorry|i mean|actually|rather)\b|;|"
|
||||||
r"(?!갖고|고고|에서)(?<!가)[가-힣](?:서|고)(?:[\s,.…]|$)|하고|셔서|면서|다가(?![와오])|갔다|다녀|아니|기다|대기|(?:가|와) ?있어|계세요|"
|
r"(?!갖고|고고|에서)(?<!가)[가-힣](?:서|고)(?:[\s,.…]|$)|(?:으로|로|에) ?가서|"
|
||||||
|
r"(?:흔들|흔드시|보시|돌|내리|올리|집어|내밀|숙이|들|봐 ?주시)고(?=[가-힣])|(?:쪽|나|날|위|아래|앞)보고(?=[가-힣])|(?:집어|와|가져와)서(?=[가-힣])|하고|셔서|면서|다가(?![와오])|갔다|다녀|아니|기다|대기|(?:가|와) ?있어|계세요|"
|
||||||
r"계십시오", re.I)
|
r"계십시오", re.I)
|
||||||
# several requests or a stay ("go to p3 and wait", "가서 기다려", "p3에 가 있어"): steps.read's
|
# several requests or a stay ("go to p3 and wait", "가서 기다려", "p3에 가 있어"): steps.read's
|
||||||
HAND_WORDS = re.compile(r"\byou(?:'re| are) holding\b|\b(?:in|from) my hand\b|\bhere'?s\b|\bhanding\b|\bi'?ll give\b|"
|
HAND_WORDS = re.compile(r"\byou(?:'re| are) holding\b|\b(?:in|from) my hand\b|\bhere'?s\b|\bhanding\b|\bi'?ll give\b|"
|
||||||
@@ -713,7 +716,7 @@ def _load():
|
|||||||
POLITE = re.compile(r"\bif you don'?t mind\b|\b(?:it'?d|it would|that would|that'?d) be (?:great|nice|good|lovely|awesome|"
|
POLITE = re.compile(r"\bif you don'?t mind\b|\b(?:it'?d|it would|that would|that'?d) be (?:great|nice|good|lovely|awesome|"
|
||||||
r"cool|helpful) if you(?: could)?\b|^\W*go ahead and\b|\bfor a (?:sec|second|moment|bit)\b|\bif you please\b", re.I)
|
r"cool|helpful) if you(?: could)?\b|^\W*go ahead and\b|\bfor a (?:sec|second|moment|bit)\b|\bif you please\b", re.I)
|
||||||
SLANG = [(re.compile(rf"(?<![\w가-힣]){a}(?![\w가-힣])", re.I), b) for a, b in (
|
SLANG = [(re.compile(rf"(?<![\w가-힣]){a}(?![\w가-힣])", re.I), b) for a, b in (
|
||||||
("wav", "wave"), ("reech", "reach"), ("ur", "your"), ("u", "you"), ("lemme", "let me"), ("luk", "look"),
|
("wav", "wave"), ("reech", "reach"), ("ur", "your"), ("u(?!-?turn)", "you"), ("lemme", "let me"), ("luk", "look"),
|
||||||
("pickup", "pick up"), ("plz|pls", "please"), ("mister robot|hey robot|yo robot|bro|buddy|lol|beep boop", ""),
|
("pickup", "pick up"), ("plz|pls", "please"), ("mister robot|hey robot|yo robot|bro|buddy|lol|beep boop", ""),
|
||||||
("^\\W*robot", ""), (",?\\s*robot(?=\\s*[,.!?]|\\s*$)", ""),
|
("^\\W*robot", ""), (",?\\s*robot(?=\\s*[,.!?]|\\s*$)", ""),
|
||||||
("보이소|보시오|보시게|보십시오", "봐"), ("주이소|주시게", "주세요"), ("따라온나|따라오시게|따라오이소", "따라와"),
|
("보이소|보시오|보시게|보십시오", "봐"), ("주이소|주시게", "주세요"), ("따라온나|따라오시게|따라오이소", "따라와"),
|
||||||
@@ -788,6 +791,7 @@ def core(text, markers=()):
|
|||||||
"감사합니다") cut, and the one marker named written as CANON_PLACE ("go to the coffee corner" -> "go to p3")."""
|
"감사합니다") cut, and the one marker named written as CANON_PLACE ("go to the coffee corner" -> "go to p3")."""
|
||||||
from assistant import brain
|
from assistant import brain
|
||||||
t = TAIL.sub("", brain.CALLING.sub("", plain(text))).strip(" ,.!?~") or text
|
t = TAIL.sub("", brain.CALLING.sub("", plain(text))).strip(" ,.!?~") or text
|
||||||
|
t = re.sub(r"(?<![가-힣])좀\s+(?=[가-힣])", "", t) # "뒤로 좀 돌아 줘": a softener, not a word to compare
|
||||||
named = [m for m in markers if brain.named_place(t, m, markers)]
|
named = [m for m in markers if brain.named_place(t, m, markers)]
|
||||||
if len(named) == 1:
|
if len(named) == 1:
|
||||||
low = brain._norm(t, markers)
|
low = brain._norm(t, markers)
|
||||||
@@ -852,8 +856,9 @@ DIR = {"forward": r"\b(?:forward|forwards|forword|ahead|straight)\b|\bto the fro
|
|||||||
|
|
||||||
CARRY = (r"\b(?:bring(?! yourself)|fetch|deliver|carry)\b|\bget me\b|\b(?:to|for) me\b(?=.*\b(?:bring|get|fetch|hand|pass)\b)|"
|
CARRY = (r"\b(?:bring(?! yourself)|fetch|deliver|carry)\b|\bget me\b|\b(?:to|for) me\b(?=.*\b(?:bring|get|fetch|hand|pass)\b)|"
|
||||||
r"\bget(?:ting)?\b.*\bfrom\b|\bgo get\b|가져|갖다|가지고 ?와|가져다|챙겨 ?(?:와|다)|갖고 ?와") # words that bring a thing to someone
|
r"\bget(?:ting)?\b.*\bfrom\b|\bgo get\b|가져|갖다|가지고 ?와|가져다|챙겨 ?(?:와|다)|갖고 ?와") # words that bring a thing to someone
|
||||||
COME_VERB = (r"\bcome\b|\bcum\b|\bkum\b|\bget over\b|\bapproach|\bcloser\b|\bhither\b|\bnear me\b|"
|
COME_SAID = (r"\bcome\b|\bcum\b|\bkum\b|\bget over\b|\bapproach|\bcloser\b|\bhither\b|\bnear me\b|"
|
||||||
r"\bget closer\b|\broll over\b|\bdrive over\b|\bmy side\b|\bnext to me\b|\bto me\b|와|오세요|오십시오|오시|올래")
|
r"\bget closer\b|\broll over\b|\bdrive over\b|\bmy side\b|\bnext to me\b|\bto me\b|와|오세요|오십시오|오시|올래|"
|
||||||
|
r"(?<![가-힣])컴(?= ?히어|(?![가-힣]))") # Konglish "컴 히어 해 줘", "이리 컴"
|
||||||
LIFT_SAID_MAX_M = 0.3 # m; a longer lift amount said is no lift request ("grow to three meters tall")
|
LIFT_SAID_MAX_M = 0.3 # m; a longer lift amount said is no lift request ("grow to three meters tall")
|
||||||
LIFT_BODY = (r"\b(?:yourself|your (?:body|torso|upper body)|body|make you|taller|shorter|smaller|small|tall|high|lift|rise|grow|"
|
LIFT_BODY = (r"\b(?:yourself|your (?:body|torso|upper body)|body|make you|taller|shorter|smaller|small|tall|high|lift|rise|grow|"
|
||||||
r"shrink|come down|go up|go down|move up|move down|raise up|lower down|come up|sink down|elevate|squat|height|"
|
r"shrink|come down|go up|go down|move up|move down|raise up|lower down|come up|sink down|elevate|squat|height|"
|
||||||
@@ -868,7 +873,7 @@ MOVE_VERB = (r"\b(?:move|go|step|back up|backup|scoot|slide|shift|drive|roll|rev
|
|||||||
LOOK_DIR = {"left": r"\bleft|왼|레프트|(?:^|\s)좌로|좌측", "right": r"\bright|\brite\b|오른|라이트|(?:^|\s)우로|우측",
|
LOOK_DIR = {"left": r"\bleft|왼|레프트|(?:^|\s)좌로|좌측", "right": r"\bright|\brite\b|오른|라이트|(?:^|\s)우로|우측",
|
||||||
"up": r"\bup|\bupward|\bceiling|\bsky\b|\bhigher\b|천장|하늘|(?<!원)위", "down": r"\bdown|\bfloor|\bground|\bfeet\b|바닥|땅|아래|밑"}
|
"up": r"\bup|\bupward|\bceiling|\bsky\b|\bhigher\b|천장|하늘|(?<!원)위", "down": r"\bdown|\bfloor|\bground|\bfeet\b|바닥|땅|아래|밑"}
|
||||||
LOOK_ME = (r"\b(?:at|on|to|toward|towards) (?:me|us|나)\b|\bthis way\b|\bover here\b|\bmy way\b|\bhere\b|\bwatch me\b|"
|
LOOK_ME = (r"\b(?:at|on|to|toward|towards) (?:me|us|나)\b|\bthis way\b|\bover here\b|\bmy way\b|\bhere\b|\bwatch me\b|"
|
||||||
r"\bme in the eye|\bmy face\b|나한테|저한테|쳐다봐|(?:^|\s)(?:여기|이쪽|저|나|날)(?:를|을)?\s*(?:좀\s*)?(?:봐|보세요|look)")
|
r"\bme in the eye|\bmy face\b|나한테|저한테|쳐다봐|(?:^|\s)(?:여기|이쪽|저|나|날|절)(?:를|을)?\s*(?:(?:좀|한 ?번|잠깐|잠시|다시)\s*)*(?:바라|쳐다)?(?:봐|보세요|look)")
|
||||||
|
|
||||||
|
|
||||||
EN_NUM = {w: i for i, w in enumerate("zero one two three four five six seven eight nine ten eleven twelve thirteen "
|
EN_NUM = {w: i for i, w in enumerate("zero one two three four five six seven eight nine ten eleven twelve thirteen "
|
||||||
@@ -1011,7 +1016,7 @@ def _slot(kind, text, markers, holding):
|
|||||||
not re.search(rf"(?<![a-z0-9]){re.escape(named[0].lower())}(?![0-9])", said):
|
not re.search(rf"(?<![a-z0-9]){re.escape(named[0].lower())}(?![0-9])", said):
|
||||||
return None # "exit a" with only Exit_B, "booth 13" with Booth_12: asked
|
return None # "exit a" with only Exit_B, "booth 13" with Booth_12: asked
|
||||||
return ("go_to", named[0])
|
return ("go_to", named[0])
|
||||||
if kind == "come" and (re.search(CARRY + r"|따라", t) or not re.search(COME_VERB, t)):
|
if kind == "come" and (re.search(CARRY + r"|따라", t) or not re.search(COME_SAID, t)):
|
||||||
return None # "나한테 가져와", "이리 줘": not a trip to the person
|
return None # "나한테 가져와", "이리 줘": not a trip to the person
|
||||||
if kind == "come" and re.search(r"\bwith (?:me|us)\b|함께|같이", t):
|
if kind == "come" and re.search(r"\bwith (?:me|us)\b|함께|같이", t):
|
||||||
return ("follow", "") # "just come with me": walk along
|
return ("follow", "") # "just come with me": walk along
|
||||||
@@ -1057,7 +1062,7 @@ def _slot(kind, text, markers, holding):
|
|||||||
not re.search(r"\bface\b|\bother (?:side|way)\b|\d+\s*(?:degrees?|도)", t.replace("360", "")) and \
|
not re.search(r"\bface\b|\bother (?:side|way)\b|\d+\s*(?:degrees?|도)", t.replace("360", "")) and \
|
||||||
said_amount(text)[1] in (None, 360):
|
said_amount(text)[1] in (None, 360):
|
||||||
return ("turn", ("right" if re.search(r"\bright\b|오른쪽", t) else "left") + " 360")
|
return ("turn", ("right" if re.search(r"\bright\b|오른쪽", t) else "left") + " 360")
|
||||||
if re.search(r"\baround\b|\bu-?turn\b|유턴|뒤로 돌|뒤돌|\bother way\b|\babout face\b|한 바퀴", t):
|
if re.search(r"\baround\b|\bu-?turn\b|유턴|뒤로 (?:(?:좀|한 ?번|얼른|빨리)\s*)?돌|뒤돌|\bother way\b|\babout face\b|한 바퀴", t):
|
||||||
return None if re.search(r"\bleft|\bright\b|왼|오른", t) else ("turn", "around 180")
|
return None if re.search(r"\bleft|\bright\b|왼|오른", t) else ("turn", "around 180")
|
||||||
d = [x for x in _dirs(t) if x in ("left", "right")]
|
d = [x for x in _dirs(t) if x in ("left", "right")]
|
||||||
if not d and said_amount(text)[1] == 180:
|
if not d and said_amount(text)[1] == 180:
|
||||||
@@ -1159,12 +1164,54 @@ def read(text, markers=(), holding=False):
|
|||||||
kind = kind_of(text, markers)
|
kind = kind_of(text, markers)
|
||||||
if isinstance(kind, tuple): # two motions close: only when the words fit one of them
|
if isinstance(kind, tuple): # two motions close: only when the words fit one of them
|
||||||
kind, other = kind
|
kind, other = kind
|
||||||
if other not in ACTS or _slot(other, text, markers, holding) is not None:
|
if other == "put" and not holding and not PUT_VERB.search(text):
|
||||||
|
pass # "원래 자리로 가 줘": no put verb, nothing held: the trip back
|
||||||
|
elif other not in ACTS or _slot(other, text, markers, holding) is not None:
|
||||||
|
return None
|
||||||
|
if kind and _verb_conflict(kind, text, holding):
|
||||||
return None
|
return None
|
||||||
got = _slot(kind, text, markers, holding) if kind else None
|
got = _slot(kind, text, markers, holding) if kind else None
|
||||||
return ("fetch", said) if got and got[0] == "fetch" else got
|
return ("fetch", said) if got and got[0] == "fetch" else got
|
||||||
|
|
||||||
|
|
||||||
|
PICK_VERB = re.compile(r"집|잡|들어|들고|가져|갖다|챙겨|\b(?:pick|grab|take|get|fetch|bring|hold)\b", re.I)
|
||||||
|
LOOK_VERB = re.compile(r"봐|보세|쳐다|바라|\b(?:look|see|watch)\b", re.I)
|
||||||
|
PUT_VERB = re.compile(r"놓|놔|둬|두|내려|\b(?:put|place|drop|set|leave)\b", re.I)
|
||||||
|
BACK_VERB = re.compile(r"돌아|복귀|컴백|리턴|가|와|\b(?:return|go|come|head|back)\b", re.I)
|
||||||
|
POINTED = re.compile(r"저기 ?저|저 ?자리|(?<!아까 )그 ?자리로|\bthat (?:spot|place|position)\b|\bover there\b", re.I)
|
||||||
|
|
||||||
|
|
||||||
|
def _verb_conflict(kind, text, holding):
|
||||||
|
"""The bank's kind against the verb said: "저 컵 봐" is no pick, "바닥에 있는 거 집어 줘" no look, "저기 저 자리로 가"
|
||||||
|
a pointed place, not back; holding a thing, the hand words are the hand reader's ("손 펴", "제자리 좀")."""
|
||||||
|
if kind in ("pick", "fetch") and LOOK_VERB.search(text) and not PICK_VERB.search(text):
|
||||||
|
return True
|
||||||
|
if kind == "look" and PICK_VERB.search(text) and not LOOK_VERB.search(text) and not HEAD_WORD.search(text):
|
||||||
|
return True
|
||||||
|
if kind == "come_back" and (POINTED.search(text) or not BACK_VERB.search(text)):
|
||||||
|
return True
|
||||||
|
if kind in ("turn", "move") and (HEAD_WORD.search(text) or re.search(r"돌아 ?보|허리|\bwaa*i*st\b|\btorso\b", text, re.I)):
|
||||||
|
return True # "머리 왼쪽으로 15도 돌려": the head
|
||||||
|
if kind == "look" and BODY_WORD.search(text) and not HEAD_WORD.search(text):
|
||||||
|
return True # "본체를 오른쪽으로 돌려", "torso 정면": the body
|
||||||
|
if kind == "look" and GO_VERB.search(text) and not HEAD_WORD.search(text) and not LOOK_VERB.search(text):
|
||||||
|
return True # "라이트로 살짝 가 줘": a drive
|
||||||
|
if kind == "arm_reach" and (HAND_SHAPE.search(text) or COME_VERB.search(text) and not ARM_WORD.search(text)):
|
||||||
|
return True # "손 펴 주시겠어요" (open), "할머니한테 와 줘" (come)
|
||||||
|
if kind == "wave" and not WAVE_VERB.search(text):
|
||||||
|
return True # "손 벌려 줘", "손 쥐어 빨리", "손 좀 주이소"
|
||||||
|
return holding and kind in ("arm_open", "arm_fold", "arm_reach", "arm_close")
|
||||||
|
|
||||||
|
|
||||||
|
HEAD_WORD = re.compile(r"머리|고개|얼굴|시선|\b(?:head|eyes|(?<!about )face|gaze)\b", re.I)
|
||||||
|
BODY_WORD = re.compile(r"본체|몸|허리|상체|몸통|\b(?:body|torso|waist|upper body|yourself)\b", re.I)
|
||||||
|
GO_VERB = re.compile(r"(?<![가-힣])가(?: ?줘| ?주|$|\s)|이동|움직|무브|\b(?:move|go|drive|roll|scoot)\b", re.I)
|
||||||
|
HAND_SHAPE = re.compile(r"펴|펼|쥐|주먹|넣|접|내려|오므|놔|놓|\b(?:open|close|fist|tuck|fold|lower)\b", re.I)
|
||||||
|
COME_VERB = re.compile(r"(?<![가-힣])와(?![가-힣])|와 ?(?:줘|주)|오세요|오십시오|\bcome\b", re.I)
|
||||||
|
ARM_WORD = re.compile(r"손|팔|\b(?:hand|arm)\b", re.I)
|
||||||
|
WAVE_VERB = re.compile(r"흔들|흔드|악수|인사|빠이|바이|웨이브|하이|\b(?:wave|waving|hello|hi|hey|shake|greet|bye)\b", re.I)
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
if sys.argv[1:] == ["build"]:
|
if sys.argv[1:] == ["build"]:
|
||||||
n = len(_load()[1])
|
n = len(_load()[1])
|
||||||
|
|||||||
+72
-22
@@ -123,8 +123,14 @@ CLOSE_BOX = 0.85 # a person is really closer than TOO_CLOSE on
|
|||||||
HEAD_SIGN = 1.0 # +image angle -> +head yaw (checked: + = robot's left)
|
HEAD_SIGN = 1.0 # +image angle -> +head yaw (checked: + = robot's left)
|
||||||
LOOK = {"left": (40, None), "right": (-40, None), "center": (0, head.HEAD_REST_PITCH), "up": (None, 20), "down": (None, -5)}
|
LOOK = {"left": (40, None), "right": (-40, None), "center": (0, head.HEAD_REST_PITCH), "up": (None, 20), "down": (None, -5)}
|
||||||
# ^ yaw/pitch in degrees for "look" commands: +yaw = left, +pitch = up (checked on the dashboard 2026-10-12)
|
# ^ yaw/pitch in degrees for "look" commands: +yaw = left, +pitch = up (checked on the dashboard 2026-10-12)
|
||||||
WAKE = re.compile(r"\b(hi|hey|hello|okay|ok|hai|high)?[\s,.!]*(lumi|lumia|loomi|loomy|lumie|lumee|lumy|lummy|lummi|looney|lu-mi|rumi|rumy|roomie)\b"
|
WAKE_UP_EN = r"wake up|wakey wakey|time to wake up"
|
||||||
r"|루미|누미", re.I)
|
WAKE_UP_KO = r"(?:일어나|깨어나)(?:요|세요|십시오|라|봐|봐요)?|기상"
|
||||||
|
WAKE = re.compile(rf"\b(hi|hey|hello|okay|ok|hai|high|{WAKE_UP_EN})?[\s,.!]*(lumi|lumia|loomi|loomy|lumie|lumee|lumy|lummy|lummi|looney|lu-mi|rumi|rumy|roomie)\b"
|
||||||
|
rf"(?:[\s,.!]*(?:{WAKE_UP_EN})\b)?"
|
||||||
|
rf"|(?:(?:{WAKE_UP_KO})[\s,.!~]*)?(?:헤이 ?|하이 ?)?(?:루미|누미)(?:야|아)?(?:[\s,.!~]*(?:{WAKE_UP_KO}))?"
|
||||||
|
rf"|^\W*(?:(?:hey|ok|okay|come on)\W+)?(?:{WAKE_UP_EN})\W*$|^\W*(?:(?:자|이제|얼른)\s+)?(?:{WAKE_UP_KO})[\s.!~]*$", re.I)
|
||||||
|
# ^ "Hey Lumi", "Lumi", "wake up (Lumi)", "Lumi, wake up", "루미야", "헤이 루미", "루미야 일어나", "일어나세요";
|
||||||
|
# a bare "wake up" / "일어나" only as the whole utterance ("I wake up at 7" is no call)
|
||||||
WAKE_REPLY = {"en": "Yes? How can I help?", "ko": "네? 무엇을 도와드릴까요?"}
|
WAKE_REPLY = {"en": "Yes? How can I help?", "ko": "네? 무엇을 도와드릴까요?"}
|
||||||
NAME_ONLY = re.compile(r"^\s*(hi |hey |hello )?(lumi|loomi|rumi|루미)[\s,.!?]*$", re.I)
|
NAME_ONLY = re.compile(r"^\s*(hi |hey |hello )?(lumi|loomi|rumi|루미)[\s,.!?]*$", re.I)
|
||||||
FETCH_STOP = re.compile(r"\b(sto+pp?|stob|halt|freeze|don'?t move)\b|^\W*(?:lumi\W+)?stopped\W*$|스탑|스텁|멈추(?:세요|십시오)|^\W*abort\W*$|\babort (?:the |this |your )?(?:mission|task|trip)\b|\bcancel (?:the |this |your )?(?:mission|task|trip)\b|"
|
FETCH_STOP = re.compile(r"\b(sto+pp?|stob|halt|freeze|don'?t move)\b|^\W*(?:lumi\W+)?stopped\W*$|스탑|스텁|멈추(?:세요|십시오)|^\W*abort\W*$|\babort (?:the |this |your )?(?:mission|task|trip)\b|\bcancel (?:the |this |your )?(?:mission|task|trip)\b|"
|
||||||
@@ -313,7 +319,7 @@ HELLO_ONLY = re.compile(r"^(?=\W*\w)\s*(?:(?:hi|hey|hello|hiya|hai|hallo|helo|hi
|
|||||||
r"(?:how are you(?: doing)?(?: today)?[\s,.!?]*)?$|" # "how are you?"
|
r"(?:how are you(?: doing)?(?: today)?[\s,.!?]*)?$|" # "how are you?"
|
||||||
r"^\s*(?:안녕|안녕하세요|안녕하십니까|하이)[\s.!~?]*$", re.I) # "안녕하세요", "하이"
|
r"^\s*(?:안녕|안녕하세요|안녕하십니까|하이)[\s.!~?]*$", re.I) # "안녕하세요", "하이"
|
||||||
CALL_REST = re.compile(r"^(?:[\W_]|\b(?:hi|hey|hello|hiya|hai|ok|okay|there|how are you(?: doing)?(?: today)?)\b|"
|
CALL_REST = re.compile(r"^(?:[\W_]|\b(?:hi|hey|hello|hiya|hai|ok|okay|there|how are you(?: doing)?(?: today)?)\b|"
|
||||||
r"안녕(?:하세요|하십니까)?|하이|야|아)*$", re.I) # what is left of a call without the name
|
r"안녕(?:하세요|하십니까)?|하이|헤이|야|아)*$", re.I) # what is left of a call without the name
|
||||||
CAMERA_HALF_FOV = 42.0 # deg; half the camera's view (+ the head's YAW_LIMIT for the head camera)
|
CAMERA_HALF_FOV = 42.0 # deg; half the camera's view (+ the head's YAW_LIMIT for the head camera)
|
||||||
WAKE_MAX_S = 6.0 # s; longer utterances are not checked for the wake word
|
WAKE_MAX_S = 6.0 # s; longer utterances are not checked for the wake word
|
||||||
BARGE_IN_LOGPROB = -0.6 # an interruption must be heard more clearly than a normal answer (-1.0)
|
BARGE_IN_LOGPROB = -0.6 # an interruption must be heard more clearly than a normal answer (-1.0)
|
||||||
@@ -3255,35 +3261,53 @@ STOP_UNSAID = re.compile( # a stop that is taken back, for later, said about t
|
|||||||
r"\bstop it,? (?-i:(?!Lumi\b|Robot\b)[A-Z][a-z]+)\b", re.I)
|
r"\bstop it,? (?-i:(?!Lumi\b|Robot\b)[A-Z][a-z]+)\b", re.I)
|
||||||
|
|
||||||
|
|
||||||
|
STOP_LATER = re.compile( # a stop for later ("내일 그만하시게", "행사가 끝난 후에 멈춰 주세요") or reported ("아까 직원분이
|
||||||
|
# 그만하라고 지시했습니다"); "내가 멈추라고 했지!" is said now
|
||||||
|
r"(?:^|\s)(?:나중에|이따가?|있다가|내일|모레|다음에|다음 ?번에)\s|(?:끝난|끝나고|마친|마치고|끝내고) ?(?:후|뒤|다음)?에?\s|"
|
||||||
|
r"[가-힣]고 ?나서\s|(?<!내가 )(?<!제가 )(?<!내가)(?:그만하|멈추|멈춰 ?달|정지하|서)라고\s*(?:\S+\s+)?"
|
||||||
|
r"(?:했|하셨|그랬|말했|말씀|지시|하더|하던|한다|하네)")
|
||||||
|
|
||||||
|
|
||||||
STOP_PAD = re.compile(r"^(?:\W*(?:hey|hi|yo|oh|okay|ok|so|um+|uh+|listen|right|alright|all right|excuse me|mister robot|"
|
STOP_PAD = re.compile(r"^(?:\W*(?:hey|hi|yo|oh|okay|ok|so|um+|uh+|listen|right|alright|all right|excuse me|mister robot|"
|
||||||
r"robot|lumi|loomi|루미 ?씨|루미 ?선생|루미야?|로봇아?|로봇 양반|어+|아+|야|저기요?)\b)+|"
|
r"robot|lumi|loomi|루미 ?씨|루미 ?선생|루미야?|로봇아?|로봇 양반|어+|아+|야|저기요?)\b)+|"
|
||||||
r"(?:\W*\b(?:please|plz|pls|bro|now|right now|real quick|thanks|thank you|okay|ok|would you|will you|"
|
r"(?:\W*\b(?:please|plz|pls|bro|now|right now|real quick|thanks|thank you|okay|ok|would you|will you|"
|
||||||
r"right|already|빨리|좀|제발|당장|루미야?)\b)+\W*$", re.I)
|
r"right|already|lumi|robot|빨리|좀|제발|당장|루미야?)\b)+\W*$", re.I)
|
||||||
STOP_ONLY = re.compile( # a whole sentence that only says stop / enough / stay (after calls and fillers): stop at once
|
STOP_ONLY = re.compile( # a whole sentence that only says stop / enough / stay (after calls and fillers): stop at once
|
||||||
r"(?:(?:sto+p|stahp|stob|top it|enough|that'?s enough|that is enough|no more|quit it|cut it out|kill it|abort|"
|
r"(?:(?:sto+p|stahp|stob|top it|enough|that'?s enough|that is enough|no more|quit it|cut it out|knock it off|whoa,? there|whoa(?:,? whoa)+|kill it|abort|"
|
||||||
r"stop (?:everything|driving|moving|it|that|the robot|right there|right now)|enough (?:music|of that)|"
|
r"stop (?:everything|driving|moving|it|that|the robot|right there|right now)|enough (?:music|of that)|"
|
||||||
r"hold it|stop 해|그만|그만해|그만해요|그만하세요|그만하십시오|그만해 ?줄래요?|"
|
r"hold it(?: (?:right )?(?:there|here))?|stop 해|그만|그만해|그만해요|그만하세요|그만하십시오|그만해 ?줄래요?|"
|
||||||
r"그만해 ?주세요|그마내|그만둬|멈춰|멈쳐|멈처|멈추라고|멈춰 ?봐|거기까지|고마 ?(?:서라|해라|해|하이소)|서|don'?t go|가지 ?마|그마+안|"
|
r"그만해 ?주세요|그마내|그만둬|멈춰|멈쳐|멈처|멈추라고|멈춰 ?봐|거기까지|고마 ?(?:서라|해라|해|하이소)|서|don'?t go|가지 ?마|그마+안|"
|
||||||
r"얼음|cut it|노래 ?꺼|음악 ?꺼|stop the (?:music|song)|music off|stay|stay (?:here|there|put|right there)|"
|
r"얼음|cut it|노래 ?꺼|음악 ?꺼|stop the (?:music|song)|music off|stay|stay (?:here|there|put|right there)|"
|
||||||
r"(?:just )?wait there|stop following(?: me)?|finish follow|(?:여기|거기)(?:서)? ?(?:그대로 ?)?(?:있어|있어요|계세요|stay|서|서세요|"
|
r"(?:just )?wait there|stop following(?: me)?|finish follow|(?:여기|거기)(?:서)? ?(?:그대로 ?)?(?:있어|있어요|계세요|stay|서|서세요|"
|
||||||
r"기다려)|그대로 있어|가만히 있어|stay 해|wait 해)\W*){1,3}", re.I)
|
r"기다려)|그대로 있어|가만히 있어|stay 해|wait 해)\W*){1,3}", re.I)
|
||||||
|
|
||||||
|
|
||||||
|
STOP_POLITE = re.compile( # a stop asked politely, after wording.ko_plain: "멈춰 주시겠어요?" -> "멈춰 줘?", "can you stop for me?"
|
||||||
|
r"\W*(?:(?:좀|지금|당장|잠깐|잠시|거기서?|이제)\s*)*(?:멈춰|멈춰 서|정지해|그만해|스톱해|스탑해|서)(?: ?줘)?\W*|"
|
||||||
|
r"\W*(?:(?:please|lumi|hey|okay|ok)\W+)*(?:can|could|would|will) (?:you|u) (?:please |just |kindly )?(?:stop|halt|freeze)"
|
||||||
|
r"(?: (?:right )?(?:now|here|there|please))?(?: for (?:me|us|a (?:second|sec|moment|bit|minute)))?(?:,? please)?\W*|"
|
||||||
|
r"\W*(?:would|do) you mind stopping(?: (?:now|here|there))?(?: for (?:me|us|a (?:second|moment)))?(?:,? please)?\W*", re.I)
|
||||||
|
|
||||||
|
|
||||||
def stop_order(text, markers):
|
def stop_order(text, markers):
|
||||||
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button;
|
""""stop", "freeze", "멈춰": stop everything at once. Not "stop talking" and not a question about the stop button;
|
||||||
"can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop. Not a negated stop ("don't stop", "계속
|
"can you stop?", "멈출 수 있어?" and "stop, where are you going?" do stop. Not a negated stop ("don't stop", "계속
|
||||||
해"), talk about stopping ("he said stop", "bus stop", "my laptop freezes", "내 다리도 자주 멈춰"); a short bare
|
해"), talk about stopping ("he said stop", "bus stop", "my laptop freezes", "내 다리도 자주 멈춰"); a short bare
|
||||||
stop word always stops (also stretched: "stooop", "머엄춰")."""
|
stop word always stops (also stretched: "stooop", "머엄춰")."""
|
||||||
if NOT_STOP.search(text) and not re.fullmatch(r"\W*(?:(?:no|ok|okay|lumi|루미야?|hey)\W+)*(?:sto+pp?|stob|stopped|halt|freeze|멈춰|머+엄*춰|"
|
if NOT_STOP.search(text) and not re.fullmatch(r"\W*(?:(?:lumi|robot|hey|okay|ok)\W+)*(?:would|do) you mind stopping"
|
||||||
|
r"(?:,? (?:now|here|there|please|for (?:me|us|a (?:second|moment))))*\W*", text, re.I) \
|
||||||
|
and not re.fullmatch(r"\W*(?:(?:no|ok|okay|lumi|루미야?|hey)\W+)*(?:sto+pp?|stob|stopped|halt|freeze|멈춰|머+엄*춰|"
|
||||||
r"그만|정지|스톱|스탑|stop it|stop now)\W*", text, re.I):
|
r"그만|정지|스톱|스탑|stop it|stop now)\W*", text, re.I):
|
||||||
return False
|
return False
|
||||||
if STOP_UNSAID.search(text):
|
if STOP_UNSAID.search(text) or STOP_LATER.search(text):
|
||||||
return False
|
return False # "이따가 멈춰 주세요": a stop for later
|
||||||
bare = STOP_PAD.sub("", text.strip()).strip(" ,.!?~")
|
bare = STOP_PAD.sub("", text.strip()).strip(" ,.!?~")
|
||||||
if bare and STOP_ONLY.fullmatch(bare):
|
if bare and STOP_ONLY.fullmatch(bare):
|
||||||
return True # "hi Lumi, stop, okay?", "enough already", "Lumi, wait"
|
return True # "hi Lumi, stop, okay?", "enough already", "Lumi, wait"
|
||||||
# (watch out / 위험해 / "Lumi, wait" / hold on: on a mission these halt it (mission_talk), never end it)
|
# (watch out / 위험해 / "Lumi, wait" / hold on: on a mission these halt it (mission_talk), never end it)
|
||||||
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text)) or
|
from assistant import wording
|
||||||
|
plain = brain_mod.CALLING.sub("", wording.ko_plain(text)).strip()
|
||||||
|
asked = bool(brain_mod.STOP_ASK.match(brain_mod.CALLING.sub("", text)) or STOP_POLITE.fullmatch(plain) or
|
||||||
re.match(r"^\W*(?:stop|halt|freeze|멈춰|정지|스톱)\W*[,.!]", text, re.I))
|
re.match(r"^\W*(?:stop|halt|freeze|멈춰|정지|스톱)\W*[,.!]", text, re.I))
|
||||||
return bool(FETCH_STOP.search(text) or asked) and (brain_mod.intent(text, markers) or ("",))[0] not in ("quiet", "look") \
|
return bool(FETCH_STOP.search(text) or asked) and (brain_mod.intent(text, markers) or ("",))[0] not in ("quiet", "look") \
|
||||||
and not brain_mod.STOP_TALK.search(text) and ("?" not in text or asked)
|
and not brain_mod.STOP_TALK.search(text) and ("?" not in text or asked)
|
||||||
@@ -3299,14 +3323,16 @@ HAND_STATE_Q = re.compile( # how the hand is now (A1): "is your hand open?", "
|
|||||||
r"\b(?:is|are|r|was) (?:your|ur|the) (?:hand|gripper|claw|fingers?|arm)s? (?:still |now |already )?(?:open|opened|closed|shut|out|"
|
r"\b(?:is|are|r|was) (?:your|ur|the) (?:hand|gripper|claw|fingers?|arm)s? (?:still |now |already )?(?:open|opened|closed|shut|out|"
|
||||||
r"extended|empty|folded|in|up|down|stretched)\b|\b(?:hand|gripper|arm) (?:open|closed?|out)\s*(?:이야|이에요|인가요?|이니|상태|\?)|"
|
r"extended|empty|folded|in|up|down|stretched)\b|\b(?:hand|gripper|arm) (?:open|closed?|out)\s*(?:이야|이에요|인가요?|이니|상태|\?)|"
|
||||||
r"^\W*(?:(?:right|um|basically|next|so|okay)\W+)*did (?:you|u) drop (?:it|that|something|the \w+)\W*$|"
|
r"^\W*(?:(?:right|um|basically|next|so|okay)\W+)*did (?:you|u) drop (?:it|that|something|the \w+)\W*$|"
|
||||||
r"(?:손|그리퍼|집게|손가락|팔)(?:이|은|는|가)? ?(?:지금 |아직 |다 )?(?:open|close|펴져|펴진|열려|열린|닫혀|닫힌|접혀|접힌|뻗어져|오므려져|"
|
r"(?:손|그리퍼|집게|손가락|팔)(?:이|은|는|가)? ?(?:지금 |아직 |다 )?(?:open|close|오픈|클로즈|펴져|펴진|열려|열린|닫혀|닫힌|접혀|접힌|뻗어져|오므려져|"
|
||||||
r"쥐어져)\s*(?:있|상태|이야|인가)", re.I)
|
r"쥐어져)\s*(?:있|상태|이야|인가)", re.I)
|
||||||
|
|
||||||
|
|
||||||
def status_question(text):
|
def status_question(text):
|
||||||
""""What are you doing?", "where are you going?", "is your hand open?": answered from the task state ("들고 있는 거
|
""""What are you doing?", "where are you going?", "is your hand open?": answered from the task state ("들고 있는 거
|
||||||
줘" is a request)."""
|
줘" is a request)."""
|
||||||
return bool(HAND_STATE_Q.search(text)) or bool(STATUS_Q.search(text)) and not NOT_STATUS_NOW.search(text) and not EMPTY_HAND.search(text)
|
hand = HAND_STATE_Q.search(text) and not re.search(r"\b(?:stretch|stick|hold|put|reach|extend|get|move|bring)\b", text, re.I)
|
||||||
|
return bool(hand) or bool(STATUS_Q.search(text)) and not NOT_STATUS_NOW.search(text) and not EMPTY_HAND.search(text)
|
||||||
|
# hand: not "may I ask you to stretch your arm out?" (an order)
|
||||||
|
|
||||||
|
|
||||||
def says_goodbye(text):
|
def says_goodbye(text):
|
||||||
@@ -3338,6 +3364,11 @@ NOT_A_STEP = re.compile(r"^\W*(?:(?:please|and|then|also)\s+)*(?:dance|jump|fly|
|
|||||||
r"bring|take|give|hand|put|carry|deliver)\b|.*(?:춤|점프|날아|수영|박수)", re.I) # a part not read: asked
|
r"bring|take|give|hand|put|carry|deliver)\b|.*(?:춤|점프|날아|수영|박수)", re.I) # a part not read: asked
|
||||||
|
|
||||||
|
|
||||||
|
CAN_TOLD = re.compile(r"\b(?:you|u) (?:can|could|are able to|know how to)\b|(?<!줄 )(?<!주실 )(?<!줄)(?<!주실)수 ?(?:도 ?)?있(?:지|죠|잖|겠지|겠죠|을 ?걸)|"
|
||||||
|
r"줄 ?(?:도 ?)?알(?:지|죠|잖)", re.I) # with a tag: Lumi's ability said back, a question (TAG)
|
||||||
|
MYEOT_SLIP = re.compile(r"(?<![가-힣])멸(?=\s*(?:센티|센치|미터|밀리|키로|킬로|그램|개|번|도|시|분|초|명|살|층|cm|mm|kg|m\b))", re.I)
|
||||||
|
|
||||||
|
|
||||||
def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
|
def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
|
||||||
"""Which way a command goes, the same for voice (Lumi.answer), the dashboard's Command box (/tasks/parse) and
|
"""Which way a command goes, the same for voice (Lumi.answer), the dashboard's Command box (/tasks/parse) and
|
||||||
tests/command_check: (kind, data). Kinds in this order: "stop"; "detour" (data: assistant/detour.read's
|
tests/command_check: (kind, data). Kinds in this order: "stop"; "detour" (data: assistant/detour.read's
|
||||||
@@ -3348,10 +3379,15 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
|
|||||||
reading: assistant/intent_bank.py); (None, None): the LLM reads
|
reading: assistant/intent_bank.py); (None, None): the LLM reads
|
||||||
it. seen: seeing.answer or a stand-in; chain_ok: False on a mission or while a chain runs."""
|
it. seen: seeing.answer or a stand-in; chain_ok: False on a mission or while a chain runs."""
|
||||||
from assistant import chain, intent_bank
|
from assistant import chain, intent_bank
|
||||||
|
text = MYEOT_SLIP.sub("몇", text or "") # whisper's 멸 for 몇: "멸 센티까지 잡아?" asks, orders nothing
|
||||||
|
text = re.sub(r"(?<=[가-힣])(?=[a-zA-Z]{2})", " ", text) # "원래 자리에put back": the English word apart
|
||||||
|
text = re.sub(r"\bcome on back\b", "come back", text, flags=re.I) # not 1 m back
|
||||||
|
text = re.sub(r"(?<![\d.])360(?= ?돌아)", "360도", text) # "루미 360 돌아 봐": a full turn, not "turn round"
|
||||||
if stop_order(text, markers):
|
if stop_order(text, markers):
|
||||||
return "stop", None
|
return "stop", None
|
||||||
told = intent_bank.TAG.search(text) and (chain.PAST.search(text) or intent_bank.PAST_EN.search(text) or
|
told = intent_bank.TAG.search(text) and (chain.PAST.search(text) or intent_bank.PAST_EN.search(text) or
|
||||||
intent_bank.past_ko(text)) # "you went to P5 earlier, right?": asked
|
intent_bank.past_ko(text) or CAN_TOLD.search(text))
|
||||||
|
# "you went to P5 earlier, right?", "you can lift your arm, right?", "너 팔 접을 수 있지?": asked, no order
|
||||||
text = brain_mod.strip_asides(text) # "hi Lumi, it's my birthday, put it down!": the command (A1)
|
text = brain_mod.strip_asides(text) # "hi Lumi, it's my birthday, put it down!": the command (A1)
|
||||||
if sing.picked(text, last): # after the list of songs: "the first one", "Fantastic Baby"
|
if sing.picked(text, last): # after the list of songs: "the first one", "Fantastic Baby"
|
||||||
return "sing", None
|
return "sing", None
|
||||||
@@ -3371,15 +3407,18 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
|
|||||||
plan = None # "그 cup 들고 wave 해" with a cup in the hand: no second pick; the LLM
|
plan = None # "그 cup 들고 wave 해" with a cup in the hand: no second pick; the LLM
|
||||||
if plan:
|
if plan:
|
||||||
return "chain", plan
|
return "chain", plan
|
||||||
got = seen(text) if seen else None
|
held_order = (holding() if callable(holding) else holding) and not hold and \
|
||||||
|
(brain_mod.held_place(text, markers) or brain_mod.held_give(text, markers)) # "put it down ok?" with a cup:
|
||||||
|
got = seen(text) if seen and not held_order else None # the hand, not "I put it down, now?"
|
||||||
if got:
|
if got:
|
||||||
return "seeing", got
|
return "seeing", got
|
||||||
if status_question(text):
|
if status_question(text):
|
||||||
return "status", None
|
return "status", None
|
||||||
if (holding() if callable(holding) else holding) and brain_mod.held_put_back(text, markers):
|
if (holding() if callable(holding) else holding) and not brain_mod.held_back(text) and \
|
||||||
|
not brain_mod.ARM_TALK.search(text) and brain_mod.held_put_back(text, markers):
|
||||||
return "quick", ("put", "back") # "it's my birthday, put that back where you found it!"
|
return "quick", ("put", "back") # "it's my birthday, put that back where you found it!"
|
||||||
song = sing.asked(text, last) # "Let it go 불러 줘": a song title, never the hand (A1)
|
song = sing.asked(text, last) # "Let it go 불러 줘": a song title, never the hand (A1)
|
||||||
if hold and not song: # a wave / arm rule may act on a question-form request ("악수 한번 할까요?",
|
if hold and not song and not told: # a wave / arm rule may act on a question-form request ("악수 한번 할까요?",
|
||||||
arm_rule = brain_mod.intent(text, markers) # "would it be possible to wave at me?"); intent() itself refuses
|
arm_rule = brain_mod.intent(text, markers) # "would it be possible to wave at me?"); intent() itself refuses
|
||||||
if arm_rule and arm_rule[0] in ("wave", "arm"): # negations, later times, remarks, ability questions (A1)
|
if arm_rule and arm_rule[0] in ("wave", "arm"): # negations, later times, remarks, ability questions (A1)
|
||||||
return arm_quick(arm_rule, holding)
|
return arm_quick(arm_rule, holding)
|
||||||
@@ -3392,7 +3431,9 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
|
|||||||
cor = brain_mod.correction(text, b.history)
|
cor = brain_mod.correction(text, b.history)
|
||||||
if cor:
|
if cor:
|
||||||
return "correction", cor
|
return "correction", cor
|
||||||
if not song and (brain_mod.hand_request(text, False, b, markers) or brain_mod.hand_request(text, True, b, markers)):
|
if not song and not brain_mod.ARM_TALK.search(text) and not brain_mod.held_back(text) and \
|
||||||
|
(brain_mod.hand_request(text, False, b, markers) or brain_mod.hand_request(text, True, b, markers)):
|
||||||
|
# not "it'd be cool if you could hand it over someday", "I heard you can take things from people"
|
||||||
held = holding() if callable(holding) else holding
|
held = holding() if callable(holding) else holding
|
||||||
hand = brain_mod.hand_request(text, held, b, markers)
|
hand = brain_mod.hand_request(text, held, b, markers)
|
||||||
if hand:
|
if hand:
|
||||||
@@ -3408,12 +3449,16 @@ def route(text, markers, b, holding=False, seen=None, last="", chain_ok=True):
|
|||||||
if sing.asked(text, last):
|
if sing.asked(text, last):
|
||||||
return "sing", None
|
return "sing", None
|
||||||
rule = brain_mod.intent(text, markers)
|
rule = brain_mod.intent(text, markers)
|
||||||
|
if rule and rule[0] in QUICK_RULES - {"come_back", "weather", "search"} and brain_mod.ARM_TALK.search(text):
|
||||||
|
return None, None # "자네 컵 잡는 거 제법이더군", "do you know how to drive right 30 cm?",
|
||||||
|
# "70센티 앞으로 움직일 리가 있나": a remark or an ability, no motion
|
||||||
if rule and rule[0] in QUICK_RULES:
|
if rule and rule[0] in QUICK_RULES:
|
||||||
return "quick", rule
|
return "quick", rule
|
||||||
if not rule:
|
if not rule:
|
||||||
from assistant import intent_bank
|
from assistant import intent_bank
|
||||||
rule = intent_bank.read(text, markers, holding) # the same request in other words, by meaning
|
rule = None if brain_mod.GREET_ONLY.match(text or "") else \
|
||||||
if rule and rule[0] in ("wave", "arm") and brain_mod.ARM_TALK.search(text):
|
intent_bank.read(text, markers, holding) # the same request in other words, by meaning ("hello robot": no wave)
|
||||||
|
if rule and rule[0] not in ("come_back", "weather", "search") and brain_mod.ARM_TALK.search(text):
|
||||||
rule = None # "it'd be cool if you could take your hand back someday": talk (A1)
|
rule = None # "it'd be cool if you could take your hand back someday": talk (A1)
|
||||||
if rule:
|
if rule:
|
||||||
return arm_quick(rule, holding)
|
return arm_quick(rule, holding)
|
||||||
@@ -3436,7 +3481,7 @@ ARM_AGAIN = re.compile(r"^\W*(?:(?:okay|ok|yes|yeah|lumi|please|robot|루미야?
|
|||||||
|
|
||||||
|
|
||||||
FILLER_PART = re.compile(r"\W*(?:(?:hey|yo|hi|okay|ok|excuse me|um+|uh+|so|now|please|thanks|thank you|real quick|quick|"
|
FILLER_PART = re.compile(r"\W*(?:(?:hey|yo|hi|okay|ok|excuse me|um+|uh+|so|now|please|thanks|thank you|real quick|quick|"
|
||||||
r"right now|lumi|robot|buddy|mister robot|bro|dude|어이|야|저기요?|루미야?|로봇아?|당장|지금|빨리|"
|
r"right now|lumi|robot|buddy|mister robot|bro|dude|어이|야|저기요?|루미 ?씨|루미야?|로봇아?|당장|지금|빨리|"
|
||||||
r"얼른|어서|끝까지|이제|좀|제발)\W*)+", re.I) # a part of the words that is no step: a call, "now"
|
r"얼른|어서|끝까지|이제|좀|제발)\W*)+", re.I) # a part of the words that is no step: a call, "now"
|
||||||
|
|
||||||
|
|
||||||
@@ -3445,7 +3490,10 @@ def read_mission(text, markers):
|
|||||||
A single move / turn / arm / go, or words that are only partly a plain command, stay with the other paths."""
|
A single move / turn / arm / go, or words that are only partly a plain command, stay with the other paths."""
|
||||||
from assistant import steps
|
from assistant import steps
|
||||||
got, unread, by = steps.read(text, markers, llm=False)
|
got, unread, by = steps.read(text, markers, llm=False)
|
||||||
unread = [u for u in unread if not FILLER_PART.fullmatch(u)] # "팔 접어, 당장", "hey robot, fold your arm"
|
from assistant import chain
|
||||||
|
unread = [u for u in unread if not FILLER_PART.fullmatch(u) and # "팔 접어, 당장", "hey robot, fold your arm"
|
||||||
|
not chain._restated(u, text.lower().replace(u, " "))] # "컵 잡아!, 아 잡아 줄 수 있어요?": said again
|
||||||
|
# (the parts come lower-cased: "부스 B로 가서" is the part itself, not said twice)
|
||||||
rule = brain_mod.intent(text, markers) or ("", "")
|
rule = brain_mod.intent(text, markers) or ("", "")
|
||||||
if unread and rule[0] == "look" and rule[1].endswith(f" {brain_mod.HEAD_YAW[1]:g}"):
|
if unread and rule[0] == "look" and rule[1].endswith(f" {brain_mod.HEAD_YAW[1]:g}"):
|
||||||
return None # "turn around and look": the head looks behind (brain.BEHIND_WORDS)
|
return None # "turn around and look": the head looks behind (brain.BEHIND_WORDS)
|
||||||
@@ -3462,7 +3510,9 @@ def read_mission(text, markers):
|
|||||||
return None
|
return None
|
||||||
if len(got) > 1 and all(st == got[0] for st in got) and got[0]["do"] in ("arm", "wave", "look", "lift"):
|
if len(got) > 1 and all(st == got[0] for st in got) and got[0]["do"] in ("arm", "wave", "look", "lift"):
|
||||||
got = got[:1] # "reach out, reach out to me": one reach, said twice
|
got = got[:1] # "reach out, reach out to me": one reach, said twice
|
||||||
plain = not steps.is_mission(got) and (len(got) == 1 or (brain_mod.intent(text, markers) or ("",))[0] == "fetch")
|
one_part = len(steps._split(steps._norm(steps._cut_says(text)[0], markers), markers)) == 1
|
||||||
|
plain = not steps.is_mission(got) and (len(got) == 1 or one_part or (brain_mod.intent(text, markers) or ("",))[0] == "fetch")
|
||||||
|
# ^ "컵 가져와 주셨으면 해요": one part a plain fetch can do stays the fetch, not a mission
|
||||||
if not unread and (plain or (len(got) == 1 and got[0]["do"] in ("move", "turn", "arm"))): # "take the cup and put
|
if not unread and (plain or (len(got) == 1 and got[0]["do"] in ("move", "turn", "arm"))): # "take the cup and put
|
||||||
return None # it on the chair": two steps, not a pick
|
return None # it on the chair": two steps, not a pick
|
||||||
return got, unread, by
|
return got, unread, by
|
||||||
|
|||||||
+117
-17
@@ -35,16 +35,21 @@ _SUP_KO = "|".join(k for k in brain.SUPPORTS if not k.isascii())
|
|||||||
_NUM = r"(\d+(?:\.\d+)?)"
|
_NUM = r"(\d+(?:\.\d+)?)"
|
||||||
_DIR = r"(forward|ahead|straight|back(?:wards?)?|left|right)"
|
_DIR = r"(forward|ahead|straight|back(?:wards?)?|left|right)"
|
||||||
_DIR_KO = r"(앞으로|뒤로|왼쪽으로|오른쪽으로)"
|
_DIR_KO = r"(앞으로|뒤로|왼쪽으로|오른쪽으로)"
|
||||||
_FILL = (r"(?:please|let'?s|lets|hey lumi|hi lumi|hey|hi|lumi|loomi|rumi|okay|ok|alright|all right|so|well|real quick|if you can|if you could|자|저기|저기요|혹시|instead|um+|uh+|er|hmm|thank you|thanks|now|then|and|also|first|next|"
|
_FILL = (r"(?:(?:저기 |그 )?(?:이보게(?: 루미)?|어이(?: 로봇아?| 루미야?)?|아야(?: 루미)?|야야(?: 루미)?|우리 루미|보소|자네|"
|
||||||
r"finally|after that|there|for me|again|carefully|slowly|could you|can you|would you|will you|lumi야|루미야|루미|음|응|어|야 로봇|로봇아|로봇야|"
|
r"루미 ?(?:님|씨|군|양)(?:께서|께)?|로봇 ?씨|여보세요|실례지만|실례합니다|죄송한데요?|죄송하지만|죄송합니다만|"
|
||||||
|
r"번거로우시겠지만)|" # calls of every level ("이보게 루미", "루미 님께서") before "루미" alone
|
||||||
|
r"please|let'?s|lets|hey lumi|hi lumi|hey|hi|lumi|loomi|rumi|okay|ok|alright|all right|so|well|real quick|if you can|if you could|자|저기|저기요|혹시|instead|um+|uh+|er|hmm|thank you|thanks|now|then|and|also|first|next|"
|
||||||
|
r"finally|after that|there|for me|for us|again|carefully|slowly|could you|can you|would you|will you|lumi야|루미야|루미|음|응|어|야 로봇|로봇아|로봇야|"
|
||||||
r"감사합니다|고마워요|고마워|고맙습니다|좀|먼저|우선|일단|그다음|그 다음|마지막으로|다시|lastly|first of all|"
|
r"감사합니다|고마워요|고마워|고맙습니다|좀|먼저|우선|일단|그다음|그 다음|마지막으로|다시|lastly|first of all|"
|
||||||
r"(?:i'?d|i would) like you to|i want you to|i need you to|you should|kindly|go ahead and|maybe|possibly|"
|
r"(?:i'?d|i would) like you to|i want you to|i need you to|you should|kindly|go ahead and|maybe|possibly|"
|
||||||
r"do me a favou?r and|be a dear and|right away|quickly|if you don'?t mind)")
|
r"do me a favou?r and|be a dear and|right away|quickly|if you don'?t mind|excuse me|sorry|"
|
||||||
|
r"거시기|에구|에이그|아|얘|no|nope|actually|change of plans?|아니|아니야|아니요|아뇨|아니 아니|" # "no, bring it to p4 instead": the new order
|
||||||
|
r"ㅎㅎ+|ㅋㅋ+|응\??|한 ?번만|쪼까|쫌|퍼뜩|얼른|빨리|어서|우리|거기서|그|robot)")
|
||||||
_PEOPLE = r"(?:them|him|her|someone|somebody|the person(?: there)?|people|the people|everyone|everybody|the guests?)"
|
_PEOPLE = r"(?:them|him|her|someone|somebody|the person(?: there)?|people|the people|everyone|everybody|the guests?)"
|
||||||
# where one step ends and the next starts
|
# where one step ends and the next starts
|
||||||
_SPLIT = re.compile(r"\s*(?:,|;|\.(?=\s|$)|\band then\b|\bthen\b|\band\b|\bafter that\b|\bafterwards\b|\bonce you'?re there\b|"
|
_SPLIT = re.compile(r"\s*(?:,|;|\.(?=\s|$)|\band then\b|\bthen\b|\band\b|\bafter that\b|\bafterwards\b|\bonce you'?re there\b|"
|
||||||
r"\bwhen you get there\b|그리고 나서|그러고 나서|그런 다음에?|그 후에?|그리고|그 ?다음에?|그담에|다음에)\s*")
|
r"\bwhen you get there\b|그리고 나서|그러고 나서|그런 다음에?|그 후에?|그리고|그 ?다음에?|그담에|다음에)\s*")
|
||||||
_SPLIT_KO = re.compile(r"(?<=[가-힣](?:고|서))(?<!라고)(?<!다고)(?<!자고)(?<!냐고)(?<!에서)(?<!말고)\s+(?!있)|(?<=다가)\s+") # "들고 ", "가서 ": a verb
|
_SPLIT_KO = re.compile(r"(?<=[가-힣](?:고|서))(?<!라고)(?<!다고)(?<!자고)(?<!냐고)(?<!에서)(?<!말고)\s+(?!있)(?!(?<![가와해]서\s)(?:줘|줘요|주세요|주십시오|줄래|주실래|주라|주게|주이소|봐|봐요|보세요)(?![가-힣]))|(?<=다가)\s+") # "들고 ", "가서 ": a verb
|
||||||
# joining two steps, not a quote
|
# joining two steps, not a quote
|
||||||
|
|
||||||
def _norm(text, markers=()):
|
def _norm(text, markers=()):
|
||||||
@@ -73,6 +78,11 @@ _SAME = [ # wordings read as the plain one (the blind mission sets, 2026-10-22
|
|||||||
r"|\buntil you(?:'re| are) told to (?:go on|continue|move on)\b", "until i tell you to go on"),
|
r"|\buntil you(?:'re| are) told to (?:go on|continue|move on)\b", "until i tell you to go on"),
|
||||||
(r"(?:누가\s*)?계속\s*(?:가라고|하라고|가도 된다고)\s*(?:할|하실|말할)\s*때까지\s*(?:거기서\s*)?", ""),
|
(r"(?:누가\s*)?계속\s*(?:가라고|하라고|가도 된다고)\s*(?:할|하실|말할)\s*때까지\s*(?:거기서\s*)?", ""),
|
||||||
(r"(?<=\S)까지\s*(?=갔다 ?와|다녀와)", " "), # "p4까지 갔다 와요" = "p4 갔다 와요"
|
(r"(?<=\S)까지\s*(?=갔다 ?와|다녀와)", " "), # "p4까지 갔다 와요" = "p4 갔다 와요"
|
||||||
|
(r"컴백\s*(?:하|해)\S*|컴 ?백(?=[\s,.!?]|$)", "돌아와"), (r"오더(?:를)?\s*(?=받)", "지시 "), # Konglish
|
||||||
|
(r"원 ?서클\s*(?=돌)", "한 바퀴 "), (r"\bwait\s*(?:하고|해서)", "기다리고"),
|
||||||
|
(r"\b((?:give|hand|take|bring|send) (?:it|this|that) |go |head |come )too\b", r"\1to"), # whisper's "too"
|
||||||
|
(r"웨이트\s*(?:하고|해서|했다가)", "기다리고"), (r"웨이트\s*해\S*", "기다려"),
|
||||||
|
(r"(?<=[가-힣a-z0-9_])(에|로|으로)\s*고\s*해서", r"\1 가서"), (r"들렀다가|들렀다 ?(?=와)", "갔다가"),
|
||||||
(r"돌아오(?:세요|십시오)", "돌아와"), (r"(?:이리로|여기로|이쪽으로)\s*돌아와", "돌아와"),
|
(r"돌아오(?:세요|십시오)", "돌아와"), (r"(?:이리로|여기로|이쪽으로)\s*돌아와", "돌아와"),
|
||||||
]
|
]
|
||||||
_AFTER_KO = {"간": "가고", "온": "오고", "집은": "집고", "잡은": "잡고", "든": "들고", "받은": "받고", "준": "주고", "놓은": "놓고",
|
_AFTER_KO = {"간": "가고", "온": "오고", "집은": "집고", "잡은": "잡고", "든": "들고", "받은": "받고", "준": "주고", "놓은": "놓고",
|
||||||
@@ -89,7 +99,7 @@ _HON_KO = [("가셔서", "가서"), ("가시고", "가고"), ("가셨다가", "
|
|||||||
# ---------- one clause -> one step ----------
|
# ---------- one clause -> one step ----------
|
||||||
def _place(word, markers):
|
def _place(word, markers):
|
||||||
"""A place word in a go clause -> marker name, "here", or None (not on the map)."""
|
"""A place word in a go clause -> marker name, "here", or None (not on the map)."""
|
||||||
word = re.sub(r"(?<=\S) (?:point|marker)$|\s*(?:앞|옆|근처|쪽|포인트|지점)$", "", word.strip()) # "the final point", "p5 앞"
|
word = re.sub(r"(?<=\S) (?:point|marker)$|\s*(?:앞|옆|근처|쪽|포인트|지점|위치|포지션|자리)$", "", word.strip()) # "the final point", "p5 앞"
|
||||||
w = re.sub(r"^(?:either |the |your |my |point |marker |포인트 ?)", "", word)
|
w = re.sub(r"^(?:either |the |your |my |point |marker |포인트 ?)", "", word)
|
||||||
exact = next((mk for mk in markers if wording._key(mk) == wording._key(w)), None) # "coffee_corner", "부스 3"
|
exact = next((mk for mk in markers if wording._key(mk) == wording._key(w)), None) # "coffee_corner", "부스 3"
|
||||||
if exact:
|
if exact:
|
||||||
@@ -294,12 +304,17 @@ def _give(c):
|
|||||||
if re.fullmatch(rf"(?:give|hand) (?:it|that|this|the (?:(?:{COL}) )?(?:{OBJ})s?)?(?: over)?"
|
if re.fullmatch(rf"(?:give|hand) (?:it|that|this|the (?:(?:{COL}) )?(?:{OBJ})s?)?(?: over)?"
|
||||||
rf"(?: to (?:me|you|{_PEOPLE}|the person there|whoever is(?: there)?|anyone(?: there)?|anybody(?: there)?|"
|
rf"(?: to (?:me|you|{_PEOPLE}|the person there|whoever is(?: there)?|anyone(?: there)?|anybody(?: there)?|"
|
||||||
rf"the (?:first )?(?:person|one) you (?:see|meet)))?(?: there)?"
|
rf"the (?:first )?(?:person|one) you (?:see|meet)))?(?: there)?"
|
||||||
r"|wait (?:there )?(?:until|till) (?:someone|somebody|anyone|they|he|she) takes? it(?: from you)?"
|
rf"|wait (?:there )?(?:until|till) (?:someone|somebody|anyone|they|he|she) (?:takes?|comes? (?:and|to) (?:take|get)s?) "
|
||||||
|
rf"(?:it|the (?:(?:{COL}) )?(?:{OBJ})s?)(?: from you)?"
|
||||||
|
r"|(?:누가|누군가|사람이|손님이|그 사람이|그분이)\s*(?:(?:그거|그걸|컵을?|이거)\s*)?(?:가져갈|받을|가지러 올|찾으러 올)\s*때까지\s*"
|
||||||
|
r"(?:기다려|기다리고|기다렸다가|대기해|있어)"
|
||||||
r"|hand it over|(?:give|hand) it", c) or \
|
r"|hand it over|(?:give|hand) it", c) or \
|
||||||
re.fullmatch(rf"(?:그거|그것을?|(?:(?:{COL})\s*)?(?:{OBJ})(?:을|를)?)?\s*(?:줘|주고|주세요|건네 ?줘|건네주고|"
|
re.fullmatch(rf"(?:그거|그것을?|(?:(?:{COL})\s*)?(?:{OBJ})(?:을|를)?)?\s*(?:줘|주고|주세요|건네 ?줘|건네주고|"
|
||||||
rf"건네 ?주세요|건네|전해 ?줘|전해 ?주고|전해 ?주세요|전해)", c):
|
rf"건네 ?주세요|건네|전해 ?줘|전해 ?주고|전해 ?주세요|전해)", c):
|
||||||
return {"do": "give"}
|
return {"do": "give"}
|
||||||
if re.fullmatch(r"(?:거기 (?:있는|계신)\s*)?(?:나한테|저한테|나에게|저에게|그 사람한테|사람한테|그분께|분께|분한테)\s*"
|
if re.fullmatch(r"(?:나|저) (?:줘|주세요|주고)", c) or \
|
||||||
|
re.fullmatch(r"(?:(?:그거|그걸|이거|이걸)\s+)?(?:거기 (?:있는|계신)\s*)?(?:나한테|저한테|나에게|저에게|(?:그|저|이) ?사람(?:한테|에게)|사람한테|"
|
||||||
|
r"(?:그|저|이) ?분(?:께|한테)|분께|분한테)\s*"
|
||||||
rf"(?:(?:이거|그거|이것|그것|이걸|그걸|(?:(?:이|그)\s*)?(?:{OBJ})(?:을|를)?)\s*)?"
|
rf"(?:(?:이거|그거|이것|그것|이걸|그걸|(?:(?:이|그)\s*)?(?:{OBJ})(?:을|를)?)\s*)?"
|
||||||
r"(?:줘|주고|주세요|건네|건네줘|건네주고|건네주세요|건네 ?줘|건네 ?주세요|드려|드리고|갖다 ?줘|갖다 ?주세요)", c) or \
|
r"(?:줘|주고|주세요|건네|건네줘|건네주고|건네주세요|건네 ?줘|건네 ?주세요|드려|드리고|갖다 ?줘|갖다 ?주세요)", c) or \
|
||||||
re.fullmatch(r"(?:이|그|저|두|세|네) ?분(?:께|한테|에게)\s*(?:줘|주고|드려|드리고|건네|건네 ?줘|건네 ?드려)", c):
|
re.fullmatch(r"(?:이|그|저|두|세|네) ?분(?:께|한테|에게)\s*(?:줘|주고|드려|드리고|건네|건네 ?줘|건네 ?드려)", c):
|
||||||
@@ -407,12 +422,12 @@ def _wait(c, markers, after):
|
|||||||
m = re.fullmatch(rf"(?:(.+?)에서\s*)?(?:(\d+(?:\.\d+)?) s\s*(?:동안|정도|만)?\s*)?{_KO_GIVER}\s*(?:({COL})\s*)?({OBJ}|물건|뭔가|무언가|그거|뭐|무엇을|뭘|이거)?\s*"
|
m = re.fullmatch(rf"(?:(.+?)에서\s*)?(?:(\d+(?:\.\d+)?) s\s*(?:동안|정도|만)?\s*)?{_KO_GIVER}\s*(?:({COL})\s*)?({OBJ}|물건|뭔가|무언가|그거|뭐|무엇을|뭘|이거)?\s*"
|
||||||
r"(?:을|를)?\s*(?:주면|건네주면|건네면|갖다주면|가져다주면|가져다 주면|줄 때까지|건네줄 때까지|줄 거야|"
|
r"(?:을|를)?\s*(?:주면|건네주면|건네면|갖다주면|가져다주면|가져다 주면|줄 때까지|건네줄 때까지|줄 거야|"
|
||||||
r"줄 거예요|가져올 거야)\s*(?:기다렸다가|기다려서|기다리고|기다려|기다려요)?\s*"
|
r"줄 거예요|가져올 거야)\s*(?:기다렸다가|기다려서|기다리고|기다려|기다려요)?\s*"
|
||||||
r"(받아서|받아|받고|받아와|받아 와|받아요)?", c)
|
r"(받아서|받아 ?가지고 ?와|받아 ?가지고|받아|받고|받아와|받아 와|받아요)?", c)
|
||||||
if m and (m.group(1) is None or _at_place(m.group(1), markers)):
|
if m and (m.group(1) is None or _at_place(m.group(1), markers)):
|
||||||
obj = brain.OBJECTS.get(m.group(4) or "")
|
obj = brain.OBJECTS.get(m.group(4) or "")
|
||||||
return ([{"do": "go", "to": _at_place(m.group(1), markers)}] if m.group(1) else []) + \
|
return ([{"do": "go", "to": _at_place(m.group(1), markers)}] if m.group(1) else []) + \
|
||||||
[{"do": "receive", "object": obj, "wait_s": float(m.group(2)) if m.group(2) else WAIT_GIVE_S}] + \
|
[{"do": "receive", "object": obj, "wait_s": float(m.group(2)) if m.group(2) else WAIT_GIVE_S}] + \
|
||||||
([{"do": "go", "to": "here"}] if m.group(5) in ("받아 와", "받아와") else [])
|
([{"do": "go", "to": "here"}] if re.fullmatch(r"받아 ?(?:가지고 ?)?와", m.group(5) or "") else [])
|
||||||
if after and re.fullmatch(r"(?:거기|여기)(?:서|에서)", c):
|
if after and re.fullmatch(r"(?:거기|여기)(?:서|에서)", c):
|
||||||
return [] # "p3로 가서 | 거기서 | 기다려": the place of the next step
|
return [] # "p3로 가서 | 거기서 | 기다려": the place of the next step
|
||||||
if after and after["do"] == "receive" and after.get("wait_s") and re.fullmatch(r"받아서|받아|받고|받아 와|받아와|받아요", c):
|
if after and after["do"] == "receive" and after.get("wait_s") and re.fullmatch(r"받아서|받아|받고|받아 와|받아와|받아요", c):
|
||||||
@@ -461,10 +476,10 @@ def _wait(c, markers, after):
|
|||||||
|
|
||||||
|
|
||||||
_POLITE = re.compile(r"(?<=[가-힣])\s*(?:주십시오|주시겠어요|주시겠습니까|주실 수 있나요|주실 수 있습니까|주실 수 있어요|"
|
_POLITE = re.compile(r"(?<=[가-힣])\s*(?:주십시오|주시겠어요|주시겠습니까|주실 수 있나요|주실 수 있습니까|주실 수 있어요|"
|
||||||
r"줄 수 있어요|줄 수 있어|주실래요|줄래요?|줘 ?봐요?|줘요?|주세요|죠)\??$") # every speech level
|
r"줄 수 있어요|줄 수 있어|주실래요|줄래요?|줘 ?봐요?|줘요?|주세요|주라|죠)\??$") # every speech level
|
||||||
_HONORIFIC = [(r"(가|와|놔|돌아|집어|잡어|잡아|들어|줘) ?봐요?$", r"\1"), # "가봐", "놔 봐": try / do it
|
_HONORIFIC = [(r"(가|와|놔|돌아|집어|잡어|잡아|들어|줘) ?봐요?$", r"\1"), # "가봐", "놔 봐": try / do it
|
||||||
(r"(?<=[가-힣]) ?주시고$", "고"), (r"(?<=[가-힣]) ?주셔서$", "서"), # "가 주시고": 가고
|
(r"(?<=[가-힣]) ?주시고$", "고"), (r"(?<=[가-힣]) ?주셔서$", "서"), # "가 주시고": 가고
|
||||||
(r"가(?:십시오|세요|시죠|요)$", "가"), (r"오(?:십시오|세요|시죠)$", "와"), (r"도(?:십시오|세요)$", "돌아"),
|
(r"가(?:십시오|세요|시죠|요)$", "가"), (r"((?:으로|로|에) )가게나?$", r"\1가"), (r"오(?:십시오|세요|시죠)$", "와"), (r"도(?:십시오|세요)$", "돌아"),
|
||||||
(r"드리(?:십시오|세요)$", "드려"), (r"(?:주|드리)십시오$", "줘"), (r"물러나(?:세요|십시오|요)?$", "가"),
|
(r"드리(?:십시오|세요)$", "드려"), (r"(?:주|드리)십시오$", "줘"), (r"물러나(?:세요|십시오|요)?$", "가"),
|
||||||
(r"회전(?:해|하세요|하십시오|해요)$", "돌아"), (r"말씀(?:해|하세요|하십시오|해요|해 주세요)$", "말해"),
|
(r"회전(?:해|하세요|하십시오|해요)$", "돌아"), (r"말씀(?:해|하세요|하십시오|해요|해 주세요)$", "말해"),
|
||||||
(r"놓으(?:십시오|세요)$", "놔"), (r"기다리(?:십시오|세요|시죠|셔요)$", "기다려"),
|
(r"놓으(?:십시오|세요)$", "놔"), (r"기다리(?:십시오|세요|시죠|셔요)$", "기다려"),
|
||||||
@@ -684,9 +699,10 @@ def _clause(c, markers, after=None):
|
|||||||
|
|
||||||
def _clause_steps(c, markers, after=None):
|
def _clause_steps(c, markers, after=None):
|
||||||
c = re.sub(r"^(?:second(?:ly)?|third(?:ly)?|fourth|first(?:ly)?|last(?:ly)?|step \d)[\s,]+", "", c.strip(" .!?")) # "second, go to ..."
|
c = re.sub(r"^(?:second(?:ly)?|third(?:ly)?|fourth|first(?:ly)?|last(?:ly)?|step \d)[\s,]+", "", c.strip(" .!?")) # "second, go to ..."
|
||||||
c = re.sub(rf"^(?:{_FILL}[\s,]+)+|(?:[\s,]+{_FILL})+$", "", c).strip(" .!?,")
|
c = re.sub(rf"^(?:{_FILL}(?:[\s,]+|$))+|(?:[\s,]+{_FILL})+$", "", c).strip(" .!?,")
|
||||||
if re.search(r"[가-힣]", c):
|
if re.search(r"[가-힣]", c):
|
||||||
c = re.sub(r"\s+", " ", c)
|
c = re.sub(r"\s+", " ", wording.ko_plain(c)).strip(" .!?~") # every speech level / dialect as 반말: "돌아오게나",
|
||||||
|
c = re.sub(rf"^(?:{_FILL}(?:[\s,]+|$))+|(?:[\s,]+{_FILL})+$", "", c).strip(" .!?,~") # "가 주시겄슈" -> "돌아와", "가 줘"
|
||||||
c = re.sub(r"\s좀\s", " ", c)
|
c = re.sub(r"\s좀\s", " ", c)
|
||||||
c = re.sub(r"^(?:야\s+)?로봇(?:아|야)?[,\s]+|^야[,\s]+(?!로봇)", "", c) # "야 로봇", "로봇아", "야": calling it
|
c = re.sub(r"^(?:야\s+)?로봇(?:아|야)?[,\s]+|^야[,\s]+(?!로봇)", "", c) # "야 로봇", "로봇아", "야": calling it
|
||||||
c = c.replace("그리퍼를", "손을").replace("물러나", "뒤로 물러나") if "뒤로" not in c else c.replace("그리퍼를", "손을")
|
c = c.replace("그리퍼를", "손을").replace("물러나", "뒤로 물러나") if "뒤로" not in c else c.replace("그리퍼를", "손을")
|
||||||
@@ -705,7 +721,7 @@ def _clause_steps(c, markers, after=None):
|
|||||||
c = re.sub(r"^\S+ 말고\s+", "", c) # "미나 말고 사라한테": not Mina, Sara
|
c = re.sub(r"^\S+ 말고\s+", "", c) # "미나 말고 사라한테": not Mina, Sara
|
||||||
c = re.sub(r"^\S+ (?:없으니까|없어서|없대서)\s+", "", c) # "현우 없으니까 ...": the reason, not a step
|
c = re.sub(r"^\S+ (?:없으니까|없어서|없대서)\s+", "", c) # "현우 없으니까 ...": the reason, not a step
|
||||||
c = re.sub(r"\s+(?:거기로|내가) 갈게$", "", c)
|
c = re.sub(r"\s+(?:거기로|내가) 갈게$", "", c)
|
||||||
c = re.sub(r"(?<=[a-z0-9가-힣]) (?:하고|해서|하고서|하고 나서|한 다음에?)$", "", c) # "turn left 하고 p2로 가",
|
c = re.sub(r"(?<=[a-z0-9가-힣])(?<!거)(?<!것)(?<!대로) (?:하고|해서|하고서|하고 나서|한 다음에?)$", "", c) # "turn left 하고 p2로 가",
|
||||||
# "go to 입구 하고"
|
# "go to 입구 하고"
|
||||||
raw, c = c, _sender(c)
|
raw, c = c, _sender(c)
|
||||||
if not c:
|
if not c:
|
||||||
@@ -735,7 +751,8 @@ def _clause_steps(c, markers, after=None):
|
|||||||
c = re.sub(r"\bstraight ahead\b", "forward", c)
|
c = re.sub(r"\bstraight ahead\b", "forward", c)
|
||||||
c = re.sub(r"\bthe gripper\b", "your hand", c)
|
c = re.sub(r"\bthe gripper\b", "your hand", c)
|
||||||
c = c.replace("그리퍼", "손")
|
c = c.replace("그리퍼", "손")
|
||||||
m = re.fullmatch(r"(.+?)에 있는 (?:사람|분|손님)(?:한테|에게|께)\s*(?:갖다|가져다|건네) ?(?:줘|주고|주세요)?", c)
|
m = re.fullmatch(r"(.+?)에 (?:있는|계신) (?:사람|분|손님)(?:한테|에게|께)\s*(?:(?:갖다|가져다|건네) ?(?:줘|주고|주세요|드려|드리고)?|"
|
||||||
|
r"줘|주고|드려|드리고)", c)
|
||||||
if m:
|
if m:
|
||||||
to = _places(m.group(1), markers)
|
to = _places(m.group(1), markers)
|
||||||
return to and len(to) == 1 and [{"do": "go", "to": to[0]}, {"do": "give"}] or None
|
return to and len(to) == 1 and [{"do": "go", "to": to[0]}, {"do": "give"}] or None
|
||||||
@@ -743,6 +760,8 @@ def _clause_steps(c, markers, after=None):
|
|||||||
if m and c != raw:
|
if m and c != raw:
|
||||||
obj, col = _thing(m.group(1), m.group(2))
|
obj, col = _thing(m.group(1), m.group(2))
|
||||||
return [{"do": "pick", "object": obj, "colour": col}]
|
return [{"do": "pick", "object": obj, "colour": col}]
|
||||||
|
if after and after["do"] in ("pick", "receive") and re.fullmatch(r"(?:여기로\s*)?(?:(?:받아|집어) ?)?(?:가져와|가지고 ?와|갖고 ?와)", c):
|
||||||
|
return [{"do": "go", "to": "here"}] # "민수한테 컵 받아서 가져와": as "bring it here"
|
||||||
if c in ("bring it back to me", "bring it to me", "bring it back") or \
|
if c in ("bring it back to me", "bring it to me", "bring it back") or \
|
||||||
re.fullmatch(r"(?:나한테|저한테|나에게|저에게)\s*(?:가져와|가져다 ?줘|가져와서|가져다 ?주고|가져다|갖다 ?줘|갖다)"
|
re.fullmatch(r"(?:나한테|저한테|나에게|저에게)\s*(?:가져와|가져다 ?줘|가져와서|가져다 ?주고|가져다|갖다 ?줘|갖다)"
|
||||||
r"(?:요| ?주세요)?", c):
|
r"(?:요| ?주세요)?", c):
|
||||||
@@ -769,10 +788,83 @@ def _clause_steps(c, markers, after=None):
|
|||||||
if hand and hand[0] == "receive" and not (after and re.match(r"(?:just )?(?:hold|keep)\b|.*들고 ?있", c)) \
|
if hand and hand[0] == "receive" and not (after and re.match(r"(?:just )?(?:hold|keep)\b|.*들고 ?있", c)) \
|
||||||
and not re.search(r"누가|누군가|someone|somebody|something|anything|things|주면|gives?\b", c):
|
and not re.search(r"누가|누군가|someone|somebody|something|anything|things|주면|gives?\b", c):
|
||||||
return [{"do": "receive", "object": hand[1], "from_hand": True}] # "take this from me", "이거 받아": from the person's hand
|
return [{"do": "receive", "object": hand[1], "from_hand": True}] # "take this from me", "이거 받아": from the person's hand
|
||||||
|
m = re.fullmatch(rf"(?:find|look for|search for|locate|look around for) (?:the |a |an |my )?(?:({COL}) )?({OBJ})s?|"
|
||||||
|
rf"(?:(?:{COL})\s*)?(?:{OBJ})\s*(?:을|를)?\s*찾(?:아서|고|아 ?가지고)", c)
|
||||||
|
if m: # "find the red cup and bring it to me": the pick looks around
|
||||||
|
t = re.search(rf"(?:({COL})\s*)?({OBJ})", c)
|
||||||
|
obj, col = _thing(t.group(1), t.group(2))
|
||||||
|
return [{"do": "pick", "object": obj, "colour": col}]
|
||||||
|
m = re.fullmatch(r"(.+?)(?:으로|로|에) (?:가져가|가지고 가|갖고 가|들고 가)(?:서| 줘)?", c)
|
||||||
|
if m and (to := _places(m.group(1), markers)) and len(to) == 1:
|
||||||
|
return [{"do": "go", "to": to[0]}] # "피사로 가져가": as "take it to p4"
|
||||||
|
s = _place_at(c, markers) or _fetch_clause(c, markers)
|
||||||
|
if s:
|
||||||
|
return s
|
||||||
s = _place_step(c) or _say(c)
|
s = _place_step(c) or _say(c)
|
||||||
return [s] if s else None
|
return [s] if s else None
|
||||||
|
|
||||||
|
|
||||||
|
_PUT_KO = r"(?:놔|놓아|놓고|내려놔|내려 ?놓고|둬|두고|놔두고|놔둬|올려 ?놔|올려 ?놓고)"
|
||||||
|
_GIVE_AT_KO = r"(?:갖다 ?주고|갖다 ?줘|가져다 ?주고|가져다 ?줘|갖다 ?드리고|갖다 ?드려|전해 ?주고|전해 ?줘|배달해 ?주고|배달해)"
|
||||||
|
|
||||||
|
|
||||||
|
def _place_at(c, markers):
|
||||||
|
""""put it on p3", "deliver the cup to p5", "컵을 p5에 갖다 놓고", "p3에 갖다 줘": (the named thing picked here,) a
|
||||||
|
drive there, then put down (put / leave / 놔) or handed over (deliver / 갖다 줘). None otherwise."""
|
||||||
|
m = re.fullmatch(rf"(put|place|set|leave|drop|deliver|drop off) (?:it|that|this|the ((?:(?:{COL}) )?(?:{OBJ}))s?)"
|
||||||
|
r"(?: down| off)? (?:on|at|in|to) (?:the )?(.+?)", c)
|
||||||
|
if m:
|
||||||
|
verb, thing, where = m.groups()
|
||||||
|
else:
|
||||||
|
m = re.fullmatch(rf"(?:(?:이거|그거|이걸|그걸|((?:(?:{COL})\s*)?(?:{OBJ}))(?:을|를)?)\s+)?(.+?)(?:에다가?|에|로|으로) "
|
||||||
|
rf"(?:(갖다|가져다|가져가서) ?)?({_PUT_KO}|{_GIVE_AT_KO})(?: 줘| 주고)?", c)
|
||||||
|
if not m or (m.group(4) in ("갖다 줘", "갖다줘", "가져다 줘", "가져다줘") and not m.group(1)):
|
||||||
|
return None # "p3에 갖다 줘" alone: a fetch / give, not this
|
||||||
|
thing, where = m.group(1), m.group(2)
|
||||||
|
verb = "put" if re.fullmatch(_PUT_KO, m.group(4)) else "deliver"
|
||||||
|
to = _places(where, markers)
|
||||||
|
if not to or len(to) != 1 or to == ["here"]:
|
||||||
|
return None
|
||||||
|
pick = []
|
||||||
|
if thing:
|
||||||
|
t = re.fullmatch(rf"(?:({COL})\s*)?({OBJ})", thing.strip())
|
||||||
|
obj, col = _thing(t.group(1), t.group(2))
|
||||||
|
pick = [{"do": "pick", "object": obj, "colour": col}]
|
||||||
|
return pick + [{"do": "go", "to": to[0]}, {"do": "give"} if verb == "deliver" else {"do": "place", "on": None}]
|
||||||
|
|
||||||
|
|
||||||
|
_FETCH_VERB = re.compile(r"\b(?:bring|fetch|get|carry|move)\b|가져|갖다|가지고|갖고|옮겨")
|
||||||
|
|
||||||
|
|
||||||
|
def _fetch_clause(c, markers):
|
||||||
|
"""A whole fetch said as one part of several ("bring me the cup from p2 and then go home", "p1에서 병 가져다 p2에
|
||||||
|
놔 주고 ..."): brain.parse_fetch's reading as steps, only when it names the object and every place it names."""
|
||||||
|
if not _FETCH_VERB.search(c) or brain.not_an_order(c, asked=True) or not (
|
||||||
|
re.match(r"(?:(?:please|just|go and|go) )?(?:bring|fetch|get|carry|move|take|grab)\b", c) or
|
||||||
|
re.search(r"(?:가져와|가져와서|가져다 ?(?:줘|주고|놔|놓고)?|가져다가|갖다 ?(?:줘|주고|놔|놓고)|갖다가|가지고 ?와(?:서)?|"
|
||||||
|
r"갖고 ?와(?:서)?|챙겨 ?와(?:서)?|옮겨(?: ?줘| ?주고| ?와| ?놔)?|들고 ?와(?:서)?|주시고|(?<!갖)(?<!가지)고)$", c)):
|
||||||
|
return None # an order said now, not "did you bring ...", "I'll bring ..."
|
||||||
|
c = re.sub(r"(?<=[가-힣]) ?고$", " 주고", c) if re.search(r"(?:갖다|가져다)고$", c) else c # "가져다 주시고" (_HONORIFIC)
|
||||||
|
task, problems = brain.parse_fetch(c, markers)
|
||||||
|
src, dest = task["source"], task["dest"]
|
||||||
|
if problems == ["dest"] and isinstance(src, dict) and re.search(r"(?:다가|서|고)$", c):
|
||||||
|
return [{"do": "go", "to": src["marker"]}, {"do": "pick", "object": task["object"], "colour": task["colour"],
|
||||||
|
**({"prefer": task["prefer"]} if task.get("prefer") else {})}] # "p1에서 컵 가져다가 | p3에 놔"
|
||||||
|
if problems or src == "here" and dest == "here":
|
||||||
|
return None
|
||||||
|
out = [{"do": "go", "to": src["marker"]}] if isinstance(src, dict) else []
|
||||||
|
out.append({"do": "pick", "object": task["object"], "colour": task["colour"],
|
||||||
|
**({"prefer": task["prefer"]} if task.get("prefer") else {})})
|
||||||
|
out.append({"do": "go", "to": dest["marker"] if isinstance(dest, dict) else "here"} |
|
||||||
|
({"implied": True} if dest == "here" and re.search(r"(?:와서|다가|가지고|갖고)$", c) else {})) # "가져와서 | p6로": no
|
||||||
|
# trip back first
|
||||||
|
if task["finish"] == "place":
|
||||||
|
out.append({"do": "place", "on": None})
|
||||||
|
elif dest == "here" and not re.search(r"(?:와서|다가|가지고|갖고)$", c): # "가져와서 | p3에 있는 사람한테 줘"
|
||||||
|
out.append({"do": "give", "fetch_give": True}) # handed over only when more follows (rules); the plain fetch
|
||||||
|
return out # holds it here
|
||||||
|
|
||||||
|
|
||||||
# ---------- whole commands ----------
|
# ---------- whole commands ----------
|
||||||
_STEP_VERB = (r"(?:go|come|drive|head|return|give|hand|put|place|set|leave|take|pick|grab|get|bring|carry|turn|move|"
|
_STEP_VERB = (r"(?:go|come|drive|head|return|give|hand|put|place|set|leave|take|pick|grab|get|bring|carry|turn|move|"
|
||||||
r"wait|hold|keep|open|close|reach|fold|receive|ask|find|look for)\b")
|
r"wait|hold|keep|open|close|reach|fold|receive|ask|find|look for)\b")
|
||||||
@@ -801,8 +893,9 @@ def _split(t, markers=()):
|
|||||||
for part in _SPLIT.split(t):
|
for part in _SPLIT.split(t):
|
||||||
pieces = []
|
pieces = []
|
||||||
for p in _SPLIT_KO.split(part):
|
for p in _SPLIT_KO.split(part):
|
||||||
if pieces and ends and re.search(rf"(?<![가-힣])(?:{'|'.join(ends)})$", pieces[-1]):
|
if pieces and ends and re.search(rf"(?<![가-힣])(?:{'|'.join(ends)})$", pieces[-1]) or \
|
||||||
pieces[-1] += " " + p
|
pieces and re.search(r"(?:갖고|가지고)$", pieces[-1]) and re.match(r"(?:와|오)", p):
|
||||||
|
pieces[-1] += " " + p # "갖고 와": one verb (bring), not "take it | come"
|
||||||
else:
|
else:
|
||||||
pieces.append(p)
|
pieces.append(p)
|
||||||
out += [p for p in pieces if p.strip()]
|
out += [p for p in pieces if p.strip()]
|
||||||
@@ -851,6 +944,11 @@ def _pieces(c, markers, after):
|
|||||||
def rules(text, markers=()):
|
def rules(text, markers=()):
|
||||||
"""(steps, unread clauses). Steps are merged where two clauses mean one ("look for the table" + "put it there")."""
|
"""(steps, unread clauses). Steps are merged where two clauses mean one ("look for the table" + "put it there")."""
|
||||||
text = re.sub(r"(?<=[가-힣A-Za-z0-9])(으로|로|에)(가서|가고|가면)(?=[가-힣])", r"\1 \2 ", text or "") # written without
|
text = re.sub(r"(?<=[가-힣A-Za-z0-9])(으로|로|에)(가서|가고|가면)(?=[가-힣])", r"\1 \2 ", text or "") # written without
|
||||||
|
if re.search(r"[가-힣]{9,}", text): # Korean written without spaces: "피사에가서5분있다가다시오세요"
|
||||||
|
text = re.sub(r"(실례지만|죄송한데요|가서|와서|돌고|있다가|기다렸다가|기다리고|갔다가|하고|해서|집어서|잡아서|집고|잡고|들고|"
|
||||||
|
r"받아서|받고|다시)(?=[가-힣\d])|(?<=[가-힣\d]에)(?=있는|계신)|(?<=있는|계신)(?=[가-힣])", r"\1 ", text)
|
||||||
|
text = re.sub(r"(?<=[가-힣])(?=\d)|(?<=\d[초분])(?=[가-힣])|(?<=다시)(?=[와오])|(?<=[아어와여해])(?=주(?:세요|시|라|십|실|게))",
|
||||||
|
" ", text)
|
||||||
cut, says = _cut_says(text) # spaces: "부스A로가서저희"
|
cut, says = _cut_says(text) # spaces: "부스A로가서저희"
|
||||||
t = _protect_lists(_norm(cut, markers), markers)
|
t = _protect_lists(_norm(cut, markers), markers)
|
||||||
t = _INTERJECTION.sub("", t)
|
t = _INTERJECTION.sub("", t)
|
||||||
@@ -889,6 +987,8 @@ def rules(text, markers=()):
|
|||||||
steps.append(s)
|
steps.append(s)
|
||||||
steps = [s for i, s in enumerate(steps) # "bring it" then a place to go: no trip back first
|
steps = [s for i, s in enumerate(steps) # "bring it" then a place to go: no trip back first
|
||||||
if not (s.pop("implied", False) and i + 1 < len(steps) and steps[i + 1]["do"] == "go")]
|
if not (s.pop("implied", False) and i + 1 < len(steps) and steps[i + 1]["do"] == "go")]
|
||||||
|
steps = [s for i, s in enumerate(steps) if not (s.pop("fetch_give", False) and
|
||||||
|
(i == len(steps) - 1 or steps[i + 1]["do"] in ("wait", "place")))]
|
||||||
steps, unread = _people(steps, unread, text)
|
steps, unread = _people(steps, unread, text)
|
||||||
if steps and not unread and all(s["do"] == "wait" for s in steps):
|
if steps and not unread and all(s["do"] == "wait" for s in steps):
|
||||||
return [], [text.strip()] # "hold on a second", "wait here": talk to me, not a task
|
return [], [text.strip()] # "hold on a second", "wait here": talk to me, not a task
|
||||||
|
|||||||
@@ -29,11 +29,11 @@ LOUDER = re.compile(r"\blouder\b|\bspeak up\b|\b(?:can'?t|cannot|can not|couldn'
|
|||||||
r"(?:소리|목소리)\S*\s*너무\s*작", re.I)
|
r"(?:소리|목소리)\S*\s*너무\s*작", re.I)
|
||||||
QUIETER = re.compile(r"\bquieter\b|\bsofter\b|\btoo loud\b|\bnot so loud\b|\bless loud\b|\bso loud\b|"
|
QUIETER = re.compile(r"\bquieter\b|\bsofter\b|\btoo loud\b|\bnot so loud\b|\bless loud\b|\bso loud\b|"
|
||||||
r"\b(?:lower|turn down|drop) (?:your |the )?(?:voice|volume|sound)\b|\b(?:volume|sound) down\b|"
|
r"\b(?:lower|turn down|drop) (?:your |the )?(?:voice|volume|sound)\b|\b(?:volume|sound) down\b|"
|
||||||
r"\bturn (?:it |yourself )?down\b|\b(?:speak|talk) (?:more )?(?:quietly|softly)\b|"
|
r"\bturn (?:it |yourself )?down\b|\btone (?:it |yourself )?down\b|\b(?:speak|talk) (?:more )?(?:quietly|softly)\b|"
|
||||||
r"작게|시끄러|(?:소리|볼륨|목소리)\s*(?:를|을|좀|\s)*(?:줄여|낮춰|내려)|(?:소리|목소리)\S*\s*너무\s*커", re.I)
|
r"작게|조용조용|조곤조곤|소곤소곤|시끄러|(?:소리|볼륨|목소리)\s*(?:를|을|좀|\s)*(?:줄여|낮춰|내려)|(?:소리|목소리)\S*\s*너무\s*커", re.I)
|
||||||
VOICE = re.compile(r"\b(?:speak|speaking|talk|talking|say|saying|said|voice|speech|words)\b|말|얘기|이야기|목소리", re.I)
|
VOICE = re.compile(r"\b(?:speak|speaking|talk|talking|say|saying|said|voice|speech|words)\b|말|얘기|이야기|목소리", re.I)
|
||||||
SLOW = re.compile(r"\b(?:slower|slowly|slow down)\b|천천히|느리게|느릿", re.I)
|
SLOW = re.compile(r"\b(?:slower|slowly|slow down)\b|천천히|느리게|느릿|슬로우하게|슬로우리", re.I)
|
||||||
FAST = re.compile(r"\b(?:faster|quicker|quickly|speed up)\b|빨리|빠르게", re.I)
|
FAST = re.compile(r"\b(?:faster|quicker|quickly|speed up)\b|빨리|빠르게|패스트하게|퀵하게", re.I)
|
||||||
TOO_FAST = re.compile(r"\b(?:too|so) fast\b|(?:너무|넘)\s*빨라|빠르네|빨라요", re.I)
|
TOO_FAST = re.compile(r"\b(?:too|so) fast\b|(?:너무|넘)\s*빨라|빠르네|빨라요", re.I)
|
||||||
TOO_SLOW = re.compile(r"\b(?:too|so) slow(?:ly)?\b|(?:너무|넘)\s*느려|느리네|느려요", re.I)
|
TOO_SLOW = re.compile(r"\b(?:too|so) slow(?:ly)?\b|(?:너무|넘)\s*느려|느리네|느려요", re.I)
|
||||||
DRIVE = re.compile(r"\b(?:go|going|drive|driving|move|moving|walk|come|run|follow|forward)\b|"
|
DRIVE = re.compile(r"\b(?:go|going|drive|driving|move|moving|walk|come|run|follow|forward)\b|"
|
||||||
|
|||||||
+44
-9
@@ -20,7 +20,10 @@ EN_NUM = {"one": 1, "two": 2, "three": 3, "four": 4, "five": 5, "six": 6, "seven
|
|||||||
"ten": 10, "eleven": 11, "twelve": 12}
|
"ten": 10, "eleven": 11, "twelve": 12}
|
||||||
KO_EN_NUM = {"원": 1, "투": 2, "쓰리": 3, "스리": 3, "뜨리": 3, "트리": 3, "포": 4, "파이브": 5, "화이브": 5,
|
KO_EN_NUM = {"원": 1, "투": 2, "쓰리": 3, "스리": 3, "뜨리": 3, "트리": 3, "포": 4, "파이브": 5, "화이브": 5,
|
||||||
"식스": 6, "씩스": 6, "세븐": 7, "쎄븐": 7, "에잇": 8, "에이트": 8, "나인": 9, "텐": 10, "일레븐": 11,
|
"식스": 6, "씩스": 6, "세븐": 7, "쎄븐": 7, "에잇": 8, "에이트": 8, "나인": 9, "텐": 10, "일레븐": 11,
|
||||||
"트웰브": 12} # English numbers said in Korean ("피쓰리", "포인트 원")
|
"트웰브": 12, "써틴": 13, "서틴": 13, "포틴": 14, "피프틴": 15, "휘프틴": 15, "식스틴": 16, "세븐틴": 17,
|
||||||
|
"에이틴": 18, "나인틴": 19} # English numbers said in Korean ("피쓰리", "포인트 원")
|
||||||
|
KO_EN_TENS = {"트웬티": 20, "트웨니": 20, "써티": 30, "서티": 30, "포티": 40, "피프티": 50, "휘프티": 50, "식스티": 60,
|
||||||
|
"세븐티": 70, "에이티": 80, "나인티": 90} # before a unit only (numbers): "에이티 센티"
|
||||||
NATIVE = {"한": 1, "두": 2, "세": 3, "네": 4, "다섯": 5, "여섯": 6, "일곱": 7, "여덟": 8, "아홉": 9, "열": 10}
|
NATIVE = {"한": 1, "두": 2, "세": 3, "네": 4, "다섯": 5, "여섯": 6, "일곱": 7, "여덟": 8, "아홉": 9, "열": 10}
|
||||||
SINO = {"일": 1, "이": 2, "삼": 3, "사": 4, "오": 5, "육": 6, "륙": 6, "칠": 7, "팔": 8, "구": 9}
|
SINO = {"일": 1, "이": 2, "삼": 3, "사": 4, "오": 5, "육": 6, "륙": 6, "칠": 7, "팔": 8, "구": 9}
|
||||||
_D = "[일이삼사오육륙칠팔구]"
|
_D = "[일이삼사오육륙칠팔구]"
|
||||||
@@ -112,6 +115,12 @@ def markers(t):
|
|||||||
def numbers(t):
|
def numbers(t):
|
||||||
"""Distances and angles in lower-case text -> digits and metres: "half a meter" -> "0.5 m", "오십 센치" -> "0.5 m",
|
"""Distances and angles in lower-case text -> digits and metres: "half a meter" -> "0.5 m", "오십 센치" -> "0.5 m",
|
||||||
"일 미터 반" -> "1.5 m", "구십 도" -> "90도"."""
|
"일 미터 반" -> "1.5 m", "구십 도" -> "90도"."""
|
||||||
|
t = re.sub(rf"(?<![가-힣])(?:({'|'.join(KO_EN_TENS)})\s?)?({'|'.join(sorted(KO_EN_NUM, key=len, reverse=True))})?"
|
||||||
|
rf"(?<=[가-힣])\s*(?=(?:{UNIT}|도|degrees?|디그리스?)(?![a-z가-힣]))",
|
||||||
|
lambda m: f"{KO_EN_TENS.get(m.group(1), 0) + KO_EN_NUM.get(m.group(2), 0)} "
|
||||||
|
if m.group(1) or m.group(2) else m.group(0), t)
|
||||||
|
# Konglish amounts: "텐 센치", "에이티 센티", "트웬티 파이브 도"
|
||||||
|
t = re.sub(r"(\d+)\s*디그리스?(?![가-힣])", r"\1도", t) # "피프틴 디그리"
|
||||||
t = re.sub(r"\bone and a half\b", "1.5", t)
|
t = re.sub(r"\bone and a half\b", "1.5", t)
|
||||||
t = re.sub(rf"\b({'|'.join(TENS)})(?:[ -]({'|'.join(list(EN_NUM)[:9])}))?\b",
|
t = re.sub(rf"\b({'|'.join(TENS)})(?:[ -]({'|'.join(list(EN_NUM)[:9])}))?\b",
|
||||||
lambda m: str(TENS[m.group(1)] + EN_NUM.get(m.group(2), 0)), t)
|
lambda m: str(TENS[m.group(1)] + EN_NUM.get(m.group(2), 0)), t)
|
||||||
@@ -122,7 +131,7 @@ def numbers(t):
|
|||||||
lambda m: str(1000 * _num(m.group(1)) if m.group(1) else 1000), t) # "a thousand", "five thousand"
|
lambda m: str(1000 * _num(m.group(1)) if m.group(1) else 1000), t) # "a thousand", "five thousand"
|
||||||
t = re.sub(rf"\b([2-9]|{'|'.join(list(EN_NUM)[1:9])}) hundred(?: and)?(?: (\d+))?\b",
|
t = re.sub(rf"\b([2-9]|{'|'.join(list(EN_NUM)[1:9])}) hundred(?: and)?(?: (\d+))?\b",
|
||||||
lambda m: str(100 * _num(m.group(1)) + int(m.group(2) or 0)), t) # "two hundred and fifty"
|
lambda m: str(100 * _num(m.group(1)) + int(m.group(2) or 0)), t) # "two hundred and fifty"
|
||||||
t = re.sub(rf"\b({'|'.join(TEEN)}|eleven|twelve)\b(?=\s*{UNIT}(?![a-z]))",
|
t = re.sub(rf"\b({'|'.join(TEEN)}|eleven|twelve)\b(?=\s*(?:{UNIT}(?![a-z])|degrees?\b|도(?![가-힣])))",
|
||||||
lambda m: str(TEEN.get(m.group(1)) or EN_NUM[m.group(1)]), t) # "fifteen centimetres"
|
lambda m: str(TEEN.get(m.group(1)) or EN_NUM[m.group(1)]), t) # "fifteen centimetres"
|
||||||
t = re.sub(r"\b(?:a|one) hundred(?: and)? (\d+)\b", lambda m: str(100 + int(m.group(1))), t)
|
t = re.sub(r"\b(?:a|one) hundred(?: and)? (\d+)\b", lambda m: str(100 + int(m.group(1))), t)
|
||||||
t = re.sub(r"\b(?:a|one) hundred\b", "100", t)
|
t = re.sub(r"\b(?:a|one) hundred\b", "100", t)
|
||||||
@@ -143,11 +152,16 @@ def numbers(t):
|
|||||||
t = re.sub(rf"(?:(?<=으로)|(?<=로))\s*({_SINO})\s*도(?![가-힣])", lambda m: f" {sino(m.group(1))}도", t)
|
t = re.sub(rf"(?:(?<=으로)|(?<=로))\s*({_SINO})\s*도(?![가-힣])", lambda m: f" {sino(m.group(1))}도", t)
|
||||||
t = re.sub(rf"(?<![가-힣\d])({_SINO})\s*도(?=\s+(?:왼쪽|오른쪽|뒤로|돌))", lambda m: f"{sino(m.group(1))}도", t)
|
t = re.sub(rf"(?<![가-힣\d])({_SINO})\s*도(?=\s+(?:왼쪽|오른쪽|뒤로|돌))", lambda m: f"{sino(m.group(1))}도", t)
|
||||||
t = re.sub(r"(\d+)\s*degrees?(?=\s*[가-힣])", r"\1도", t) # "왼쪽으로 45 degrees 돌아"
|
t = re.sub(r"(\d+)\s*degrees?(?=\s*[가-힣])", r"\1도", t) # "왼쪽으로 45 degrees 돌아"
|
||||||
|
t = re.sub(r"(?<![\d.])(\d+) 도(?=\s+(?:왼|오른|위|아래|밑|좌|우|뒤|돌|회전|틀|꺾))", r"\1도", t) # "고개를 90 도 오른쪽으로"
|
||||||
|
t = re.sub(rf"(?:^|(?<=으로)|(?<=[~,\s몸]))({_SINO})\s*도(?=\s*(?:왼|오른|좌|우|회전|돌|틀|꺾|만|쯤|정도|얼른|빨리|천천히|살짝|좀|퍼뜩|언능))",
|
||||||
|
lambda m: f"{sino(m.group(1))}도 ", t) # written together: "왼쪽으로십오도회전해"
|
||||||
|
t = re.sub(r"(?<![\d.])(\d+) ?(?:m|미터)\s?([1-9])0(?![\d.]|\s*(?:센|cm|밀|mm|미|m\b|도))(?=\s*(?:만|쯤|정도)?\s*(?:[가-힣]|$))",
|
||||||
|
lambda m: f"{m.group(1)}.{m.group(2)} m", t) # "1미터 50" is 1.5 m
|
||||||
t = re.sub(rf"\bhalf (?:a |an )?{UNIT}", "0.5 m", t)
|
t = re.sub(rf"\bhalf (?:a |an )?{UNIT}", "0.5 m", t)
|
||||||
t = re.sub(rf"반\s*{UNIT}", "0.5 m", t)
|
t = re.sub(rf"반\s*{UNIT}", "0.5 m", t)
|
||||||
for w, d in NUM_WORDS.items():
|
for w, d in NUM_WORDS.items():
|
||||||
if w.isascii():
|
if w.isascii():
|
||||||
t = re.sub(rf"\b{w}\b(?=\s*(?:{UNIT}(?![a-z])|degrees?|and a (?:half|0\.5)))", d, t) # "one meter", "a meter"
|
t = re.sub(rf"\b{w}\b(?=\s*(?:{UNIT}(?![a-z])|degrees?|도(?![가-힣])|and a (?:half|0\.5)))", d, t) # "one meter", "a meter"
|
||||||
else:
|
else:
|
||||||
t = re.sub(rf"(?<![가-힣]){w}\s*(?={UNIT})", d + " ", t)
|
t = re.sub(rf"(?<![가-힣]){w}\s*(?={UNIT})", d + " ", t)
|
||||||
t = re.sub(rf"(?<![\d.])0(\d)\s*(?={UNIT}(?![a-z]))", r"0.\1 ", t) # whisper's "05 meters": 0.5 m
|
t = re.sub(rf"(?<![\d.])0(\d)\s*(?={UNIT}(?![a-z]))", r"0.\1 ", t) # whisper's "05 meters": 0.5 m
|
||||||
@@ -274,7 +288,7 @@ ASR_SLIPS = [ # how whisper writes Korean commands (tests/asr_check.py, 2026-1
|
|||||||
(r"([a-z0-9])\.?\s+(으로|로)\s*(?=가|와|이동|돌아)", r"\1\2 "), # "P3. 로가줘", "final point. 로 가": one word
|
(r"([a-z0-9])\.?\s+(으로|로)\s*(?=가|와|이동|돌아)", r"\1\2 "), # "P3. 로가줘", "final point. 로 가": one word
|
||||||
(r"(?<=로)\s*가죠(?![가-힣])", " 가 줘"), # "p3로 가 줘" written "p3로 가죠"
|
(r"(?<=로)\s*가죠(?![가-힣])", " 가 줘"), # "p3로 가 줘" written "p3로 가죠"
|
||||||
(r"\blook (?:last|lest|less)(?=[\s.!,]*$)", "look left"), (r"\bdoc t\b", "dock 2"), # said at the end
|
(r"\blook (?:last|lest|less)(?=[\s.!,]*$)", "look left"), (r"\bdoc t\b", "dock 2"), # said at the end
|
||||||
(r"고게(?=\s*(?:들|숙))", "고개"), (r"찝어", "집어"), (r"파이나(?=\s*(?:갔|가|로))", "파이널"),
|
(r"고게(?=\s*(?:들|숙)|[를는도가]?\s)", "고개"), (r"찝어", "집어"), (r"파이나(?=\s*(?:갔|가|로))", "파이널"),
|
||||||
# the owner's English as whisper wrote it live (logs/lumi.log 2026-10-21 / 22)
|
# the owner's English as whisper wrote it live (logs/lumi.log 2026-10-21 / 22)
|
||||||
(r"\bcount to(?= p\s?\d)", "come to"), # "Let's count to p5."
|
(r"\bcount to(?= p\s?\d)", "come to"), # "Let's count to p5."
|
||||||
# the head up / down, said or heard loosely (2026-10-23 15:08-15:16: "Look at the bellow.", "Look it up.")
|
# the head up / down, said or heard loosely (2026-10-23 15:08-15:16: "Look at the bellow.", "Look it up.")
|
||||||
@@ -296,6 +310,10 @@ ASR_SLIPS = [ # how whisper writes Korean commands (tests/asr_check.py, 2026-1
|
|||||||
|
|
||||||
_NO = r"(?<![가-힣a-z])"
|
_NO = r"(?<![가-힣a-z])"
|
||||||
KONGLISH = [ # English direction words said in Korean -> the Korean word ("레프트로 반 미터 가 줘요", "라이트 턴 해")
|
KONGLISH = [ # English direction words said in Korean -> the Korean word ("레프트로 반 미터 가 줘요", "라이트 턴 해")
|
||||||
|
(r"왼쭉|왼족", "왼쪽"), (r"멈처|멈쳐", "멈춰"), (r"슴니(?=다|까)", "습니"), (r"(?<![가-힣])야루미", "야 루미"),
|
||||||
|
(r"(?:쉐|셰)이크 ?핸즈?|핸드 ?쉐이크", "악수"), (r"(?<![가-힣])히어로(?= ?(?:와|오|가까이))", "이리로"),
|
||||||
|
(r"리프트 ?다운(?: ?(?:해|하(?:게나?|세요|십시오|시게|시오)?))?(?=\s|$|[?.!~,])", "몸 내려"),
|
||||||
|
(r"리프트 ?업(?: ?(?:해|하(?:게나?|세요|십시오|시게|시오)?))?(?=\s|$|[?.!~,])", "몸 올려"), # read by norm and ko_plain
|
||||||
(_NO + r"레프트\s*(?:쪽으로|으로|로|쪽)?", "왼쪽으로 "),
|
(_NO + r"레프트\s*(?:쪽으로|으로|로|쪽)?", "왼쪽으로 "),
|
||||||
(_NO + r"라이트\s*(?:쪽으로|으로|로|쪽)(?![가-힣])|" + _NO + r"라이트(?=\s*(?:턴|turn|무브|move|\d|반\s*미터))",
|
(_NO + r"라이트\s*(?:쪽으로|으로|로|쪽)(?![가-힣])|" + _NO + r"라이트(?=\s*(?:턴|turn|무브|move|\d|반\s*미터))",
|
||||||
"오른쪽으로 "), # "라이트 켜" is a light
|
"오른쪽으로 "), # "라이트 켜" is a light
|
||||||
@@ -311,6 +329,7 @@ KONGLISH = [ # English direction words said in Korean -> the Korean word ("레
|
|||||||
(r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*업(?![가-힣])", r"\1 들어"),
|
(r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*업(?![가-힣])", r"\1 들어"),
|
||||||
(r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*다운(?![가-힣])", r"\1 숙여"),
|
(r"(고개|머리|헤드|얼굴)\s*(?:를|을)?\s*다운(?![가-힣])", r"\1 숙여"),
|
||||||
(_NO + r"헤드(?=\s)", "고개"),
|
(_NO + r"헤드(?=\s)", "고개"),
|
||||||
|
(_NO + r"웨이스트(?=\s|를|을|는|가)", "허리"),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
@@ -415,8 +434,17 @@ _END_NOT_ASKED = r"(?=(?:\s+(?:빨리|얼른|어서|좀|제발|당장|지금|ple
|
|||||||
_HON = r"(?:세요|세용|세여|십시오|시오|셔요|시죠|실래요|실래|시겠어요|시겠습니까|시겠어|시게|이소(?:마|예)?|거라|너라|렴|라고요?|랑께요?|래이|이라|쇼|시라|시지요|실래예|씨요|세예)"
|
_HON = r"(?:세요|세용|세여|십시오|시오|셔요|시죠|실래요|실래|시겠어요|시겠습니까|시겠어|시게|이소(?:마|예)?|거라|너라|렴|라고요?|랑께요?|래이|이라|쇼|시라|시지요|실래예|씨요|세예)"
|
||||||
_LOOK_AT = r"(왼쪽|오른쪽|위|위쪽|아래|아래쪽|뒤|뒤쪽|앞|하늘|천장|바닥|여기|이쪽|저쪽|나|날|저|정면|좌측|우측)"
|
_LOOK_AT = r"(왼쪽|오른쪽|위|위쪽|아래|아래쪽|뒤|뒤쪽|앞|하늘|천장|바닥|여기|이쪽|저쪽|나|날|저|정면|좌측|우측)"
|
||||||
KO_PLAIN = [
|
KO_PLAIN = [
|
||||||
|
*((re.compile(a), b) for a, b in KONGLISH[:8]), # slips / Konglish above
|
||||||
|
(re.compile(r"(?<=[가-힣?!.~]) +(?:허허|하하|헤헤|호호|히히|ㅋ+|ㅎ+)[\s!.~]*$"), ""), # a laugh after it: "돌아 봐요 허허"
|
||||||
|
(re.compile(r"(?<![가-힣])(?:퍼뜩|퍼떡|언능|얼렁|싸게싸게)(?![가-힣])"), "빨리"), # dialect "quickly"
|
||||||
|
(re.compile(r"(?<=봐) 봐(?=\s*(?:[,.!?~…]|$))"), ""), # "돌아가 봐 봐": once
|
||||||
|
(re.compile(r"(?<=[려어아여]) (?:좀|한 ?번) (?=놔|놓|둬|두)"), " "), # "컵 내려 좀 놔 줘": a softener
|
||||||
|
(re.compile(r"(?<=[가-힣])게나(?=\s*(?:[,.!?~…]|$))"), "게"), # 하게체 "이동하게나", "주게나"
|
||||||
|
(re.compile(r"겄슈|겄어유|겠슈"), "겠어요"), (re.compile(r"(?<=[가-힣])세유(?=\s*(?:[,.!?~…]|$))"), "세요"), # 충청
|
||||||
|
(re.compile(r"(?<![가-힣])(\S*?[가-힣])(?:으)?(?:시겠어요|시겠습니까|시겠어|실래요|실래)\s*\?"), "STEMQ"),
|
||||||
|
# "회전하시겠어요?": please turn
|
||||||
(re.compile(r"(?<=아니 )(\S+?)(?:이요|요)(?=\s*(?:[,.!?~…]|$))"), r"\1"), # "아 아니 정면이요": the noun
|
(re.compile(r"(?<=아니 )(\S+?)(?:이요|요)(?=\s*(?:[,.!?~…]|$))"), r"\1"), # "아 아니 정면이요": the noun
|
||||||
(re.compile(r"오른쭉|오른족"), "오른쪽"), (re.compile(r"(?<![가-힣])외쪽"), "왼쪽"), (re.compile(r"고게(?= )"), "고개"),
|
(re.compile(r"오른쭉|오른족"), "오른쪽"), (re.compile(r"(?<![가-힣])외쪽"), "왼쪽"), (re.compile(r"고게(?=[를는도가]?\s)"), "고개"),
|
||||||
(re.compile(r"(루미야|루미씨|루미 씨)(?=[가-힣])"), r"\1 "), # "루미야오른쪽 봐"
|
(re.compile(r"(루미야|루미씨|루미 씨)(?=[가-힣])"), r"\1 "), # "루미야오른쪽 봐"
|
||||||
(re.compile(r"(?<![가-힣])쫌(?![가-힣])"), "좀"), (re.compile(r"(?<![가-힣])놉여"), "높여"),
|
(re.compile(r"(?<![가-힣])쫌(?![가-힣])"), "좀"), (re.compile(r"(?<![가-힣])놉여"), "높여"),
|
||||||
(re.compile(r"(?<= )주드라(?:고|구)|(?<= )주드랑께"), "줘"), # 전라: "와 주드라고"
|
(re.compile(r"(?<= )주드라(?:고|구)|(?<= )주드랑께"), "줘"), # 전라: "와 주드라고"
|
||||||
@@ -429,7 +457,10 @@ KO_PLAIN = [
|
|||||||
(re.compile(r"(\d+(?:\.\d+)?\s*(?:도|미터|센티(?:미터)?|센치|cm|m)(?![가-힣a-z]))\s+(?:좀|쫌|한번|한 번)\s+(?=[가-힣])"), r"\1 "),
|
(re.compile(r"(\d+(?:\.\d+)?\s*(?:도|미터|센티(?:미터)?|센치|cm|m)(?![가-힣a-z]))\s+(?:좀|쫌|한번|한 번)\s+(?=[가-힣])"), r"\1 "),
|
||||||
# "45도 좀 돌아 줘": the amount, then the verb
|
# "45도 좀 돌아 줘": the amount, then the verb
|
||||||
(re.compile(r"(?<= )조(?:잉)?(?=\s*(?:[,.!?~…]|$))"), "줘"), # "흔들어 조잉", "손 한번 조"
|
(re.compile(r"(?<= )조(?:잉)?(?=\s*(?:[,.!?~…]|$))"), "줘"), # "흔들어 조잉", "손 한번 조"
|
||||||
(re.compile(r"악수 ?(?:한 ?번)? ?(?:할까요?|하실래요?|합시다|하십시다|하자잉|허자잉?|하입시더)"), "악수하자"), # shake hands = wave
|
(re.compile(r"악수 ?(?:한 ?번)? ?(?:할까요?|하실까요?|할래요?|하시죠|하시겠어요|하실래요?|합시다|하십시다|하자잉|허자잉?|하입시더|하세|허세|합세|하시게)(?![가-힣])\s*\??"),
|
||||||
|
"악수하자"), # shake hands = wave; 하게체 "악수하세"
|
||||||
|
(re.compile(r"(?<=[어아여해줘봐와가라자워려춰켜꺼놔둬]) (?:응|엉|알았지|알겠지|알았죠|알겠죠|오케이)"
|
||||||
|
r"\s*[?!.~]*(?=\s*$)"), ""), # a tag after the order: "고개 들어 응?"
|
||||||
(re.compile(r"(?<=[가-힣](?:라|자)) 마(?=\s*(?:[,.!?~…]|$))"), ""), # 경상: "팔 접어 봐라 마"
|
(re.compile(r"(?<=[가-힣](?:라|자)) 마(?=\s*(?:[,.!?~…]|$))"), ""), # 경상: "팔 접어 봐라 마"
|
||||||
(re.compile(_LOOK_AT + r" ?(?:한번 )?(?:바|보게)(?= 주|\s*(?:[,.!?~]|$))"), r"\1 봐"), # whisper "왼쪽바", 하게체 "하늘보게"
|
(re.compile(_LOOK_AT + r" ?(?:한번 )?(?:바|보게)(?= 주|\s*(?:[,.!?~]|$))"), r"\1 봐"), # whisper "왼쪽바", 하게체 "하늘보게"
|
||||||
(re.compile(r"(\S+) ?주면 안 (?:돼|될까|되나|되겠니|되겠어|되겠습니까)(?:요)?\s*\??" + r"(?=\s*(?:[,.!~…]|$))"), r"\1 줘?"),
|
(re.compile(r"(\S+) ?주면 안 (?:돼|될까|되나|되겠니|되겠어|되겠습니까)(?:요)?\s*\??" + r"(?=\s*(?:[,.!~…]|$))"), r"\1 줘?"),
|
||||||
@@ -473,7 +504,9 @@ def _stem_l(word):
|
|||||||
if not j or j[2] != 8:
|
if not j or j[2] != 8:
|
||||||
return None
|
return None
|
||||||
stem = word[:-1] + _syl(j[0], j[1])
|
stem = word[:-1] + _syl(j[0], j[1])
|
||||||
return {"드": "들", "도": "돌", "여": "열", "미": "밀", "내미": "내밀", "흔드": "흔들"}.get(stem, stem)
|
if stem.endswith("시") and len(stem) > 1 and stem not in ("다시",):
|
||||||
|
stem = stem[:-1].removesuffix("으") or stem # honorific: "트실 수" -> 트, "도실 수" -> 도, "집으실" -> 집
|
||||||
|
return {"드": "들", "도": "돌", "트": "틀", "여": "열", "미": "밀", "내미": "내밀", "흔드": "흔들"}.get(stem, stem)
|
||||||
|
|
||||||
|
|
||||||
def _can_you(m, kind):
|
def _can_you(m, kind):
|
||||||
@@ -508,12 +541,14 @@ def ko_plain(t):
|
|||||||
for rx, to in KO_PLAIN:
|
for rx, to in KO_PLAIN:
|
||||||
if to in ("CAN_L", "CAN_N"):
|
if to in ("CAN_L", "CAN_N"):
|
||||||
t = rx.sub(lambda m: _can_you(m, to), t)
|
t = rx.sub(lambda m: _can_you(m, to), t)
|
||||||
elif to == "STEM":
|
elif to in ("STEM", "STEMQ"):
|
||||||
def stem(m):
|
def stem(m):
|
||||||
w = m.group(1)
|
w = m.group(1)
|
||||||
if KO_SOCIAL_BEFORE.search(m.string[:m.start()]):
|
if KO_SOCIAL_BEFORE.search(m.string[:m.start()]):
|
||||||
return m.group(0)
|
return m.group(0)
|
||||||
got = _stem_aform(w[:-1] if w.endswith("으") and len(w) > 1 and _jamo(w[-2]) and _jamo(w[-2])[2] else w)
|
got = _stem_aform(w[:-1] if w.endswith("으") and len(w) > 1 and _jamo(w[-2]) and _jamo(w[-2])[2] else w)
|
||||||
|
if to == "STEMQ" and got:
|
||||||
|
return got + ("?" if got == "줘" else " 줘?")
|
||||||
return got if got else m.group(0)
|
return got if got else m.group(0)
|
||||||
t = rx.sub(stem, t)
|
t = rx.sub(stem, t)
|
||||||
else:
|
else:
|
||||||
@@ -536,7 +571,7 @@ def norm(text, names=()):
|
|||||||
"""Lower case, whisper's slips (ASR_SLIPS), Konglish directions (KONGLISH), numbers first ("point five meters" is
|
"""Lower case, whisper's slips (ASR_SLIPS), Konglish directions (KONGLISH), numbers first ("point five meters" is
|
||||||
a distance), then marker names (names: the map's)."""
|
a distance), then marker names (names: the map's)."""
|
||||||
t = " " + (text or "").lower().replace("’", "'") + " "
|
t = " " + (text or "").lower().replace("’", "'") + " "
|
||||||
t = re.sub(r"(\S+)[—–-]+\s*(?=\1)", "", t) # a stutter: "육십 센— 센티", "go ah— ahead"
|
t = re.sub(r"(?<!\S)(\S+)[—–-]+\s*(?=\1)", "", t) # a stutter: "육십 센— 센티", "go ah— ahead"
|
||||||
t = re.sub(r"(?<=[가-힣])(?=\d+(?:\.\d+)?\s*(?:미터|센티|센치|cm|m\b|도))", " ", t) # "오른쪽으로80센티미터"
|
t = re.sub(r"(?<=[가-힣])(?=\d+(?:\.\d+)?\s*(?:미터|센티|센치|cm|m\b|도))", " ", t) # "오른쪽으로80센티미터"
|
||||||
for slip, said in ASR_SLIPS + KONGLISH:
|
for slip, said in ASR_SLIPS + KONGLISH:
|
||||||
t = re.sub(slip, said, t)
|
t = re.sub(slip, said, t)
|
||||||
|
|||||||
@@ -338,3 +338,83 @@ notation, regexes, no rounds 1–6 train text, no case in both splits, and print
|
|||||||
|
|
||||||
All r8 files after `_h`: 34754 train / 34196 held cases, 1923 train / 1965 held dialogues; unique text 96.8 % over
|
All r8 files after `_h`: 34754 train / 34196 held cases, 1923 train / 1965 held dialogues; unique text 96.8 % over
|
||||||
~99,700 texts; Korean ~79 %; `logs/w3_gen/check_r8.py` 0 problems.
|
~99,700 texts; Korean ~79 %; `logs/w3_gen/check_r8.py` 0 problems.
|
||||||
|
|
||||||
|
## r9 (round 9, 2026-10-24/26 nights: Korean / English parity, writer W4)
|
||||||
|
|
||||||
|
`r9/train/` and `r9/held/` (train seed 91, held seed 92; growth files seeds 93 / 94), written blind from docs/14,
|
||||||
|
docs/16, docs/17 and knowledge/. The owner's goal: Korean as good as English. Every meaning of a set is said at
|
||||||
|
**every level**; every case (sing: the list `LEVELS`, missions: the value, dialogues: every turn) carries NEW field
|
||||||
|
`level`: `en_native`, `en_nonnative`, `ko_banmal` (반말), `ko_haeyo` (해요체), `ko_hasipsio` (하십시오체), `ko_honorific`
|
||||||
|
(-시-, 께서, 드리다, 여쭤보다), `ko_hage` (하게체, elderly), `ko_friendly` (친구끼리: ~, ㅎㅎ, ㅋㅋ, ~임?, ㄱㄱ), `ko_dialect`
|
||||||
|
(경상 / 전라 / 충청; field `dialect` where known), `konglish` (English words in Hangul), `mixed` (code switching). Near
|
||||||
|
misses at every level (mix `hard`: negation, ability, condition, later, reported, remark, words to others,
|
||||||
|
take-back; intents end in `:hard_<kind>`), whisper slips (mix `slip`). Formats are round 6's (r6 commands / r6
|
||||||
|
dialogues sections), NO new expect tokens. De-duplicated inside a split, held against train and both against every
|
||||||
|
earlier round's train text (exact; a dialogue's scored say used before gets a filler in front). Load as
|
||||||
|
`tests.blind.r9.<split>.<name>`.
|
||||||
|
|
||||||
|
| File | train / held | Notes |
|
||||||
|
|---|---|---|
|
||||||
|
| `commands_go`, `_move`, `_turn`, `_look`, `_lift`, `_waist` | 2842/2814, 2524/2527, 1773/1772, 2304/2290, 1225/1225, 884/884 | r6 conventions; numbers in every form (digits, 일 / 이 / 삼, 한 / 두, English words, 원 / 투 / 쓰리) |
|
||||||
|
| `commands_wave`, `_reach`, `_hand`, `_give`, `_take`, `_put`, `_bring` | 869/836, 869/864, 1006/896, 761/731, 1182/1175, 768/757, 2042/2038 | handshakes = wave, 손 줘 / give me a hand = reach; hand includes "is your hand open?" (`status \| talk`) |
|
||||||
|
| `commands_follow`, `_come`, `_point`, `_stop`, `_status`, `_voice` | 585/573, 768/753, 483/478, 812/813, 943/741, 977/959 | stop: every running action as `before`; status `_b`: near misses (don't tell, my phone's battery, words to another person, reported, later) |
|
||||||
|
| `commands_more`, `_chain`, `_detour` | 703/458, 1499/1492, 1759/1688 | more `_b`: near misses at every level; detour `_b`: "why did you stop?" at every level (`talk \| status`) |
|
||||||
|
| `commands_missions`, `commands_sing`, `speed_short` | 1495/1485, 698/580, 1263/1093 | sing `_b`: every song and the song list at every level; speed_short (≤ 3 words, `fast: True`) `_b`: every short meaning at every level + short near misses |
|
||||||
|
| `questions_world` | 6311/3659 | quick / knowledge / unknown / lookup / time meanings (field `q`) at every level; held is smaller: same-text questions were kept only in train |
|
||||||
|
| `dialogues_mixed` | 440/440 (4569/4539 scored turns) | a fact, really? / a false claim / a follow-up, a command on the dialogue's map, a near miss, status, thanks + a question, goodbye; one level per dialogue |
|
||||||
|
| `followup_dialogues` | 330/330 (2970/2970) | follow-ups on Lumi's answer, contradictions (AGREE in must_not) |
|
||||||
|
| `closing_context` | 429/414 | field `closing` end / continue |
|
||||||
|
| `seeing_dialogues` | 328/324 (1640/1620) | r6 person fields; the scene changes |
|
||||||
|
| `memory_dialogues` | 207/199 (1242/1194) | r6 memory format |
|
||||||
|
| `lookup_dialogues` | 154/154 (1279/1289) | r6 lookup format (`lookup` field per turn): weather (city / here, day, ask general / rain / temp / dust / wind), day-only / city-only follow-ups, umbrella / 몇 도 / 미세먼지 for the talk's place and day (`lookup:weather \| none`), climate knowledge (장마철, 황사, 태풍: `none` + must), a remark, near misses (already checked, don't tell me, a friend asked, a plan if it rains, news later: `none`, lookup None), news (topic, more, the second / last one), thanks + a new question, goodbye; one speaker = one dialect; the hello is not scored |
|
||||||
|
|
||||||
|
A file `<name>_b.py` is a growth file (`logs/w4_gen/gen_grow9.py`) filling the cells the first write left empty;
|
||||||
|
published files are never changed. Totals: 37345 train / 33581 held cases, 1888 train / 1861 held dialogues. Per
|
||||||
|
level (cases + scored turns) 7.5–10.1 % each (en_nonnative lowest, ko_dialect highest); near misses 19–26 % at every
|
||||||
|
level. Unique text 72 % (the same wording on several maps / states / before-actions is one text).
|
||||||
|
|
||||||
|
Generators (seeded, not in the repo): `logs/w4_gen/` on the Thor: `ko.py` (Hangul, request endings per level,
|
||||||
|
negation / ability / condition / later / reported / remark / others / take-back frames, numbers, slips), `qlib.py`
|
||||||
|
(question endings per level), `caps.py` (command meanings), `spoken9.py` (marker forms), `render.py`, `gen_cmd.py`,
|
||||||
|
`questions.py`, `gen_dlg.py`, `gen_all.py` (the first write), `gen_lookup9.py`, `gen_grow9.py`; `check_r9.py` checks
|
||||||
|
imports, fields, levels, maps / markers, expect tokens, steps, regexes, no earlier train text, no case in both splits,
|
||||||
|
and parity (every set has every level in both splits, every meaning `intent` / `q` / song at every level in both
|
||||||
|
splits, near misses at every level in every command set, dialogues_mixed and lookup_dialogues): 0 problems.
|
||||||
|
|
||||||
|
## r10 (round 10, 2026-10-26: English half, cup tasks, writer W5)
|
||||||
|
|
||||||
|
`r10/train/` and `r10/held/`, written blind from docs/14, docs/16 and docs/17 (no assistant code or bank read). The
|
||||||
|
owner's complaint: round 9 was only ~17 % English. Here English is **half of every set** (en_native 27 %, en_nonnative
|
||||||
|
23 %), the nine Korean / Konglish / mixed levels of round 9 share the other half (5.6 % each), and every meaning is said
|
||||||
|
at every level in both splits. English wordings: plain, polite and indirect ("would you mind …ing", "could you
|
||||||
|
possibly …", "I was wondering if you could …", "I need you to …"), questions that are requests ("can you …?", "how about
|
||||||
|
…ing?", "any chance you could …?"), casual, rude, long and rambling ("sorry to bother you, but …", "my hands are full,
|
||||||
|
so …"), children; non-native English (broken frames "you can …?", "I want that you …", articles dropped); accent and
|
||||||
|
whisper slips ("tern lef", "pleace", "kup", "tay bull"). Near misses at every level in every command set: negation,
|
||||||
|
ability questions that are no request ("is it possible for a robot like you to …, in general?"), condition, later,
|
||||||
|
reported, remark, words to others, take-back, hypothetical, quote (`:hard_<kind>`, expect `talk | ask`; "don't look at
|
||||||
|
me" = `action:look away | talk | ask`). Field `level` as round 9, `style` on English cases (plain, polite, direct,
|
||||||
|
question, casual, rude, long, child, nonnative, nn_whole, whole). No text in both splits, none of an earlier round's
|
||||||
|
train text (rounds 1–4, r6, r8, r9). Formats of round 9; NO new expect tokens. Load as `tests.blind.r10.<split>.<name>`.
|
||||||
|
|
||||||
|
| File | train / held | Notes |
|
||||||
|
|---|---|---|
|
||||||
|
| `commands_go`, `_move`, `_turn`, `_look`, `_lift`, `_waist` | 1754, 2036, 1372, 1975, 782, 697 (each split) | r6 conventions; amounts new to this round (move 15 / 25 / 40 / 60 / 70 cm, 2.5 / 3 m, 3.5 m refused; turn 20–150°; look 5–50°; lift 3–15 cm; waist 20 / 60 / 90°) |
|
||||||
|
| `commands_wave`, `_reach`, `_hand`, `_give`, `_take`, `_put`, `_bring` | 826, 712, 724, 526, 730, 526, 1029 | handshakes = wave, "lend me your hand" = reach; give / take / put / bring here are apples, oranges and "it" (the cups are in `commands_cup`) |
|
||||||
|
| `commands_follow`, `_come`, `_point`, `_stop`, `_status`, `_voice` | 524, 712, 473, 968, 1023 / 965, 922 | stop with every running action as `before`; status includes "what's in your hand?", "where are you taking that cup?" and near misses (my phone's battery, don't tell me) |
|
||||||
|
| `commands_more`, `_chain`, `_detour` | 853 / 846, 1402, 1282 | chain: 45 % cup chains ("pick up the cup and look at me", holding "put the cup down and give us a wave": `chain \| mission`, `parts` "pick cup", "pick red cup", "put down", "give") |
|
||||||
|
| `commands_missions` | 1800 | step notation of tests/test_steps.py; cup missions: `pick red cup \| go M \| give`, `pick cup \| go M \| place`, `go M \| receive cup wait \| go here`, `go M \| give Sarah`, `pick cup \| go M \| give \| go here`, `go M \| place \| go here`, `receive hand \| go M`, `pick white cup \| give`, `go M \| pick cup \| go here`, `pick cup \| go M \| place dining table`, plus waits, two places, an instruction wait; `?` for coffee, dancing, later, conditions (field `kind` P1–P14 / hard) |
|
||||||
|
| `commands_sing`, `speed_short` | 828 / 804, 1024 / 1000 | sing: every song at every level; speed_short ≤ 3 words, `fast: True`, every capability at every level incl. the cup ("hand it over", "set it down") |
|
||||||
|
| `commands_cup` | 11114 | NEW set, command format (scored like the other command sets). Idle: pick by colour (`action:pick red cup \| mission \| refuse`) or by which one ("the cup on the left", "the smaller cup", "제일 가까운 컵": `action:pick cup \| …`); search ("look for the red cup": `seeing \| action:look \| action:pick red cup \| mission \| action:fetch \| ask \| talk`); take from a hand (`receive \| talk`); "pass me the cup" (`mission \| action:fetch \| action:pick cup`); fetch from a marker, from one marker to another, to a named person at a marker, deliver and come back (`action:fetch \| mission`, `\| ask` for a translated marker name); "wait here until I tell you" (`talk \| stop \| ask`); "give me the cup" idle (`empty_hand \| ask \| talk \| mission \| action:fetch \| action:pick cup`). Holding (state `holding`, 44 %): give to me (`give`), to a described person ("the man in the blue shirt", "her": `give \| ask`), to a name only (`ask \| give`), put here / on a named thing / back, carry to a marker (`mission \| action:fetch \| action:go_to M`), carry and put on the table there; new orders on the way (before `("bring the cup to Sarah at the stage", "ACTION: mission")`): stop, wait here (`stop \| talk \| ask`), "no, the other table" (`place \| ask \| talk`), "give it to her instead" (`give \| ask`), "go to M instead", "never mind, bring it back". Whole-sentence corrections are not wrapped in request frames (style `whole`) |
|
||||||
|
| `dialogues_mixed` (+ `_b`) | 303 (2121 scored turns), _b 502 (2644 / 2646) | one level per dialogue; mixed: 4 commands in a talk, a near miss, status, goodbye. `_b` cup talks: (A) pick → "what are you holding?" → give (`give \| empty_hand \| none`, the checker keeps the start's hand) → thanks (`action:arm open \| give \| none`); (B) holding: put on a named table → "no, the other table" → give to a described person → a near miss; (C) fetch from a marker → stop → to a named person; (D) take from the hand → carry to a marker → "don't move until I say so" → come here → give |
|
||||||
|
| `memory_dialogues` | 161 (644 scored turns) | r6 memory format with cup memory: `seen` a cup today (where), `self.holding` a cup or nothing, a talk yesterday with the command "bring the red cup to stage"; turns: where was the cup seen, what are you holding (`status \| none`), what did I ask yesterday (cup + place), "do what we said" (`ask \| none`, the place read back) |
|
||||||
|
|
||||||
|
Totals: 36614 train / 36501 held cases, 966 / 966 dialogues; per level (cases + scored turns) English 49.8 %
|
||||||
|
(en_native 26.9, en_nonnative 22.9), each Korean / Konglish / mixed level 5.6 %. Unique text 89.8 %.
|
||||||
|
|
||||||
|
Generators (seeded, not in the repo): `logs/w5_gen/` on the Thor: `en10.py` (English frames, -ing forms, non-native
|
||||||
|
grammar, accent slips, near-miss frames), `render10.py` (a meaning at a level; Korean endings from W4's
|
||||||
|
`logs/w4_gen/ko.py` plus indirect ones), `caps10.py` (single commands), `cup10.py` (cup tasks), `gen10.py` (all command
|
||||||
|
sets, missions, chain, sing, status, more, speed_short; train and held filled cell by cell from one pool of taken
|
||||||
|
texts), `dlg10.py` (dialogues); `check_r10.py` (round 9's checks plus no held text in train and the English share):
|
||||||
|
0 problems.
|
||||||
|
|||||||
+66
-4
@@ -73,7 +73,7 @@ SETS = ["commands_go", "commands_move", "commands_turn", "commands_look", "comma
|
|||||||
"commands_stop", "commands_status", "commands_chain", "commands_detour", "speed_short", "commands_sing",
|
"commands_stop", "commands_status", "commands_chain", "commands_detour", "speed_short", "commands_sing",
|
||||||
"commands_missions", "seeing_dialogues", "followup_dialogues", "dialogues_mixed", "unknowns", "silence_noise",
|
"commands_missions", "seeing_dialogues", "followup_dialogues", "dialogues_mixed", "unknowns", "silence_noise",
|
||||||
"hearing", "questions_world", "memory_dialogues", "commands_come", "commands_hand", "commands_point",
|
"hearing", "questions_world", "memory_dialogues", "commands_come", "commands_hand", "commands_point",
|
||||||
"commands_voice", "commands_waist", "commands_more", "closing_context"]
|
"commands_voice", "commands_waist", "commands_more", "closing_context", "lookup_dialogues"]
|
||||||
# commands_chain, commands_detour, speed_short, dialogues_mixed: round r2 on;
|
# commands_chain, commands_detour, speed_short, dialogues_mixed: round r2 on;
|
||||||
# questions_world, memory_dialogues: r6 on. Any other file in a round's folder
|
# questions_world, memory_dialogues: r6 on. Any other file in a round's folder
|
||||||
# is scored too, by the set its name grows ("commands_go_b" as commands_go)
|
# is scored too, by the set its name grows ("commands_go_b" as commands_go)
|
||||||
@@ -164,6 +164,7 @@ def _persons(frames=None):
|
|||||||
|
|
||||||
scene.snapshot = lambda cameras=None, since=None: [SCENE["now"]] if SCENE["now"] is not None else []
|
scene.snapshot = lambda cameras=None, since=None: [SCENE["now"]] if SCENE["now"] is not None else []
|
||||||
scene.things, scene.people, scene._persons = _things, _people, _persons
|
scene.things, scene.people, scene._persons = _things, _people, _persons
|
||||||
|
scene.speaker_key = lambda d, b: 0 # scene._front's stable sort keeps _persons' order: the speaker A first (A6)
|
||||||
VLM_ASKED = [("glasses", r"glass|안경|선글"), ("hat", r"\bhat|\bcap\b|beanie|모자|캡"), ("hair", r"hair|머리"),
|
VLM_ASKED = [("glasses", r"glass|안경|선글"), ("hat", r"\bhat|\bcap\b|beanie|모자|캡"), ("hair", r"hair|머리"),
|
||||||
("bag", r"bag|backpack|가방|배낭"), ("top_pattern", r"pattern|stripe|check|dot|print|무늬|줄무늬|체크|땡땡이"),
|
("bag", r"bag|backpack|가방|배낭"), ("top_pattern", r"pattern|stripe|check|dot|print|무늬|줄무늬|체크|땡땡이"),
|
||||||
("bottom_kind", r"jeans|trousers|pants|skirt|shorts|바지|청바지|치마|반바지"),
|
("bottom_kind", r"jeans|trousers|pants|skirt|shorts|바지|청바지|치마|반바지"),
|
||||||
@@ -222,6 +223,8 @@ def turn_route(b, say, lang, mk, state="idle", use_llm=True):
|
|||||||
"""One turn the way lumi.answer() goes: command_check.rules (drive words, then lumi.route) with seeing.answer on
|
"""One turn the way lumi.answer() goes: command_check.rules (drive words, then lumi.route) with seeing.answer on
|
||||||
the fake scene; what the rules leave through dialogue_check.run_turn with the cameras' facts (and the hand) in
|
the fake scene; what the rules leave through dialogue_check.run_turn with the cameras' facts (and the hand) in
|
||||||
the prompt. (route in dialogue_check's notation, reply, by). A rule's fixed line is "" (not judged)."""
|
the prompt. (route in dialogue_check's notation, reply, by). A rule's fixed line is "" (not judged)."""
|
||||||
|
if lang not in ("en", "ko"): # r9 "mix" turns: Lumi answers in Korean or English
|
||||||
|
lang = "ko" if brain.HANGUL.search(say) else "en"
|
||||||
brain.FORCED_LANG["lang"] = lang
|
brain.FORCED_LANG["lang"] = lang
|
||||||
said = {}
|
said = {}
|
||||||
|
|
||||||
@@ -256,6 +259,9 @@ def turn_route(b, say, lang, mk, state="idle", use_llm=True):
|
|||||||
got if got.startswith("action:") else "action:" + got)
|
got if got.startswith("action:") else "action:" + got)
|
||||||
if r.startswith("action:") or r == "mission":
|
if r.startswith("action:") or r == "mission":
|
||||||
b.history.append((say, f"ACTION: {r.split(':', 1)[1] if ':' in r else r}"))
|
b.history.append((say, f"ACTION: {r.split(':', 1)[1] if ':' in r else r}"))
|
||||||
|
elif r in ("weather", "search"): # lumi.look_up keeps the question (+ WEATHER_ASKED)
|
||||||
|
b.last_lookup = say + brain.WEATHER_ASKED if r == "weather" else say
|
||||||
|
b.history.append((b.last_lookup, ""))
|
||||||
return r, "", "rules"
|
return r, "", "rules"
|
||||||
if not use_llm:
|
if not use_llm:
|
||||||
return "llm?", "", "-"
|
return "llm?", "", "-"
|
||||||
@@ -452,6 +458,7 @@ def score_missions(c, old, use_llm):
|
|||||||
got=json.loads(json.dumps(got)), unread=unread)
|
got=json.loads(json.dumps(got)), unread=unread)
|
||||||
|
|
||||||
|
|
||||||
|
LOOKUP = {"lookup:weather": "weather", "lookup:news": "search", "lookup:web": "search"} # lookup_dialogues (r9)
|
||||||
FORGOT = set(__import__("assistant.memory", fromlist=["FORGOT"]).FORGOT.values())
|
FORGOT = set(__import__("assistant.memory", fromlist=["FORGOT"]).FORGOT.values())
|
||||||
|
|
||||||
|
|
||||||
@@ -483,6 +490,8 @@ def score_dialogue(d, old, use_llm, judge=False):
|
|||||||
r, reply, by = turn_route(b, turn["say"], lang, mk, state, use_llm)
|
r, reply, by = turn_route(b, turn["say"], lang, mk, state, use_llm)
|
||||||
if r == "llm?":
|
if r == "llm?":
|
||||||
rows.append(row(key, "llm?" if scored else "-", "-", "", route="", reply=""))
|
rows.append(row(key, "llm?" if scored else "-", "-", "", route="", reply=""))
|
||||||
|
if turn.get("closing"):
|
||||||
|
rows[-1]["closing"] = turn["closing"]
|
||||||
b.history.append((turn["say"], ""))
|
b.history.append((turn["say"], ""))
|
||||||
continue
|
continue
|
||||||
if r.startswith("action:give") or r.startswith("action:place"):
|
if r.startswith("action:give") or r.startswith("action:place"):
|
||||||
@@ -492,7 +501,7 @@ def score_dialogue(d, old, use_llm, judge=False):
|
|||||||
if not scored:
|
if not scored:
|
||||||
rows.append(row(key, "-", by, "", route=r, reply=reply))
|
rows.append(row(key, "-", by, "", route=r, reply=reply))
|
||||||
continue
|
continue
|
||||||
want = dict(turn, expect_action=" | ".join(a.strip().removeprefix("action:")
|
want = dict(turn, expect_action=" | ".join(LOOKUP.get(a.strip(), a.strip()).removeprefix("action:")
|
||||||
for a in turn.get("expect_action", "none").split(" | ")))
|
for a in turn.get("expect_action", "none").split(" | ")))
|
||||||
looked_up = r in ("weather", "search", "search(unsure)") and \
|
looked_up = r in ("weather", "search", "search(unsure)") and \
|
||||||
not dialogue_check.action_ok(want["expect_action"], r) # a lookup's answer is talk (not checked)
|
not dialogue_check.action_ok(want["expect_action"], r) # a lookup's answer is talk (not checked)
|
||||||
@@ -512,6 +521,8 @@ def score_dialogue(d, old, use_llm, judge=False):
|
|||||||
r, reply, by, probs, note, v = "error", repr(e), "-", [repr(e)], "", "error"
|
r, reply, by, probs, note, v = "error", repr(e), "-", [repr(e)], "", "error"
|
||||||
rows.append(row(key, v, by, f"{d['topic']} t{j + 1} {turn['say']!r} -> [{r}] {reply[:120]!r} {probs}{note} "
|
rows.append(row(key, v, by, f"{d['topic']} t{j + 1} {turn['say']!r} -> [{r}] {reply[:120]!r} {probs}{note} "
|
||||||
f"(check: {turn.get('check')})", route=r, reply=reply, judged=judged))
|
f"(check: {turn.get('check')})", route=r, reply=reply, judged=judged))
|
||||||
|
if turn.get("closing"):
|
||||||
|
rows[-1]["closing"] = turn["closing"] # closing_context: "end" / "continue", counted apart
|
||||||
return rows
|
return rows
|
||||||
|
|
||||||
|
|
||||||
@@ -743,6 +754,7 @@ def run_set(split, name, old_rows, use_llm, cached, limit, sample=None):
|
|||||||
rows.append(row(str(c)[:200], "error", "-", f"{str(c)[:150]} -> {e!r}"))
|
rows.append(row(str(c)[:200], "error", "-", f"{str(c)[:150]} -> {e!r}"))
|
||||||
for r in rows[n:]:
|
for r in rows[n:]:
|
||||||
r["lang"] = lang_of(c, r)
|
r["lang"] = lang_of(c, r)
|
||||||
|
r["level"] = level_of(c, r)
|
||||||
if r["verdict"] in ("wrong", "motion", "error") and "-v" in sys.argv:
|
if r["verdict"] in ("wrong", "motion", "error") and "-v" in sys.argv:
|
||||||
print(f" {r['verdict'].upper():6} {r['show'][:200]}", flush=True)
|
print(f" {r['verdict'].upper():6} {r['show'][:200]}", flush=True)
|
||||||
return rows
|
return rows
|
||||||
@@ -764,6 +776,56 @@ def lang_of(c, r):
|
|||||||
return "mix" if ko and en else "ko" if ko else "en"
|
return "mix" if ko and en else "ko" if ko else "en"
|
||||||
|
|
||||||
|
|
||||||
|
LEVEL_NAME = {"banmal": "ko_banmal", "haeyo": "ko_haeyo", "hapsyo": "ko_hasipsio", "friendly": "ko_friendly",
|
||||||
|
"honorific": "ko_honorific", "dialect": "ko_dialect"} # W2's names (r6 _i files) -> r9's
|
||||||
|
LEVEL_GUESS = [("ko_dialect", r"(?:주이소|하이소|하입시더|하이소|데이|카이|라예|랑께|허자잉|줘유|해유|줍서|헙서|마씸|아이가|머꼬|와이라|"
|
||||||
|
r"하모|맞제|그라제|했노|하노|하나\?|가\?)[.?!~]*$|잉[.?!~]*$|(?:주소|해 ?도)[.?!]*$"),
|
||||||
|
("ko_hage", r"(?:하게|주게|하네|하세|보게|오게|가게나|하시게)[.?!~]*$|자네"),
|
||||||
|
("ko_honorific", r"(?:시[어겠었]|으시|하시|주시|가시|보시|께서|드리|드릴|드려|여쭤|여쭙|계세|계십|잡수|주무|말씀)"),
|
||||||
|
("ko_hasipsio", r"(?:습니다|습니까|[가-힣]니다|[가-힣]니까|십시오|시오|하십시다)[.?!~]*$"),
|
||||||
|
("ko_friendly", r"ㅋ|ㅎㅎ|~|임\?|ㄱㄱ|ㅇㅇ|ㄹㅇ|당[.?!]*$|용[.?!]*$|쥬[.?!]*$"),
|
||||||
|
("ko_haeyo", r"요[.?!~,]*(?:\s|$)")]
|
||||||
|
|
||||||
|
|
||||||
|
def level_of(c, r):
|
||||||
|
"""The speech level of a case or a scored turn: its "level" field (r9; W2's names in r6 _i files read as r9's),
|
||||||
|
else guessed from the Korean endings (marked "*"); English "en*", mixed "mixed*"."""
|
||||||
|
turn = {}
|
||||||
|
if isinstance(c, dict) and "turns" in c and r["key"][:1].isdigit():
|
||||||
|
j = int(r["key"].split("|", 1)[0]) - 1
|
||||||
|
turn = c["turns"][j] if 0 <= j < len(c["turns"]) else {}
|
||||||
|
case = c if isinstance(c, dict) else c[1] if isinstance(c, (list, tuple)) and len(c) > 1 and \
|
||||||
|
isinstance(c[1], dict) else {}
|
||||||
|
lv = turn.get("level") or (case.get("level") if not turn or "turns" not in case else None)
|
||||||
|
if lv:
|
||||||
|
return LEVEL_NAME.get(lv, lv)
|
||||||
|
if r.get("lang") == "en":
|
||||||
|
return "en*"
|
||||||
|
if r.get("lang") == "mix":
|
||||||
|
return "mixed*"
|
||||||
|
text = turn.get("say") or case.get("text") or case.get("heard") or (c[0] if isinstance(c, (list, tuple)) else "")
|
||||||
|
text = (text or "").strip()
|
||||||
|
return next((name + "*" for name, rx in LEVEL_GUESS if re.search(rx, text)), "ko_banmal*")
|
||||||
|
|
||||||
|
|
||||||
|
def by_level(saved):
|
||||||
|
"""right / cases per speech level over every set (r9 / r6 _i: as labelled; "*": guessed from the endings), and the
|
||||||
|
closing turns (closing_context) by kind."""
|
||||||
|
lv, cl = collections.defaultdict(collections.Counter), collections.defaultdict(collections.Counter)
|
||||||
|
for name in ordered(saved):
|
||||||
|
for r in saved[name]["rows"]:
|
||||||
|
if r["verdict"] != "-":
|
||||||
|
lv[r.get("level", "?")][r["verdict"]] += 1
|
||||||
|
if r.get("closing"):
|
||||||
|
cl[r["closing"]][r["verdict"]] += 1
|
||||||
|
lines = ["", "By speech level (right / cases, motions in brackets; * = guessed from the endings):", "",
|
||||||
|
"| level | right | wrong | motion | llm? |", "|---|---|---|---|---|"]
|
||||||
|
lines += [f"| {k} | {cell(lv[k])} | {lv[k]['wrong']} | {lv[k]['motion']} | {lv[k]['llm?']} |" for k in sorted(lv)]
|
||||||
|
if cl:
|
||||||
|
lines += ["", "Closing turns: " + ", ".join(f"{k} {cell(cl[k])}" for k in sorted(cl))]
|
||||||
|
return lines
|
||||||
|
|
||||||
|
|
||||||
def cell(k):
|
def cell(k):
|
||||||
n = sum(k.values())
|
n = sum(k.values())
|
||||||
return f"{k['right']}/{n} ({100 * k['right'] // max(1, n)} %)" + (f" [{k['motion']}]" if k["motion"] else "") if n else "-"
|
return f"{k['right']}/{n} ({100 * k['right'] // max(1, n)} %)" + (f" [{k['motion']}]" if k["motion"] else "") if n else "-"
|
||||||
@@ -801,7 +863,7 @@ def report(split, saved, secs):
|
|||||||
n = sum(tot.values())
|
n = sum(tot.values())
|
||||||
lines.append(f"| ALL | | {n} | {tot['right']} | {100 * tot['right'] // max(1, n)} | {tot['wrong']} | "
|
lines.append(f"| ALL | | {n} | {tot['right']} | {100 * tot['right'] // max(1, n)} | {tot['wrong']} | "
|
||||||
f"{tot['motion']} | {tot['llm?']} | {tot['error']} | |")
|
f"{tot['motion']} | {tot['llm?']} | {tot['error']} | |")
|
||||||
lines += by_lang(saved)
|
lines += by_lang(saved) + by_level(saved)
|
||||||
for name in ordered(saved):
|
for name in ordered(saved):
|
||||||
rows = saved[name]["rows"]
|
rows = saved[name]["rows"]
|
||||||
dl = {}
|
dl = {}
|
||||||
@@ -814,7 +876,7 @@ def report(split, saved, secs):
|
|||||||
r["show"].replace("\n", "\n ") for r in bad] or ["- none"]
|
r["show"].replace("\n", "\n ") for r in bad] or ["- none"]
|
||||||
out = ROOT / "logs" / f"blind_{split}.md"
|
out = ROOT / "logs" / f"blind_{split}.md"
|
||||||
out.write_text("\n".join(lines) + "\n")
|
out.write_text("\n".join(lines) + "\n")
|
||||||
print("\n".join(lines[:len(saved) + 7] + by_lang(saved)))
|
print("\n".join(lines[:len(saved) + 7] + by_lang(saved) + by_level(saved)))
|
||||||
|
|
||||||
|
|
||||||
def main(args):
|
def main(args):
|
||||||
|
|||||||
@@ -87,8 +87,9 @@ def rules(text, state, marks, b):
|
|||||||
return "refuse" # Lumi.wave refuses with something held (wave.HOLDING)
|
return "refuse" # Lumi.wave refuses with something held (wave.HOLDING)
|
||||||
if data[0] == "put" and not holding:
|
if data[0] == "put" and not holding:
|
||||||
return "empty_hand" # skills.put_down: nothing picked, nothing moves
|
return "empty_hand" # skills.put_down: nothing picked, nothing moves
|
||||||
if data[0] == "fetch" and not holding and {"object", "place"} & set(brain.parse_fetch(text, marks)[1]):
|
if data[0] == "fetch" and (holding or {"object", "place"} & set(brain.parse_fetch(text, marks)[1])):
|
||||||
return "ask" # fetch_dialog asks what is missing before anything moves
|
return "ask" # fetch_dialog asks what is missing before anything moves;
|
||||||
|
# holding: lumi.fetch_request asks where to put it first
|
||||||
return data[0] if data[0] in ("weather", "search") else f"action:{data[0]} {data[1]}".strip()
|
return data[0] if data[0] in ("weather", "search") else f"action:{data[0]} {data[1]}".strip()
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|||||||
@@ -87,7 +87,11 @@ def run_turn(b, text, lang, marks):
|
|||||||
bye = b.farewell(text, lang)
|
bye = b.farewell(text, lang)
|
||||||
b.reset()
|
b.reset()
|
||||||
return r, bye, time.time() - t0, time.time() - t0
|
return r, bye, time.time() - t0, time.time() - t0
|
||||||
if r.startswith("action:") or r in ("weather", "search"): # quick_command keeps it in the history
|
if r in ("weather", "search"): # lumi.look_up: the question (+ WEATHER_ASKED) is kept
|
||||||
|
asked = text + brain.WEATHER_ASKED if r == "weather" else text # so "도쿄는?" / "how about Daegu?" follow it
|
||||||
|
b.history.append((asked, by_rule[1] or ""))
|
||||||
|
b.last_lookup = asked
|
||||||
|
elif r.startswith("action:"): # quick_command keeps it in the history
|
||||||
a = r.split(":", 1)[-1].split(" ", 1)
|
a = r.split(":", 1)[-1].split(" ", 1)
|
||||||
b.history.append((text, f"ACTION: {a[0]} {a[1] if len(a) > 1 else '-'}"))
|
b.history.append((text, f"ACTION: {a[0]} {a[1] if len(a) > 1 else '-'}"))
|
||||||
return r, by_rule[1], None, time.time() - t0
|
return r, by_rule[1], None, time.time() - t0
|
||||||
|
|||||||
@@ -5,7 +5,8 @@ part?"), "really?" / "are you sure?" right after a motion (about the talk before
|
|||||||
number, settled facts after thanks (answered, not looked up), short follow-ups never answered "say it again".
|
number, settled facts after thanks (answered, not looked up), short follow-ups never answered "say it again".
|
||||||
English, Korean (반말 / 해요체 / 하십시오체 / friendly / honorific / dialect) and mixed; Korean replies polite.
|
English, Korean (반말 / 해요체 / 하십시오체 / friendly / honorific / dialect) and mixed; Korean replies polite.
|
||||||
|
|
||||||
.venv/bin/python tests/dialogues_night4.py [only] # through tests/followup_check.main -> logs/a4n4/night4_check.*
|
.venv/bin/python tests/dialogues_night4.py [only] [--b] # through tests/followup_check.main -> logs/a4n4/night4_check.*
|
||||||
|
# (--b: round 2 -> night4b_check.*)
|
||||||
"""
|
"""
|
||||||
import sys
|
import sys
|
||||||
|
|
||||||
@@ -81,14 +82,78 @@ DIALOGUES_NIGHT4 = [
|
|||||||
T("말씀하신 거 아까랑 좀 다른 것 같은데요?", must=[r"유칼립투스|잎|에너지|6|여섯|개월|18|20"], no=NK + [WHICH],
|
T("말씀하신 거 아까랑 좀 다른 것 같은데요?", must=[r"유칼립투스|잎|에너지|6|여섯|개월|18|20"], no=NK + [WHICH],
|
||||||
check="같은 사실을 다시"),
|
check="같은 사실을 다시"),
|
||||||
T("감사합니다, 많이 배웠어요. 안녕히 계세요.", "end")),
|
T("감사합니다, 많이 배웠어요. 안녕히 계세요.", "end")),
|
||||||
|
D("grandfather", "owl_ko_dialect", "ko",
|
||||||
|
T("부엉이 목 그거 을매나 돌아가노?", must=[r"270|이백칠십"], no=NK + [ME], check="270도; Lumi의 고개가 아님"),
|
||||||
|
T("그래 돌리믄 피는 우째 되노?", must=[r"피|혈관|혈액|핏줄|흐르|막히"], no=NK + [ME], check="혈관이 특별해서 피가 계속 흐름; " + FU),
|
||||||
|
T("눈은 와 안 움직이노?", must=[r"크|커|뼈|고정|관|원통"], no=NK + [ME], check="눈이 커서 고정; " + FU),
|
||||||
|
T("어... 그... 뭐였더라...", "-"),
|
||||||
|
T("참말이가?", must=[r"네|정말|맞|크|고정|270|피"], no=NK + [ME], check="부엉이 얘기를 다시 (못 알아들은 턴 전의 얘기)"),
|
||||||
|
T("욕봤다, 간데이.", "end")),
|
||||||
|
D("engineer", "lotte_mixed_konglish", "ko",
|
||||||
|
T("롯데월드타워 height 몇 m예요?", must=[r"555|오백오십오"], no=NK, check="555m"),
|
||||||
|
T("floor는 몇 개?", must=[r"123|백이십삼"], no=NK, check="123층; " + FU),
|
||||||
|
T("uh... what was it... 그...", "-"),
|
||||||
|
T("are you sure?", must=[r"555|123|yes|네|맞"], no=NK, rl="en", check="롯데월드타워 숫자를 다시 (못 알아들은 턴 전)"),
|
||||||
|
T("Okay, thanks. Bye!", "end")),
|
||||||
|
]
|
||||||
|
|
||||||
|
# round 2 (10:50): parts named after a world subject ("심장은 몇 개고?", "Why the name?"), lower-case English subjects,
|
||||||
|
# Lumi's own numbers asked casually and very politely, "really?" after an uncaught turn, a topic taken up again
|
||||||
|
DIALOGUES_NIGHT4B = [
|
||||||
|
D("student", "giraffe_en_native", "en",
|
||||||
|
T("Why do giraffes have such long necks?", must=[r"leaves|tree|reach|food|fight|eat"], no=N + [ME], check="to reach high leaves"),
|
||||||
|
T("How many bones are in it?", must=[r"seven|7"], no=N + [ME], check="seven, like ours; " + FU),
|
||||||
|
T("And the heart, is it big?", must=[r"kilo|kg|big|large|pump|blood|11|60 ?cm"], no=N + [ME], check="about 11 kg; " + FU),
|
||||||
|
T("hmm... the... uh...", "-"),
|
||||||
|
T("Really?", must=[r"yes|seven|7|kilo|kg|big"], no=N, check="yes, the giraffe facts again (before the uncaught turn)"),
|
||||||
|
T("Cool, thanks. Bye!", "end")),
|
||||||
|
D("grandmother", "lumi_specs_ko_honorific", "ko",
|
||||||
|
T("루미 님 머리에 든 컴퓨터는 메모리가 얼마나 되시는지요?", must=[r"122|백이십이"], no=NK, check="122GB"),
|
||||||
|
T("팔로는 얼마나 무거운 걸 드실 수 있으세요?", must=[r"2 ?(?:kg|킬로)|1 ?(?:kg|킬로)|이 ?킬로|일 ?킬로"], no=NK,
|
||||||
|
check="팔 2kg, 손에는 약 1kg"),
|
||||||
|
T("아이고 그래요? 정말이세요?", must=[r"네|2|1|킬로|맞"], no=NK, check="네, 같은 숫자를 다시"),
|
||||||
|
T("고마워요. 그럼 키는 어떻게 되세요?", must=[r"146|186|백사십"], no=NK, check="146cm, 올리면 186cm"),
|
||||||
|
T("잘 들었어요, 수고하세요.", "end")),
|
||||||
|
D("friend", "octopus_ko_banmal", "ko",
|
||||||
|
T("문어 피는 무슨 색이야?", must=[r"파란|푸른|청색"], no=NK + [ME], check="파란색"),
|
||||||
|
T("왜?", must=[r"구리|헤모시아닌|산소"], no=NK + [ME], check="구리가 든 헤모시아닌; " + FU),
|
||||||
|
T("심장은 몇 개야?", must=[r"3|세 ?개|셋"], no=NK + [ME], check="3개 (문어의 심장)"),
|
||||||
|
T("아까 피 색깔 뭐라 했지?", must=[r"파란|푸른|청색"], no=NK, check="파란색 (앞의 얘기로 돌아감)"),
|
||||||
|
T("ㅇㅋ 고마워, 간다~", "end")),
|
||||||
|
D("tourist", "namsan_mixed_konglish", "ko",
|
||||||
|
T("남산타워 언제 오픈했어요?", must=[r"1975|1980|칠십|팔십"], no=NK, check="1975년 완공, 1980년 개방"),
|
||||||
|
T("height는요?", must=[r"236|480|미터"], no=NK, check="약 236m; " + FU),
|
||||||
|
T("why 이름이 N이에요?", must=[r"남산|new|새|N"], no=NK + [r"제 이름|루미"], check="Namsan / new; 루미의 이름이 아님"),
|
||||||
|
T("Okay 땡큐!", "end")),
|
||||||
|
D("engineer", "sound_ko_hasipsio", "ko",
|
||||||
|
T("빛의 속도는 초속 몇 킬로미터입니까?", must=[r"30만|300,?000|삼십만|299"], no=NK, check="약 30만 km/s"),
|
||||||
|
T("소리는 어떻습니까?", must=[r"340|343|삼백사십"], no=NK + [ME], check="공기 중 약 340m/s; " + FU),
|
||||||
|
T("물속에서는 얼마나 빠릅니까?", must=[r"1,?500|1,?480|천오백|4|네 ?배"], no=NK, check="약 1,500m/s"),
|
||||||
|
T("확실하십니까?", must=[r"네|1,?500|천오백|맞|확실"], no=NK, check="네, 물속 숫자를 다시"),
|
||||||
|
T("수고하십시오.", "end")),
|
||||||
|
D("parent", "lumi_battery_en_nonnative", "en",
|
||||||
|
T("your battery, how many hour it go?", must=[r"10|ten"], no=N, check="about 10 hours"),
|
||||||
|
T("and when it is empty, you go charging alone?", must=[r"yes|myself|by myself|on my own|dock|charg"], no=N,
|
||||||
|
check="yes, goes to the charger by itself"),
|
||||||
|
T("hm ok, and the arm can carry how much?", must=[r"2 ?kg|two|1 ?kg|one|kilo"], no=N, check="2 kg with the gripper, ~1 kg in the hand"),
|
||||||
|
T("Sure?", must=[r"yes|2|two|1|one|kilo"], no=N, check="yes, the same numbers"),
|
||||||
|
T("Okay, see you.", "end")),
|
||||||
|
D("grandfather", "palace_ko_dialect", "ko",
|
||||||
|
T("경복궁 그거 언제 지었노?", must=[r"1395|조선|태조"], no=NK, check="1395년"),
|
||||||
|
T("이름은 와 그래 지었노?", must=[r"복|큰|하늘|복을|경사|시경|백성|태평"], no=NK + [r"제 이름|루미"],
|
||||||
|
check="큰 복을 누리라는 뜻; 루미의 이름이 아님"),
|
||||||
|
T("불은 몇 번 났노?", must=[r"임진왜란|1592|불|탔|화재|여러"], no=NK, check="임진왜란 때 탔고 1867년 다시 지음; " + FU),
|
||||||
|
T("고맙데이, 수고하그래이.", "end")),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
from tests import followup_check as fc
|
from tests import followup_check as fc
|
||||||
from tests import dialogue_check as dc
|
from tests import dialogue_check as dc
|
||||||
fc.DIALOGUES = DIALOGUES_NIGHT4
|
b = "--b" in sys.argv # round 2: its own report
|
||||||
|
fc.DIALOGUES = DIALOGUES_NIGHT4B if b else DIALOGUES_NIGHT4
|
||||||
(dc.ROOT / "logs" / "a4n4").mkdir(exist_ok=True)
|
(dc.ROOT / "logs" / "a4n4").mkdir(exist_ok=True)
|
||||||
dc.OUT_JSON, dc.OUT_MD = dc.ROOT / "logs" / "a4n4" / "night4_check.json", dc.ROOT / "logs" / "a4n4" / "night4_check.md"
|
name = "night4b_check" if b else "night4_check"
|
||||||
|
dc.OUT_JSON, dc.OUT_MD = dc.ROOT / "logs" / "a4n4" / f"{name}.json", dc.ROOT / "logs" / "a4n4" / f"{name}.md"
|
||||||
args = [a for a in sys.argv[1:] if not a.startswith("--")]
|
args = [a for a in sys.argv[1:] if not a.startswith("--")]
|
||||||
fc.main(args[0] if args else None, failed="--failed" in sys.argv)
|
fc.main(args[0] if args else None, failed="--failed" in sys.argv)
|
||||||
|
|||||||
@@ -44,6 +44,16 @@ CAPS = {
|
|||||||
"sing": ("sing a song", "노래", "부르", "불러", ["노래 싱 해 줘"]),
|
"sing": ("sing a song", "노래", "부르", "불러", ["노래 싱 해 줘"]),
|
||||||
"louder": ("speak louder", "더 크게", "말하", "말해", []),
|
"louder": ("speak louder", "더 크게", "말하", "말해", []),
|
||||||
"slower": ("speak slower", "좀 천천히", "말하", "말해", []),
|
"slower": ("speak slower", "좀 천천히", "말하", "말해", []),
|
||||||
|
"quieter": ("speak more quietly", "좀 작게", "말하", "말해", []),
|
||||||
|
"look_dn": ("look down", "아래를", "보", "봐", ["다운 봐 줘", "look down 해 주세요"]),
|
||||||
|
"look_me": ("look at me", "저를", "보", "봐", ["룩 앳 미 해 줘"]),
|
||||||
|
"around": ("turn around", "뒤로", "돌", "돌아", ["유턴 해 줘", "turn around 해 주세요"]),
|
||||||
|
"come_back": ("come back", "", "돌아오", "돌아와", ["컴백 해 줘"]),
|
||||||
|
"waist": ("turn your waist left", "허리를 왼쪽으로", "돌리", "돌려", ["웨이스트 레프트로 돌려 줘"]),
|
||||||
|
"body_up": ("raise your body", "몸을", "올리", "올려", ["리프트 업 해 줘", "바디 업 해 줘"]),
|
||||||
|
"open": ("open your hand", "손", "펴", "펴", ["핸드 오픈 해 줘"]),
|
||||||
|
"put": ("put the cup down", "컵 내려", "놓", "놔", []),
|
||||||
|
"charge": ("go charge", "충전하러", "가", "가", ["차지하러 가 줘"]),
|
||||||
}
|
}
|
||||||
EN_FORMS = ["{}", "please {}", "{}, please", "could you {}?", "can you {} for me?", "would you {}, please?",
|
EN_FORMS = ["{}", "please {}", "{}, please", "could you {}?", "can you {} for me?", "would you {}, please?",
|
||||||
"I'd like you to {}", "I'd love it if you could {}", "{}, if you don't mind", "lumi, {}",
|
"I'd like you to {}", "I'd love it if you could {}", "{}, if you don't mind", "lumi, {}",
|
||||||
@@ -138,7 +148,8 @@ def check(names=None):
|
|||||||
"missed" if got is None or got.split()[0] in command_check.NO_MOTION else "wrong"))
|
"missed" if got is None or got.split()[0] in command_check.NO_MOTION else "wrong"))
|
||||||
for t in not_now(pre, stem, a):
|
for t in not_now(pre, stem, a):
|
||||||
got = read(t)
|
got = read(t)
|
||||||
moves = got is not None and got.split()[0] not in command_check.NO_MOTION
|
moves = got is not None and got.split()[0] not in command_check.NO_MOTION and \
|
||||||
|
not (got == "action:look away" and "지 마" in t) # "저를 보지 마세요": looking away is asked
|
||||||
rows.append((name, "not_now", t, got, "no motion", "right" if not moves else
|
rows.append((name, "not_now", t, got, "no motion", "right" if not moves else
|
||||||
"wrong" if got in ("stop", "sing") else "motion")) # a stop or a song moves nothing
|
"wrong" if got in ("stop", "sing") else "motion")) # a stop or a song moves nothing
|
||||||
return rows
|
return rows
|
||||||
|
|||||||
@@ -0,0 +1,151 @@
|
|||||||
|
"""Self-check of cup-task wordings (night 4, F1), no robot, no LLM: python tests/test_fetch_words.py
|
||||||
|
|
||||||
|
1. brain.parse_fetch: where the thing is (source), where it goes (dest), which one (prefer), at every speech level.
|
||||||
|
2. steps.rules: cup tasks of several parts (fetch then more, deliver and come back, put it at a place, wait until
|
||||||
|
someone takes it, Korean calls / endings of every level, Korean written without spaces).
|
||||||
|
Notation of tests/test_steps.py."""
|
||||||
|
from assistant import brain, steps
|
||||||
|
|
||||||
|
|
||||||
|
def short(s):
|
||||||
|
"""The notation of tests/test_steps.py, the kinds used here."""
|
||||||
|
w = s.split()
|
||||||
|
if w[0] == "go":
|
||||||
|
return {"do": "go", "to": w[1]}
|
||||||
|
if w[0] == "pick":
|
||||||
|
return {"do": "pick", "object": w[-1], "colour": w[1] if len(w) == 3 else None}
|
||||||
|
if w[0] == "receive":
|
||||||
|
return {"do": "receive", "object": w[1], **({"wait_s": steps.WAIT_GIVE_S} if w[-1] == "wait" else {})}
|
||||||
|
if w[0] == "wait":
|
||||||
|
if w[1:2] == ["order"]:
|
||||||
|
return {"do": "wait", "s": steps.WAIT_ORDER_S, "until": "instruction"}
|
||||||
|
return {"do": "wait", "s": float(w[1]) if len(w) > 1 else None}
|
||||||
|
if w[0] == "turn":
|
||||||
|
return {"do": "turn", "deg": float(w[1])}
|
||||||
|
if w[0] == "place":
|
||||||
|
return {"do": "place", "on": {"name": "dining table", "colour": None, "side": None} if len(w) > 1 else None}
|
||||||
|
if w[0] == "give" and len(w) > 1:
|
||||||
|
return {"do": "give", "person": s[5:]}
|
||||||
|
return {"do": w[0]}
|
||||||
|
|
||||||
|
M = ["home", "p1", "p2", "p3", "p4", "p5", "Registration", "Main_Stage", "Coffee_Bar"]
|
||||||
|
P = lambda n: {"marker": n}
|
||||||
|
|
||||||
|
# ---- 1. one fetch: (object, colour, source, dest, finish[, prefer]); None = asked ----
|
||||||
|
FETCH = {
|
||||||
|
"bring me the red cup from p3": ("cup", "red", P("p3"), "here", "hold"),
|
||||||
|
"could you grab me the cup that's on p2?": ("cup", None, P("p2"), "here", "hold"),
|
||||||
|
"get me the cup on the left from p1": ("cup", None, P("p1"), "here", "hold", "left"),
|
||||||
|
"fetch the white cup from the coffee bar": ("cup", "white", P("Coffee_Bar"), "here", "hold"),
|
||||||
|
"would you mind bringing the cup over from p5": ("cup", None, P("p5"), "here", "hold"),
|
||||||
|
"p1 red cup bring me please": ("cup", "red", P("p1"), "here", "hold"),
|
||||||
|
"bring the cup on p1 to p4": ("cup", None, P("p1"), P("p4"), "hold"),
|
||||||
|
"take the cup from p1 to p4": ("cup", None, P("p1"), P("p4"), "hold"),
|
||||||
|
"bring the cup to p1": ("cup", None, "here", P("p1"), "hold"),
|
||||||
|
"p3에서 빨간 컵 가져와": ("cup", "red", P("p3"), "here", "hold"),
|
||||||
|
"피삼에 있는 컵 좀 가져다줄래?": ("cup", None, P("p3"), "here", "hold"),
|
||||||
|
"피투에 있는 왼쪽 컵 가져와 줘": ("cup", None, P("p2"), "here", "hold", "left"),
|
||||||
|
"피원 컵 가져와": ("cup", None, P("p1"), "here", "hold"),
|
||||||
|
"p1의 컵 가져와": ("cup", None, P("p1"), "here", "hold"),
|
||||||
|
"커피 바에서 하얀 컵 갖다 주시겠어요?": ("cup", "white", P("Coffee_Bar"), "here", "hold"),
|
||||||
|
"피오에서 작은 컵 좀 가져다 주십시오": ("cup", None, P("p5"), "here", "hold", "small"),
|
||||||
|
"일 번 포인트에 있는 컵 좀 갖다 줘": ("cup", None, P("p1"), "here", "hold"),
|
||||||
|
"피원에서 컵 가져다가 피사에 있는 테이블에 놔": ("cup", None, P("p1"), P("p4"), "place"),
|
||||||
|
"컵을 p1에 갖다 놔": ("cup", None, "here", P("p1"), "place"),
|
||||||
|
# a person, not a place: asked
|
||||||
|
"bring the cup from p2 to Minsu": ("cup", None, P("p2"), None, "hold"),
|
||||||
|
"p2에서 컵 가져다가 민수한테 줘": ("cup", None, P("p2"), None, "hold"),
|
||||||
|
"빨간 옷 입은 여자분께 컵 갖다 드려": ("cup", None, "here", None, "hold"),
|
||||||
|
}
|
||||||
|
bad = []
|
||||||
|
for text, want in FETCH.items():
|
||||||
|
task, _ = brain.parse_fetch(text, M)
|
||||||
|
got = (task["object"], task["colour"], task["source"], task["dest"], task["finish"]) + \
|
||||||
|
((task["prefer"],) if task.get("prefer") else ())
|
||||||
|
if got != want:
|
||||||
|
bad.append(f"FAIL fetch {text!r}\n want {want}\n got {got}")
|
||||||
|
|
||||||
|
# ---- 2. several parts ----
|
||||||
|
STEPS = {
|
||||||
|
"deliver the cup to p5 and come back": "pick cup | go p5 | give | go here",
|
||||||
|
"take the cup to p5, leave it there and come back": "pick cup | go p5 | place | go here",
|
||||||
|
"컵을 p5에 갖다 주고 돌아와": "pick cup | go p5 | give | go here",
|
||||||
|
"컵 피오에 갖다 놓고 돌아와 주세요": "pick cup | go p5 | place | go here",
|
||||||
|
"컵을 피오에 갖다 드리고 돌아오십시오": "pick cup | go p5 | give | go here",
|
||||||
|
"bring me the cup from p2 and then go back home": "go p2 | pick cup | go here | give | go home",
|
||||||
|
"p2에서 컵 가져다 주고 충전기로 가": "go p2 | pick cup | go here | give | go home",
|
||||||
|
"p1에서 병 가져다 p2에 놔 주고 여기로 돌아와": "go p1 | pick bottle | go p2 | place | go here",
|
||||||
|
"p1에 있는 컵을 p4로 가져다 놔": "go p1 | pick cup | go p4 | place",
|
||||||
|
"go to p3 and wait until someone takes the cup": "go p3 | give",
|
||||||
|
"피삼에 가서 누가 가져갈 때까지 기다려": "go p3 | give",
|
||||||
|
"피삼에 가서 누가 받을 때까지 기다려 주세요": "go p3 | give",
|
||||||
|
"p3에 가서 민수한테 컵 받아서 가져와": "go p3 | receive cup | go here",
|
||||||
|
"go to p3, take the cup from Minsu and bring it to me": "go p3 | receive cup | go here | give",
|
||||||
|
"컵 들고 p2로 가서 거기 있는 사람한테 줘": "pick cup | go p2 | give",
|
||||||
|
"빨간 컵을 p4에 있는 민수한테 갖다 줘": "pick red cup | go p4 | give 민수",
|
||||||
|
"fetch the cup from p1, then wait here": "go p1 | pick cup | go here | wait",
|
||||||
|
"피원에서 빨간 컵 가져다가 피삼에 놔 줘": "go p1 | pick red cup | go p3 | place",
|
||||||
|
"피일에서 컵 가져다 주시고 홈으로 가십시오": "go p1 | pick cup | go here | give | go home",
|
||||||
|
"take the bottle to p2 and wait there until someone takes it, then come back": "pick bottle | go p2 | give | go here",
|
||||||
|
"병 들고 피투로 가서 누가 가져갈 때까지 기다렸다가 돌아와": "pick bottle | go p2 | give | go here",
|
||||||
|
"컵 피삼에 갖다 주고 10초 기다렸다가 홈으로 가": "pick cup | go p3 | give | wait 10 | go home",
|
||||||
|
"빨간 컵을 피사에 갖다 놓으시고 돌아오세요": "pick red cup | go p4 | place | go here",
|
||||||
|
"take the cup to the main stage and hand it to whoever is there": "pick cup | go Main_Stage | give",
|
||||||
|
"find the red cup and bring it to me": "pick red cup | go here | give",
|
||||||
|
"빨간 컵 찾아서 나한테 가져다 줘": "pick red cup | go here | give",
|
||||||
|
"point one에서 빨간 컵 가져와서 P5에 있는 사람한테 줘": "go p1 | pick red cup | go p5 | give",
|
||||||
|
"take the banana to the main stage and give it too Mr. Kim": "pick banana | go Main_Stage | give Mr. Kim",
|
||||||
|
"에구 하얀 컵 집어서 p4로 가져가서 테이블에 놔, 응": "pick white cup | go p4 | place dining table",
|
||||||
|
"p4에 가서 누가 빨간 컵 주면 받아 가지고 와": "go p4 | receive cup wait | go here",
|
||||||
|
"p4 가서 십 초 wait 하고 와": "go p4 | wait 10 | go here",
|
||||||
|
# a new order on the way (lumi.mission_talk reads it with steps.read)
|
||||||
|
"no, bring it to p4 instead": "go p4",
|
||||||
|
"아니야 피사로 가져가 줘": "go p4",
|
||||||
|
"change of plan, go to p4 and put it down": "go p4 | place",
|
||||||
|
"그거 저 사람한테 줘": "give",
|
||||||
|
# calls and endings of every level, Konglish, no spaces
|
||||||
|
"이보게 루미, 피삼에 가서 30초 기다렸다가 돌아오게나": "go p3 | wait 30 | go here",
|
||||||
|
"루미 님께서 피삼으로 가서 30초 기다렸다가 돌아와 주시길 부탁드립니다": "go p3 | wait 30 | go here",
|
||||||
|
"아야 루미, 피투로 가서 1분 기다렸다가 돌아와 주시겄슈": "go p2 | wait 60 | go here",
|
||||||
|
"우리 루미, 피투로 가서 한 바퀴 돌고 돌아와 주라~": "go p2 | turn 360 | go here",
|
||||||
|
"자네, 피투로 가서 오더 받고 컴백해 주게나": "go p2 | wait order | go here",
|
||||||
|
"피사에가서5분있다가다시오세요": "go p4 | wait 300 | go here",
|
||||||
|
"홈 포지션에 들렀다가 피투로 가게나": "go home | go p2",
|
||||||
|
}
|
||||||
|
for text, want in STEPS.items():
|
||||||
|
got, unread = steps.rules(text, M)
|
||||||
|
if unread or got != [short(s.strip()) for s in want.split(" | ")]:
|
||||||
|
bad.append(f"FAIL steps {text!r}\n want {want}\n got {got}\n unread {unread}")
|
||||||
|
|
||||||
|
# ---- 3. holding: put it at a place = a drive there and a put-down ----
|
||||||
|
for text in ("put it on p3", "p3에 갖다 놔", "피삼에 놔 줘", "leave it at the registration"):
|
||||||
|
got, unread = steps.rules(text, M)
|
||||||
|
if unread or [s["do"] for s in got] != ["go", "place"]:
|
||||||
|
bad.append(f"FAIL put at {text!r}: {got} {unread}")
|
||||||
|
|
||||||
|
# ---- near misses: nothing is read as a task part ----
|
||||||
|
NEAR = ["did you bring the cup from p1 and go home?", "don't bring the cup from p1, go home", "I'll bring the cup from p1 myself",
|
||||||
|
"tomorrow bring me the cup from p1 and go to p2", "my friend brought the cup from p1 and went home",
|
||||||
|
"p1에서 컵 가져오지 마", "내가 p1에서 컵 가져올게", "어제 p1에서 컵 가져왔지?", "컵을 p5에 갖다 줬어?",
|
||||||
|
"p3에 갖다 놓지 마", "did you deliver the cup to p5?"]
|
||||||
|
for text in NEAR:
|
||||||
|
got, unread = steps.rules(text, M)
|
||||||
|
if not unread and got:
|
||||||
|
bad.append(f"FAIL near miss {text!r}: {got}")
|
||||||
|
|
||||||
|
# ---- 4. a correction after the read-back (fetch_dialog): what changes ----
|
||||||
|
T = {"object": "cup", "colour": "red", "source": P("p1"), "dest": "here", "finish": "hold"}
|
||||||
|
FIX = {"no, the blue one": {"colour": "blue"}, "아니 파란 거": {"colour": "blue"}, "not p1, p2": {"source": P("p2")},
|
||||||
|
"피원 말고 피투": {"source": P("p2")}, "the one on the left": {"prefer": "left"}, "왼쪽 거": {"prefer": "left"},
|
||||||
|
"the smaller one": {"prefer": "small"}, "아니 작은 거": {"prefer": "small"}, "no, from p2": {"source": P("p2")},
|
||||||
|
"아니 피사로": {"dest": P("p4")}, "no, the bottle": {"object": "bottle", "colour": None},
|
||||||
|
"the other one": {}, "아니 다른 거": {}} # not said which: nothing changes, Lumi asks what to change
|
||||||
|
for text, want in FIX.items():
|
||||||
|
task, changed = brain.parse_correction(text, T, M)
|
||||||
|
if {k: task.get(k) for k in changed} != want:
|
||||||
|
bad.append(f"FAIL correction {text!r}: want {want}, got {({k: task.get(k) for k in changed})}")
|
||||||
|
|
||||||
|
print("\n".join(bad))
|
||||||
|
print(f"{len(FETCH) + len(STEPS) + len(FIX) + len(NEAR) + 4 - len(bad)}/{len(FETCH) + len(STEPS) + len(FIX) + len(NEAR) + 4} right")
|
||||||
|
assert not bad
|
||||||
|
print("fetch words ok")
|
||||||
@@ -203,4 +203,27 @@ if __name__ == "__main__":
|
|||||||
assert brain._follow_examples(t, h), t
|
assert brain._follow_examples(t, h), t
|
||||||
for t in ("Where is p3?", "세종대왕이 누구예요?", "oh cool", "What's your name?", "Tell me about the Korean War."):
|
for t in ("Where is p3?", "세종대왕이 누구예요?", "oh cool", "What's your name?", "Tell me about the Korean War."):
|
||||||
assert not brain._follow_examples(t, h), t
|
assert not brain._follow_examples(t, h), t
|
||||||
|
# a world subject keeps Lumi's notes out (also lower-case English and a part named after it); Lumi's own things keep them
|
||||||
|
b = brain.Brain()
|
||||||
|
for h, t, want in (([], "Why do whales sing?", ["whales"]), ([], "부엉이는 고개를 몇 도까지 돌려요?", ["부엉이"]),
|
||||||
|
([("Why do whales sing?", "ACTION: none -\nTo find mates.")], "How far can the song go?", ["whales"]),
|
||||||
|
([("문어는 다리가 몇 개고?", "ACTION: none -\n여덟 개예요.")], "심장은 몇 개고?", ["문어", "다리", "심장"]),
|
||||||
|
([], "속도는 얼마예요?", []), ([], "How fast can you go?", []), ([], "Is the song yours?", []),
|
||||||
|
([], "Can the arm lift 2 kg?", [])):
|
||||||
|
b.history = list(h)
|
||||||
|
assert b.world_talk(t) == want, (t, b.world_talk(t))
|
||||||
|
# "really?" after a turn Lumi did not catch asks about the answer before it
|
||||||
|
h = [("롯데월드타워 높이 몇 m예요?", "ACTION: none -\n555미터예요."),
|
||||||
|
("uh... what was it... 그...", "ACTION: unclear -\n죄송해요, 다시 말씀해 주시겠어요?")]
|
||||||
|
assert brain.topic_turn(h)[0].startswith("롯데월드타워"), brain.topic_turn(h)
|
||||||
|
# the model's "search" with its answer after it: said (none); a lookup promise or "don't know" keeps the search
|
||||||
|
s = {"action": "search", "target": "x"}
|
||||||
|
q = "윤초는 뭐예요?"
|
||||||
|
for w in ("윤초는 지구 자전과 시계를 맞추는 1초예요.", "Mount Fuji is 3,776 metres high."):
|
||||||
|
assert brain.Brain._settled(s, w, q)["action"] == "none", w
|
||||||
|
for w in ("확인해 볼게요.", "Let me check.", "search whale song distance", "잘 모르겠어요.", "", "윤초는 뭐예요?",
|
||||||
|
"윤초가 궁금하시군요. 잠시만요.", "What exactly do you mean?"):
|
||||||
|
assert brain.Brain._settled(s, w, q) is s, w
|
||||||
|
assert brain.CHANGES.search("지금 비트코인 얼마야?") and brain.CHANGES.search("Who won the game yesterday?")
|
||||||
|
assert not brain.CHANGES.search("윤초는 뭐예요?") and not brain.CHANGES.search("How do bees dance?")
|
||||||
print("followup ok")
|
print("followup ok")
|
||||||
|
|||||||
@@ -0,0 +1,17 @@
|
|||||||
|
"""Korean speech levels read as the English request (a fixed part of tests/ko_levels_check.py): every level of a few
|
||||||
|
capabilities gives the same action, and the same phrase said as a past, a negation, a later time or a condition
|
||||||
|
gives no motion. No robot; the embedding server answers the bank.
|
||||||
|
|
||||||
|
.venv/bin/python tests/test_ko_levels.py
|
||||||
|
"""
|
||||||
|
from tests import ko_levels_check
|
||||||
|
|
||||||
|
CAPS = {"wave", "turn45", "head_up", "follow", "fetch", "go_to"}
|
||||||
|
|
||||||
|
rows = ko_levels_check.check(CAPS)
|
||||||
|
bad = [r for r in rows if r[-1] != "right"]
|
||||||
|
for name, level, text, got, want, v in bad:
|
||||||
|
print(f"FAIL {name} [{level}] {text!r} -> {got} (want {want}, {v})")
|
||||||
|
assert not bad, f"{len(bad)} of {len(rows)} not right"
|
||||||
|
assert len(rows) > 400, len(rows)
|
||||||
|
print(f"ok: {len(rows)} forms")
|
||||||
@@ -0,0 +1,142 @@
|
|||||||
|
"""Commands, questions and asides through the voice / Command box route (command_check.rules = lumi.route without the
|
||||||
|
LLM), night 4: tag questions, take-backs at every Korean level, other people addressed, polite stops, chains that are
|
||||||
|
one order, amounts not read. A wrong motion is the worst error: None (the LLM reads it) is right for the no-motion
|
||||||
|
cases. No robot.
|
||||||
|
|
||||||
|
.venv/bin/python tests/test_route_words.py
|
||||||
|
"""
|
||||||
|
from assistant import brain, detour
|
||||||
|
from tests import command_check
|
||||||
|
|
||||||
|
M = ["p1", "p2", "p3", "p5", "p6", "home", "dock2"]
|
||||||
|
CASES = [ # (text, state, route)
|
||||||
|
# a statement with a tag, an ability said back: asked
|
||||||
|
("you went to P5 earlier, right?", "idle", None), ("you can lift your arm, right?", "idle", None),
|
||||||
|
("너 팔 접을 수 있지, 그치?", "idle", None), ("너 팔 접을 수 있지?", "idle", None), ("wave, right?", "idle", "action:wave"),
|
||||||
|
("손 흔들고 나 봐, 알았지?", "idle", "chain:wave+look_me"), ("팔 접어, 알겠죠?", "idle", "action:arm fold"),
|
||||||
|
("팔 뻗을 줄 아세요?", "idle", None), ("팔을 뻗을 줄 압니까?", "idle", None), ("robot, you know how reach out to me?", "idle", None),
|
||||||
|
("robot can say hi with your hand or not? I just ask", "idle", None), ("멸 센티까지 잡아?", "idle", None),
|
||||||
|
("Back to your arm, what did you say?", "idle", None),
|
||||||
|
# one order, not a chain
|
||||||
|
("손 흔들어서 작별 인사 해 주시겠어요?", "idle", "action:wave"), ("손 흔들어서 인사해", "idle", "action:wave"),
|
||||||
|
("컵 들고 몇으로 가?", "idle", None), ("잔 들고 천천히 가는 속도가 얼마야?", "idle", None),
|
||||||
|
("하객분들 앞에서 손 거둬!, 아 거두시겠어요?", "idle", "action:arm fold"),
|
||||||
|
("로봇아, 좌측으로 10 센티미터 움직여라, 아 움직여 주실래요?", "idle", "action:move left 0.1"),
|
||||||
|
("이장이 말하는디, 팔 제자리로 해", "idle", "action:arm fold"), ("take your hand back, da?", "idle", "action:arm fold"),
|
||||||
|
("so, robot, head to p6, da?", "idle", "action:go_to p6"), ("could you possibly hand it over?, eh?", "holding", "give"),
|
||||||
|
("exactly please I'll hold it, give it here", "holding", "give"),
|
||||||
|
("pick up the cup, how fast do you go?", "idle", "chain:steps+talk"), ("고개 들고 몇 시야?", "idle", "chain:look_up+talk"),
|
||||||
|
("치수 불러 줄게, 내 머리 무슨 색이야?", "idle", "seeing"),
|
||||||
|
# handed over or not
|
||||||
|
("이거 줄게", "idle", "receive"), ("컵 줄게요", "idle", "receive cup"), ("사진 찍어 줄게", "idle", None),
|
||||||
|
("자 그럼 Lumi, wave your hand 해 봐요", "holding", "refuse"), ("give 해 줘", "holding", "give"),
|
||||||
|
("it'd be cool if you could give me the cup someday", "holding", None),
|
||||||
|
# polite stops, calls, Konglish
|
||||||
|
("멈춰 주시겠어요?", "idle", "stop"), ("멈춰 주실래요?", "idle", "stop"), ("정지해 주시겠습니까?", "idle", "stop"),
|
||||||
|
("can you stop for me?", "idle", "stop"), ("루미 씨, 잠깐 멈춰 주실 수 있나요?", "idle", "stop"),
|
||||||
|
("can you stop for coffee?", "idle", None), ("루미 씨, 팔 접어 주세요", "idle", "action:arm fold"),
|
||||||
|
("컴 히어 해 줘", "idle", "action:come"), ("이리 컴", "idle", "action:come"), ("컴퓨터 꺼 줘", "idle", None),
|
||||||
|
# other people addressed
|
||||||
|
("쉿 아기 자니까 엄마 그거 나 줘", "holding", None), ("질문을 바꿔서, 엄마 그거 나 줘", "holding", None),
|
||||||
|
("이륙 전 점검, 할머니 이제 팔 접어 좀", "idle", None), ("어머님, 컵을 들어 보세요, 저기 로봇 있어요", "idle", None),
|
||||||
|
("김 군, 자네도 팔 뻗어 보게", "idle", None), ("우리 아들, 빠빠이 해 봐 봐~", "idle", None),
|
||||||
|
("shh, Sarah, make your way to p2", "idle", None), ("우리 p3 갈까 여보", "idle", None),
|
||||||
|
("루미야 할머니한테 손 흔들어 줘", "idle", "action:wave"), ("okay, Lumi, go to p5", "idle", "action:go_to p5"),
|
||||||
|
# taken back, later, negated: every level
|
||||||
|
("로봇 씨, 손 흔들어 주시길 바랍니다, 아, 하지 않으셔도 됩니다", "idle", "talk"), ("저기유, 손 흔들어 줘유, 아녀, 됐슈", "idle", None),
|
||||||
|
("악수해 주십시오, 아닙니다, 취소하겠습니다", "idle", "talk"), ("루미야~ 나랑 악수해~, 장난이야~", "idle", "talk"),
|
||||||
|
("wave 해 줄 수 있지?, 아냐 아냐 됐어 ㅋㅋ", "idle", "talk"), ("음악 나오믄 악수해 보이소", "idle", None),
|
||||||
|
("나중에~ 손 wave 해~", "idle", None), ("행사가 끝난 후에 나한테 손 흔드십시오", "idle", None),
|
||||||
|
("robot, if I say go, then reach out to me", "idle", None), ("you not give me the cup", "holding", None),
|
||||||
|
("no hold out your hand, please", "idle", None),
|
||||||
|
("no need to return it to where it was", "holding", None), ("put down 하지 않으셔도 됩니다", "holding", None),
|
||||||
|
("파란 컵 좀 들지 마이소", "idle", None), ("자네 컵 잡는 거 제법이더군", "idle", None),
|
||||||
|
# 하게체 / dialect requests to Lumi, floor, status
|
||||||
|
("자네, 손을 흔들어 주게나", "idle", "action:wave"), ("이보게 루미, 악수하게", "idle", "action:wave"),
|
||||||
|
("나한테 손 흔들어 줄 수 있지?", "idle", "action:wave"), ("어이 로봇아, 손 흔들어 주드라고", "idle", "action:wave"),
|
||||||
|
("바닥에 내려놔 주이소", "holding", "refuse"), ("의자 밑에 놔", "holding", "refuse"), ("의자 위에 놔", "holding", "place chair"),
|
||||||
|
("그리퍼 오픈 상태야?", "idle", "status"), ("is it possible for you to open your fingers, in general?", "idle", None),
|
||||||
|
("can you look up for me?", "idle", "action:look up"), ("would you stop, please?", "idle", "stop"),
|
||||||
|
("흰색 머그컵 잡아!, 아 잡아 줄 수 있어요?", "idle", "action:pick white cup"),
|
||||||
|
("제자리에, 루미, 손 앞으로 내밀어 봐", "idle", "action:arm reach"), ("Lumi, I heard you can put that back", "holding", None),
|
||||||
|
# gives at every level, self-corrections said again, head / body / base words
|
||||||
|
("로봇아, 선생님께 드려라", "holding", "give"), ("자네, 할머니께 드리시게", "holding", "give"),
|
||||||
|
("grandma한테주십시오", "holding", "give"), ("루미, 이리 좀 조", "holding", "give"), ("루미야, 기브 미 해 주세여", "holding", "give"),
|
||||||
|
("로봇아, 그거 주세요", "idle", "empty_hand"), ("좌측으로 20센티 움직여 줘, 아니 움직이실래요?", "idle", "action:move left 0.2"),
|
||||||
|
("루미야 우측으로 15도 돌아 봐, 아니 돌아 봐요 허허", "idle", "action:turn right 15"), ("p6로 가, 아니지 p2로 가", "idle", "action:go_to p2"),
|
||||||
|
("이제 팔 접어 좀. 아니야 그냥 있어", "idle", "talk"), ("두 걸음 뒤로 물러서 줘, 부탁해", "idle", "action:move back 1"),
|
||||||
|
("어이로봇아,상체오른쪽으로십오도쫌돌려줘유", "idle", None), ("저기 루미야, 웨이스트 레프트로 좀 돌리세요", "idle", "action:waist left"),
|
||||||
|
("몸통째 왼쪽으로 돌려", "idle", "action:turn left 90"), ("실례합니다. 왼쪽을 돌아봐 주시겠습니까?", "idle", "action:look left"),
|
||||||
|
("look right at me 해 하하", "idle", "action:look me"), ("Lumi go ahead and look down at the ground", "idle", "action:look down"),
|
||||||
|
("루미 씨, 발 밑 바라보지 마세요", "idle", None), ("쳐다보지 마", "idle", "action:look away"),
|
||||||
|
("prove you're smart: come on back", "idle", "action:come_back"), ("루미 360 돌아 봐", "idle", "action:turn right 360"),
|
||||||
|
("dude, stick your hand out", "idle", None), ("dude, halt", "idle", "stop"), ("손님상에 여보 후진 2미터 반 움직여 봐", "idle", None),
|
||||||
|
("이따가 멈춰 주세요", "idle", None),
|
||||||
|
# amounts
|
||||||
|
("루미,앞으로삼십센티미터가", "idle", "ask"), ("뒤로1미터50이동해부러", "idle", "action:move back 1.5"),
|
||||||
|
("앞으로 30센티 가", "idle", "action:move forward 0.3"),
|
||||||
|
# a stop for later or reported (night 4, round 3)
|
||||||
|
("행사가 끝난 후에 멈춰 주시길 바랍니다", "idle", None), ("내일 그만하시게", "idle", None),
|
||||||
|
("아까 직원분이 그만하라고 지시했습니다", "idle", None), ("루미 군, 그만하시게", "idle", "stop"),
|
||||||
|
("저기요, 당장 멈춰 주시길 바랍니다", "idle", "stop"),
|
||||||
|
# turn (try turning) or look round; a correction said as a new order in full
|
||||||
|
("왼쪽으로 돌아 봐", "idle", "action:turn left 90"), ("오른쪽으로 돌아봐 줄래요?", "idle", "action:look right"),
|
||||||
|
("왼쪽으로 돌아보시게", "idle", "action:look left"), ("레프트 턴 해 봐", "idle", "action:turn left 90"),
|
||||||
|
("루미 오른편으로 135도 돌아— 아니 왼편으로 백이십 도 돌아 주세요~", "idle", "action:turn left 120"),
|
||||||
|
("우리 루미, 오른쪽으로 백삼십오 도 돌아... 아 잘못 말했다, 몸통째 왼쪽으로 돌려 주세요", "idle", "action:turn left 90"),
|
||||||
|
("go forward half a metre, no wait, back up 10 cm", "idle", "action:move back 0.1"),
|
||||||
|
("turn left 45 degrees, no, right", "idle", "action:turn right 45"),
|
||||||
|
("좌측으로 20센티 움직여 줘, 아니 움직이실래요?", "idle", "action:move left 0.2"),
|
||||||
|
("부스 B로 가서 왼쪽으로 돌아요", "idle", "talk"), ("hello robot, please come back for me, thank you", "idle", "action:come_back"),
|
||||||
|
("애플 그랩 해", "idle", "action:pick apple"), ("실례합니다. 제자리에 지금 갖다 놓으십시오", "holding", "action:put back"),
|
||||||
|
# round 4: new wordings
|
||||||
|
("back to your arm. what was it again?", "idle", None), ("now face the other way", "idle", "action:turn around 180"),
|
||||||
|
("do a 180, please", "idle", "action:turn around 180"), ("룩 다운 해 주세요", "idle", "action:look down"),
|
||||||
|
("룩 앳 미 해 줘", "idle", "action:look me"), ("룩 업 할 수 있어?", "idle", None),
|
||||||
|
("바이바이 좀 하세요", "idle", "action:wave"), ("어이 로봇, 빠빠이 하시게", "idle", "action:wave"),
|
||||||
|
("멈추시게", "idle", "stop"), ("hold it right there", "idle", "stop"), ("내일 멈추시게", "idle", None),
|
||||||
|
("you put down arm please", "idle", "action:arm fold"), ("어이 로봇아, 손 쪼까 내려 줘", "idle", "action:arm fold"),
|
||||||
|
("Lumi, may I ask you to stretch your arm out?", "idle", "action:arm reach"), ("is your arm out?", "idle", "status"),
|
||||||
|
("Lumi, robot, put it down ok?", "holding", "place"), ("I put it down, now?", "holding", "seeing"),
|
||||||
|
("할머니 드려라", "holding", "give"), ("우리 할머니 드리십시오", "holding", "give"), ("전화 드려", "holding", None),
|
||||||
|
("인사 드려", "holding", None), ("연락 줘", "holding", None),
|
||||||
|
("손 흔들면서 인사하고 고개 숙여", "idle", "chain:wave+look_down"),
|
||||||
|
("왔던 길로 돌아가", "idle", "action:come_back"), ("원래 있던 자리로 가 주세요", "idle", "action:come_back"),
|
||||||
|
("go back the way you came", "idle", "action:come_back"), ("원래 있던 자리로 가지 마", "idle", None),
|
||||||
|
("어제 왔던 길로 가면 돼요", "idle", None), ("knock it off, Lumi", "idle", "stop"), ("whoa there", "idle", "stop"),
|
||||||
|
("whoa, that's cool", "idle", None), ("lemme have it", "holding", "give"),
|
||||||
|
# "would you mind …ing", polite conditions and "-주시면 안 될까요" (lead, 11:30)
|
||||||
|
("would you mind shaking hands", "idle", "action:wave"), ("would you mind coming here?", "idle", "action:come"),
|
||||||
|
("do you mind waving at the kids?", "idle", "action:wave"), ("would you mind stopping here, please", "idle", "stop"),
|
||||||
|
("would you mind if I took a photo?", "idle", None), ("would you mind not moving?", "idle", None),
|
||||||
|
("손 흔들어 주시면 안 될까요?", "idle", "action:wave"), ("괜찮으시면 악수해 주실래요?", "idle", "action:wave"),
|
||||||
|
("p3로 가 주시면 안 될까요?", "idle", "action:go_to p3"), ("실례가 안 된다면 이리 와 주시겠어요?", "idle", "action:come"),
|
||||||
|
("혹시 괜찮으시면 컵 좀 집어 주실 수 있을까요?", "idle", "action:pick cup"), ("if you don't mind, wave at me", "idle", "action:wave"),
|
||||||
|
("괜찮으시면 손 흔들지 마세요", "idle", None), ("괜찮으시면 내일 p3로 가 주세요", "idle", None),
|
||||||
|
("괜찮으시면 저한테 주시면 안 될까요?", "holding", "give"), ("hello robot", "idle", None),
|
||||||
|
("hello robot, wave", "idle", "action:wave"),
|
||||||
|
]
|
||||||
|
|
||||||
|
DETOUR = [ # right after a blocked drive to p2: (text, detour.read)
|
||||||
|
("아까 저 아저씨가 루미한테 다시 가라고 했어", None), ("아까 재시도하는 거 정말 신기했어요", None),
|
||||||
|
("다른 루트로 가시겠어요?, 아, 아닙니다, 괜찮습니다", None), ("얘 뒤로 조금 갔다가 다시 가는 거 봤냐?", None),
|
||||||
|
("지가 말하믄 재시도해부러", None), ("다시 시도할 줄은 알아?", None), ("그냥 돌아올 줄 아는가?", None),
|
||||||
|
("다시 시도해 줘", "retry"), ("다른 길로 가 주세요", "around"), ("루미야 포기하지 마", "retry"),
|
||||||
|
("never mind that, just try again", "retry"),
|
||||||
|
("루미야, 다른 길 있나 민수야?", None), ("여러분, 모두 포기하고 돌아와 보시기 바랍니다", None),
|
||||||
|
]
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
detour.recent = lambda: None # no blocked drive just now (whatever the live state says)
|
||||||
|
bad = [f"detour {t!r} -> {detour.read(t, M, 'p2')!r} (want {w!r})" for t, w in DETOUR if detour.read(t, M, "p2") != w]
|
||||||
|
for text, state, want in CASES:
|
||||||
|
got = command_check.rules(text, state, M, brain.Brain())
|
||||||
|
if got != want:
|
||||||
|
bad.append(f"{text!r} [{state}] -> {got!r} (want {want!r})")
|
||||||
|
print("\n".join(bad) or f"route words ok ({len(CASES)} cases)")
|
||||||
|
assert not bad
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
main()
|
||||||
+3
-1
@@ -118,7 +118,8 @@ said = lambda: [d[1] for d in done if isinstance(d, tuple) and d[0] == "say"]
|
|||||||
# ---- the calls that wake Lumi (EN + KO + whisper slips) and what does not ----
|
# ---- the calls that wake Lumi (EN + KO + whisper slips) and what does not ----
|
||||||
for call in ("Lumi.", "Hi Lumi.", "Hi.", "Hello Lumi!", "Hello.", "Hey Lumi", "How are you?", "Hi, how are you?",
|
for call in ("Lumi.", "Hi Lumi.", "Hi.", "Hello Lumi!", "Hello.", "Hey Lumi", "How are you?", "Hi, how are you?",
|
||||||
"루미야.", "루미.", "안녕.", "안녕하세요.", "하이.", "하이 루미!", "Hi, Loomi.", "Hello, Rumi.", "Hai.",
|
"루미야.", "루미.", "안녕.", "안녕하세요.", "하이.", "하이 루미!", "Hi, Loomi.", "Hello, Rumi.", "Hai.",
|
||||||
"Lummy?", "누미야", "안녕하십니까."):
|
"Lummy?", "누미야", "안녕하십니까.", "Wake up.", "Wake up, Lumi!", "Hey Lumi.", "Lumi, wake up.",
|
||||||
|
"헤이 루미", "루미야 일어나", "루미 일어나세요.", "일어나세요.", "깨어나 루미야"):
|
||||||
L = fresh()
|
L = fresh()
|
||||||
L.mic = Mic(U(call))
|
L.mic = Mic(U(call))
|
||||||
assert L.check_wake(), call
|
assert L.check_wake(), call
|
||||||
@@ -128,6 +129,7 @@ for heard in ("Let's make music.", "What is that?", "We make it.", "Let's.", "It
|
|||||||
L.mic = Mic(U(heard))
|
L.mic = Mic(U(heard))
|
||||||
assert not L.check_wake(), heard # 16:57:00, 17:05:03 live: "(no wake word)"
|
assert not L.check_wake(), heard # 16:57:00, 17:05:03 live: "(no wake word)"
|
||||||
assert not lumi.call_only("Lumi, what time is it?") and not lumi.call_only("루미야 노래 불러줘")
|
assert not lumi.call_only("Lumi, what time is it?") and not lumi.call_only("루미야 노래 불러줘")
|
||||||
|
assert not lumi.WAKE.search("I wake up at 7 every day") and not lumi.WAKE.search("일어나서 밥 먹었어") # no call
|
||||||
L = fresh() # "How are you?" is answered, not "Yes? How can I help?"
|
L = fresh() # "How are you?" is answered, not "Yes? How can I help?"
|
||||||
L.mic = Mic(U("How are you?"))
|
L.mic = Mic(U("How are you?"))
|
||||||
L.check_wake()
|
L.check_wake()
|
||||||
|
|||||||
Reference in New Issue
Block a user