Improve Korean understanding in casual, rude, formal and suggestion forms
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -307,6 +307,44 @@ _BANK = {
|
||||
},
|
||||
}
|
||||
|
||||
_BANK["registers"] = { # one order said casually, rudely, politely, formally: the same action; Lumi stays polite
|
||||
"en": [
|
||||
("Yo, turn left.", "turn left 90", "Okay, turning left."),
|
||||
("Would you be so kind as to turn left?", "turn left 90", "Of course, turning left."),
|
||||
("Get over here, now.", "come", "Coming."),
|
||||
("Could you possibly come over here?", "come", "Sure, I'm coming."),
|
||||
("Hey, shake your hand.", "wave", "Sure, waving!"),
|
||||
("Shake hand, buddy.", "wave", "Sure, here's a wave!"),
|
||||
("Mind following me for a bit?", "follow", "Sure, I'll follow you."),
|
||||
("Look at me, will ya?", "look me", "Okay, I'm looking at you."),
|
||||
],
|
||||
"ko": [
|
||||
("야, 왼쪽으로 돌아라.", "turn left 90", "네, 왼쪽으로 돌게요."),
|
||||
("좌회전 해.", "turn left 90", "네, 왼쪽으로 돌게요."),
|
||||
("왼쪽으로 회전해 주시겠습니까?", "turn left 90", "네, 왼쪽으로 돌겠습니다."),
|
||||
("야 빨리 이리 와.", "come", "네, 갈게요."),
|
||||
("이쪽으로 와 주시겠어요?", "come", "네, 갈게요."),
|
||||
("이리 오십시오.", "come", "네, 가겠습니다."),
|
||||
("손 흔들어 봐라.", "wave", "네, 손 흔들게요!"),
|
||||
("손 좀 흔들어 주시겠어요?", "wave", "네, 손 흔들게요!"),
|
||||
("악수 한번 하자.", "wave", "좋아요, 악수해요!"),
|
||||
("저 따라다녀 주세요.", "follow", "네, 따라갈게요."),
|
||||
("야 나 따라와라.", "follow", "네, 따라갈게요."),
|
||||
("앞으로 1미터 전진해.", "move forward 1", "네, 앞으로 1미터 갈게요."),
|
||||
("50센티만 뒤로 물러나 주십시오.", "move back 0.5", "네, 뒤로 50센티 물러나겠습니다."),
|
||||
("고개 들어라.", "look up", "네, 위를 볼게요."),
|
||||
("고개를 드세요.", "look up", "네, 위를 볼게요."),
|
||||
("야 나 좀 봐.", "look me", "네, 보고 있어요."),
|
||||
("저를 봐 주시겠습니까?", "look me", "네, 보고 있겠습니다."),
|
||||
("손 내밀어 봐.", "arm reach", "네, 손을 내밀게요."),
|
||||
("팔 접어라.", "arm fold", "네, 팔을 접을게요."),
|
||||
("야 너 손 흔들 줄 아냐?", "none", "네, 흔들 수 있어요. 흔들어 드릴까요?"),
|
||||
("아까 너 손 흔들었잖아.", "none", "네, 아까 흔들었어요."),
|
||||
("손 흔들지 마라.", "none", "네, 안 흔들게요."),
|
||||
("얘, 이리 와 봐.", "none", "아이가 귀엽네요."),
|
||||
],
|
||||
}
|
||||
|
||||
EXAMPLES = [(cat, lang, said, reply, action)
|
||||
for cat, langs in _BANK.items() for lang, rows in langs.items() for said, action, reply in rows]
|
||||
|
||||
|
||||
@@ -0,0 +1,40 @@
|
||||
"""More English sentences of the same meaning: other verbs and idioms for the same order ("face left", "do a u-turn",
|
||||
"bow your head", "eyes on me", "lend me your hand", "tag along", "stick with me", "go get the cup for me"), each with
|
||||
the frames people put around it (please, could you, would you mind, I need you to, slang, non-native)."""
|
||||
|
||||
FRAMES = ["{}", "please {}", "{}, please", "could you {}?", "can you {}?", "would you {}?", "can you {} for me?",
|
||||
"I need you to {}", "I'd like you to {}", "go ahead and {}", "{} now", "yo, {}", "just {}", "lumi, {}",
|
||||
"you {} please", "{} pls", "can u {}", "would you please {}?", "hey, {} would ya"]
|
||||
|
||||
|
||||
def _with(phrases):
|
||||
return list(dict.fromkeys(f.format(p) for p in phrases for f in FRAMES))
|
||||
|
||||
|
||||
INTENT = {
|
||||
"turn": _with(["face left", "face right", "face the other way", "turn the other way", "do a u-turn", "make a u-turn",
|
||||
"rotate one eighty", "turn one eighty", "pivot left", "pivot right", "swing left", "swing right",
|
||||
"turn your body to the left", "turn your body to the right", "about face", "flip around"]),
|
||||
"look": _with(["bow your head", "nod your head down", "look at the ceiling", "look at the floor", "eyes on me",
|
||||
"turn to me", "turn your head to me", "look my way", "look in my direction", "eyes up",
|
||||
"eyes down", "glance up", "glance down", "peek left", "peek right", "check out the ceiling"]),
|
||||
"come_back": _with(["go back to your spot", "return to where you started", "come back to where you were",
|
||||
"go back where you came from", "back to your starting point", "return to your spot",
|
||||
"head back to where you were"]),
|
||||
"arm_reach": _with(["lend me your hand", "let me hold your hand", "give me a hand to hold", "stick your hand out",
|
||||
"put your arm out", "offer me your hand"]),
|
||||
"arm_open": _with(["release the gripper", "let go with your gripper", "loosen your grip", "unclench your hand",
|
||||
"open up your fingers", "relax your fingers"]),
|
||||
"arm_close": _with(["clench your hand", "tighten your grip", "grip tight", "squeeze your fingers shut"]),
|
||||
"fetch": _with(["go get the <obj> for me", "go get me the <obj>", "fetch me the <obj>", "grab me the <obj>",
|
||||
"bring the <obj> my way", "get the <obj> and bring it here", "could you bring over the <obj>",
|
||||
"pass me the <obj>"]),
|
||||
"lift": _with(["get taller", "raise yourself up", "make yourself shorter", "lower yourself", "make yourself taller"]),
|
||||
# not "go up / down a bit": "move up a smidge" is a drive forward
|
||||
"follow": _with(["tag along", "stick with me", "come along with me", "walk behind me", "stay on my heels",
|
||||
"keep up with me", "come with me, buddy"]),
|
||||
"come": _with(["get over here", "come over to me", "come on over", "come closer to me", "scoot over here",
|
||||
"roll over here", "make your way over here"]),
|
||||
"wave": _with(["do you shake your hand", "do you wave", "shake my hand", "give me a handshake", "high five me",
|
||||
"wave goodbye", "give a little wave", "wave your hand at me"]),
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
"""More English questions about Lumi in casual / chat / non-native wording ("who put you together?", "you gonna hurt
|
||||
me?", "u do stairs?"), for the quick answers' kinds."""
|
||||
|
||||
QUICK = {
|
||||
"name": ["what do they call you", "what do people call you", "what should i call you", "got a name", "name please",
|
||||
"what's your name buddy", "what are you called", "how should i address you"],
|
||||
"age": ["how old is this robot", "are you new", "how long have you existed", "when were you born",
|
||||
"what year were you made", "how many years old are you"],
|
||||
"maker": ["who put you together", "who designed you", "who created you", "which company made this", "who's your maker",
|
||||
"where do you come from, which company", "who invented you"],
|
||||
"height": ["you're tall, how tall exactly", "how high are you", "what's your height in centimeters",
|
||||
"how tall is lumi"],
|
||||
"cameras": ["where are your cameras", "what do you see with", "where are your eyes",
|
||||
"do you have cameras", "camera how many you have"],
|
||||
"safety": ["are you going to hurt me", "will you hurt me", "are you dangerous", "can you hurt people",
|
||||
"is it safe near you", "should i be scared of you"],
|
||||
"stairs": ["do you do stairs", "can you take the stairs", "can you go upstairs", "can you climb steps",
|
||||
"can you go up stairs by yourself"],
|
||||
"how_are_you": ["what's up", "how you doing", "how have you been", "you good", "how's your day", "how's life"],
|
||||
"can_sing": ["you sing", "can you sing a bit", "do you know any songs", "are you a singer"],
|
||||
"battery_life": ["how long can you run", "how long do you last", "how long till you need charging",
|
||||
"how many hours on one charge"],
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
"""More Korean sentences of the same meaning for the body moves: other verbs (전진, 후진, 물러나, 좌회전, 따라다녀,
|
||||
뒤따라와 …), other word orders ("1미터 앞으로" / "앞으로 1미터") and the casual / rude register (명령조: "가라",
|
||||
"빨리 와", "당장 돌아", "봐라"), on top of korean_levels.py's fronts x verbs x endings."""
|
||||
from assistant.bank_words import korean_levels as kl
|
||||
|
||||
kl.VERBS.update({
|
||||
"뒤따라와": ("뒤따라와", "뒤따라오"), "따라붙어": ("따라붙어", "따라붙으"), "전진": ("전진해", "전진하"),
|
||||
"후진": ("후진해", "후진하"), "물러나": ("물러나", "물러나"), "빠져": ("빠져", "빠지"), "나가": ("나가", "나가"),
|
||||
"좌회전": ("좌회전해", "좌회전하"), "우회전": ("우회전해", "우회전하"), "틀어": ("틀어", "트"), "출발": ("출발해", "출발하"),
|
||||
"고개들어": ("들어", "드"), "챙겨": ("챙겨", "챙기"), "내려놓아": ("내려놓아", "내려놓으"),
|
||||
})
|
||||
|
||||
# the casual / rude register: a bare order with -라, a "hurry", a "now"
|
||||
RUDE = ["{a}라", "{a} 봐라", "{a}라고", "빨리 {a}", "{a}, 빨리", "{a} 빨리", "당장 {a}", "얼른 {a}", "어서 {a}", "빨리 {a}라",
|
||||
"{a}라니까", "{a}라 좀", "냉큼 {a}"]
|
||||
|
||||
|
||||
def _make(fronts, verbs):
|
||||
out = kl._make(fronts, verbs)
|
||||
for f in fronts:
|
||||
for v in verbs:
|
||||
for e in RUDE:
|
||||
t = kl._say(f, v, e)
|
||||
if t and t not in out:
|
||||
out.append(t)
|
||||
return out
|
||||
|
||||
|
||||
_FWD = ["앞으로 ", "앞쪽으로 ", "1미터 앞으로 ", "앞으로 1미터 ", "한 걸음 앞으로 ", "두 걸음 앞으로 ", "조금만 앞으로 ",
|
||||
"1미터만 앞으로 ", "앞으로 조금 ", "30센티 앞으로 "]
|
||||
_BACK = ["뒤로 ", "뒤쪽으로 ", "50센티 뒤로 ", "뒤로 50센티 ", "한 걸음 뒤로 ", "두 걸음 뒤로 ", "조금만 뒤로 ",
|
||||
"50센티만 뒤로 ", "뒤로 조금 ", "1미터 뒤로 "]
|
||||
_SIDE = ["왼쪽으로 ", "오른쪽으로 ", "왼쪽으로 50센티 ", "오른쪽으로 1미터 ", "옆으로 "]
|
||||
|
||||
INTENT = {
|
||||
"move": _make(_FWD, ["가", "이동", "전진", "나가", "움직"]) + _make(_BACK, ["가", "이동", "후진", "물러나", "빠져"]) +
|
||||
_make(_SIDE, ["가", "이동"]) + _make(["", "좀 ", "조금 "], ["전진", "후진", "물러나"]),
|
||||
"turn": _make(["왼쪽으로 ", "오른쪽으로 ", "왼편으로 ", "오른편으로 ", "왼쪽으로 90도 ", "오른쪽으로 45도 ",
|
||||
"45도 오른쪽으로 ", "90도 왼쪽으로 ", "오른쪽으로 30도 ", "뒤로 ", "뒤쪽으로 ", "반 바퀴 ", "180도 "],
|
||||
["돌아", "회전"]) +
|
||||
_make(["몸을 왼쪽으로 ", "몸을 오른쪽으로 ", "몸 왼쪽으로 ", "몸 오른쪽으로 ", "몸을 뒤로 "], ["돌려"]) +
|
||||
_make(["왼쪽으로 몸 ", "오른쪽으로 몸 ", "왼쪽으로 몸 좀 ", "오른쪽으로 몸 좀 "], ["틀어", "돌려"]) +
|
||||
_make(["반대쪽으로 ", "반대로 ", "뒤쪽으로 "], ["돌아서"]) +
|
||||
_make(["", "살짝 "], ["좌회전", "우회전"]),
|
||||
"follow": _make(["", "저 ", "나 ", "날 ", "저를 ", "제 뒤 ", "제 뒤를 ", "내 뒤 ", "나 좀 ", "저 좀 ", "졸졸 ", "계속 ",
|
||||
"끝까지 "], ["따라다녀", "뒤따라와", "따라붙어", "따라와", "쫓아와"]),
|
||||
"come": _make(["이리 ", "이리로 ", "여기로 ", "이쪽으로 ", "제 쪽으로 ", "가까이 ", "좀 더 가까이 ", "여기까지 ", "제 앞까지 ",
|
||||
"내 앞으로 ", "나한테 ", "저한테 "], ["와", "다가와"]),
|
||||
"go_to": _make(["<place>로 ", "<place>까지 ", "<place> 쪽으로 "], ["가", "이동", "움직", "출발"]),
|
||||
"look": _make(["왼쪽을 ", "오른쪽을 ", "위를 ", "아래를 ", "위쪽을 ", "아래쪽을 ", "천장을 ", "바닥을 ", "앞을 ", "정면을 ",
|
||||
"저 좀 ", "나 좀 ", "날 ", "저를 ", "여기를 ", "이쪽을 ", "제 얼굴 "], ["봐", "쳐다봐", "바라봐"]) +
|
||||
_make(["고개 ", "고개를 ", "머리 ", "머리를 ", "고개 좀 "], ["고개들어", "숙여"]) +
|
||||
_make(["고개를 위로 ", "고개 위로 ", "머리를 위로 "], ["올려"]) +
|
||||
_make(["고개를 아래로 ", "고개 아래로 ", "머리를 아래로 "], ["내려"]) +
|
||||
_make(["고개를 왼쪽으로 ", "고개를 오른쪽으로 ", "고개 왼쪽으로 ", "고개 오른쪽으로 "], ["돌려"]),
|
||||
"wave": _make(["손 ", "손을 ", "손 좀 ", "손 한번 ", "손 크게 ", "손을 좀 "], ["흔들어"]) +
|
||||
_make(["", "저랑 ", "나랑 ", "악수 한번 "], ["악수"]),
|
||||
"arm_reach": _make(["손 ", "손을 ", "팔 ", "팔을 ", "손을 앞으로 ", "팔을 앞으로 "], ["내밀어", "뻗어"]),
|
||||
"arm_fold": _make(["팔 ", "팔을 ", "팔을 몸 쪽으로 "], ["접어", "거둬"]),
|
||||
"lift": _make(["몸 ", "몸을 ", "키 ", "키를 "], ["올려", "내려", "높여", "낮춰"]) + _make(["몸을 위로 ", "몸 위로 "], ["올려"]) +
|
||||
_make(["몸을 아래로 ", "몸 아래로 "], ["내려"]),
|
||||
"pick": _make(["<obj> ", "<obj> 좀 ", "그 <obj> ", "이 <obj> ", "<obj> 하나 ", "<obj>을 ", "테이블 위 <obj> "],
|
||||
["집", "잡", "챙겨", "들어올려"]),
|
||||
"fetch": _make(["<obj> ", "<obj> 좀 ", "나한테 <obj> ", "저한테 <obj> ", "<obj> 하나 ", "여기로 <obj> "],
|
||||
["가져와", "갖고와", "챙겨와", "가져다", "갖다"]),
|
||||
"put": _make(["<obj> ", "그거 ", "이거 ", "테이블에 ", "테이블 위에 ", "여기 ", "들고 있는 거 "], ["놔", "내려놔", "둬", "내려놓아"]),
|
||||
"arm_open": _make(["손 ", "손을 ", "그리퍼 ", "집게 ", "손가락 "], ["펴", "벌려", "열어"]),
|
||||
"arm_close": _make(["손 ", "손을 ", "그리퍼 ", "집게 ", "손가락 "], ["닫아", "오므려"]),
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
"""Korean questions about Lumi in the casual / rude register (야 너 몇 살이냐, -냐 / -니 / 대 봐) and the formal and
|
||||
honorific ones (-습니까, -세요, 성함 / 연세 / 여쭤봐도), for the quick answers' kinds that had them least."""
|
||||
|
||||
QUICK = {
|
||||
"name": ["야 너 이름 뭐냐", "니 이름 뭐냐", "이름이 뭐냐고", "너 이름이 뭐니", "이름 뭐냐", "넌 이름이 뭐냐", "이름이 뭡니까",
|
||||
"이름이 어떻게 되십니까", "이름이 무엇인지 말씀해 주십시오", "성함이 어떻게 되시는지요", "존함이 어떻게 되세요",
|
||||
"이름 좀 여쭤봐도 될까요", "뭐라고 부르면 되냐", "뭐라고 불러야 됩니까"],
|
||||
"age": ["야 너 몇 살이냐", "너 몇 살 먹었냐", "나이 몇이냐", "몇 살이냐고", "몇 살이니", "나이가 몇이니", "몇 살입니까",
|
||||
"나이가 어떻게 됩니까", "연세가 어떻게 되세요", "연세가 어떻게 되십니까", "올해 몇 살이신가요", "몇 살이신지 여쭤봐도 될까요",
|
||||
"언제 만들어졌냐", "만들어진 지 얼마나 됐냐", "제작된 지 얼마나 되었습니까"],
|
||||
"maker": ["야 누가 너 만들었냐", "누가 만들었냐고", "어디 회사 거냐", "너 어디 제품이냐", "너 누가 만들었니", "어느 회사 제품입니까",
|
||||
"제조사가 어디입니까", "누가 개발했습니까", "어느 회사에서 만드셨어요", "어디서 만드신 로봇인가요", "개발하신 곳이 어디세요",
|
||||
"만든 회사가 어디냐", "어디서 개발했냐"],
|
||||
"who": ["야 너 뭐냐", "넌 대체 뭐냐", "너 정체가 뭐냐", "너 뭐 하는 놈이냐", "뭐 하는 로봇이에요", "뭐 하는 로봇이냐",
|
||||
"무슨 일 하는 로봇이에요", "어떤 일을 하는 로봇입니까", "어떤 로봇이신가요", "누구신가요", "누구십니까", "자기소개 좀 해 보세요",
|
||||
"당신은 누구입니까", "넌 누구니"],
|
||||
"height": ["너 얼마나 커", "얼마나 크냐", "야 너 키 몇이냐", "키 몇 센티냐", "키가 몇이니", "너 얼마나 커요", "키가 얼마나 됩니까",
|
||||
"신장이 어떻게 되십니까", "키가 어떻게 되세요", "키는 얼마나 되시나요"],
|
||||
"weight": ["야 너 몇 킬로냐", "몸무게 몇이냐", "얼마나 무겁냐", "너 무게 얼마니", "무게가 얼마나 나갑니까", "몸무게가 어떻게 되세요",
|
||||
"무게가 어떻게 되십니까", "몇 킬로그램이나 나가세요"],
|
||||
"battery_life": ["충전하면 얼마나 버티냐", "배터리 몇 시간 가냐", "한 번 충전하면 얼마나 버텨", "배터리 얼마나 버텨요",
|
||||
"충전하면 몇 시간 버팁니까", "배터리는 얼마나 가세요", "한 번 충전하시면 몇 시간 가세요", "배터리 몇 시간짜리냐"],
|
||||
"speed": ["얼마나 빠르냐", "속도 몇이냐", "최고 속도 몇이냐", "얼마나 빠르니", "최고 속도가 어떻게 됩니까", "속도가 어떻게 되세요",
|
||||
"얼마나 빨리 다니세요", "얼마나 빨리 달리냐"],
|
||||
"languages": ["무슨 말 하냐", "너 무슨 말 하냐", "몇 개 국어 하냐", "영어 할 줄 아냐", "무슨 언어 하냐", "말은 뭐 뭐 하니",
|
||||
"어떤 언어를 구사합니까", "어떤 언어를 하세요", "몇 개 국어 하세요", "영어도 하실 줄 아세요", "무슨 말 할 줄 알아"],
|
||||
"how_are_you": ["잘 지냈냐", "기분 어떠냐", "요즘 어떠냐", "잘 지냈니", "기분 어떠니", "잘 지내셨습니까", "기분이 어떻습니까",
|
||||
"잘 지내셨어요", "요즘 어떻게 지내세요", "오늘 기분 어떠세요"],
|
||||
"can_sing": ["노래할 줄 아냐", "노래 부를 줄은 아냐", "노래도 하냐", "노래도 하세요", "노래도 하십니까", "노래 부르실 줄 아세요",
|
||||
"노래 좀 하냐", "노래 잘하냐"],
|
||||
"dance": ["춤도 춰", "춤도 춰요", "춤은 추냐", "춤 출 줄 아냐", "춤도 춥니까", "춤도 추세요", "춤 추실 줄 아세요", "춤 잘 추냐",
|
||||
"춤 좀 추냐"],
|
||||
"cameras": ["카메라 어디 있냐", "카메라 어디 달려 있어", "카메라는 어디에 있어요", "카메라는 어디에 달려 있습니까", "카메라 몇 개냐",
|
||||
"카메라가 몇 개 있으세요", "눈은 어디에 있으세요", "눈이 어디냐"],
|
||||
"country": ["어느 나라 거냐", "너 어디 나라 로봇이냐", "고향이 어디세요", "고향이 어디야", "어디서 왔냐", "어느 나라에서 오셨어요",
|
||||
"어느 나라 로봇입니까"],
|
||||
"stairs": ["계단은 타냐", "계단 올라갈 수 있냐", "계단 오를 수 있니", "계단도 올라가세요", "계단을 오를 수 있습니까", "계단 탈 줄 아냐"],
|
||||
"time_now": ["몇 시냐", "지금 몇 시냐고", "지금 몇 시니", "현재 시각이 어떻게 됩니까", "지금 몇 시인지 여쭤봐도 될까요",
|
||||
"지금 몇 시예요 혹시"],
|
||||
"date_today": ["오늘 며칠이냐", "무슨 요일이냐", "오늘 며칠이니", "오늘은 무슨 요일입니까", "오늘 날짜가 어떻게 되나요",
|
||||
"오늘이 며칠인지 여쭤봐도 될까요"],
|
||||
"name_meaning": ["루미가 무슨 뜻이에요", "루미가 무슨 뜻이야", "루미라는 이름은 무슨 뜻이에요", "루미 뜻이 뭐냐", "이름이 무슨 뜻입니까",
|
||||
"이름 뜻이 뭐예요", "루미라는 이름 무슨 의미야", "이름에 무슨 뜻이 있으세요", "왜 이름이 루미예요"],
|
||||
"software": ["무슨 프로그램으로 움직여요", "무슨 소프트웨어 써", "뭘로 프로그래밍 됐어요", "어떤 프로그램 돌아가요",
|
||||
"소프트웨어는 뭐로 만들었습니까", "무슨 언어로 코딩됐어", "프로그램은 뭘로 짰냐"],
|
||||
}
|
||||
+23
-7
@@ -920,9 +920,10 @@ NOT_NAME = {"루미", "누미", "류미", "무미", "루비", "루니", "아니"
|
||||
|
||||
def to_someone_else(text):
|
||||
""""Hey Jake, come see this", "Mom, look!", "민수야 이리 와 봐": said to another person nearby, not an order to Lumi."""
|
||||
if ASIDE_EN.search(text) or re.match(r"^\W*(?:야|얘)[\s,!]+(?!.*(?:루미|로봇|lumi))", text, re.I) or \
|
||||
if ASIDE_EN.search(text) or re.match(r"^\W*얘[\s,!]+(?!.*(?:루미|로봇|lumi))", text, re.I) or \
|
||||
re.match(r"^\W*my (?:friend|dear|buddy|son|daughter|boy|girl|kid|baby|love|darling)\s*,", text, re.I):
|
||||
return True # "야 그 사과 좀 집어 줘", "my friend, you follow me"
|
||||
return True # "얘 그 사과 좀 집어 줘", "my friend, you follow me"
|
||||
# (a bare 야 is the casual call to Lumi: "야, 이리 와")
|
||||
for m in re.finditer(r"[,\s]([가-힣]{2})(아|야)(?=[\s,!~.]|$)", text): # "그거 내려놔, 지훈아 깨져"
|
||||
c = m.group(1)[-1]
|
||||
vowel_end = (ord(c) - 0xAC00) % 28 == 0
|
||||
@@ -1053,11 +1054,23 @@ def not_an_order(text, asked=True):
|
||||
return False # "I'm on your right": said so the head turns there
|
||||
rest = instead_of(t) # "don't put your arm out, my baby will grab it"
|
||||
now = NOW_CLAUSE.sub(" ", WAIT_UNTIL.sub(" ", t)) # "when you're ready", "while you do", "말씀하실 때": now
|
||||
now = STEP_AFTER.sub(" 그리고 ", now) # "p3로 이동한 다음에 손 흔들어": Lumi's own step first
|
||||
return bool(to_someone_else(t) or CANT_GO.search(t) or DRINK.search(t) or IDIOMS.search(t) or
|
||||
CONDITION.search(now) or REMARK.search(now) or
|
||||
TAKEN_BACK.search(t) or
|
||||
rest != t and REMARK.search(rest) or asked and ASKED.search(t) or NEGATED.search(t) or ko_told(t) or
|
||||
ABOUT_IT.search(t) or LATER_SAID.search(t) or ASIDE_NOW.search(t))
|
||||
ABOUT_IT.search(t) or LATER_SAID.search(t) or ASIDE_NOW.search(t) or DOUBT.search(t))
|
||||
|
||||
|
||||
DOUBT = re.compile(r"\b(?:can|could) (?:you|u) (?:even|really)\b|"
|
||||
r"\b(?:he|she|they|my (?:son|daughter|kid|kids|friend|wife|husband|mom|dad|boss|brother|sister)) "
|
||||
r"(?:wants?|wanted|would like|likes?|loves?|tried) to (?!have you\b)", re.I)
|
||||
# "can you even turn left?": a doubt; "my son wants to fold your arm": what someone else wants to do, no order
|
||||
|
||||
|
||||
STEP_AFTER = re.compile(r"(?:이동한|간|돈|돌아선|회전한|본|쳐다본|집은|잡은|든|흔든|내려놓은|놓은|온|돌아온|따라간|움직인|올린|내린|"
|
||||
r"숙인|편|접은|내민|뻗은|연|닫은|가져온|챙긴) (?:다음에|후에)")
|
||||
# Lumi's own step, then the next one ("오른쪽 본 다음에 손 흔들어"), not a condition like "회의 끝난 다음에"
|
||||
|
||||
|
||||
NOW_CLAUSE = re.compile( # time words that mean now, with the order (T1, 2026-10-27): no later condition
|
||||
@@ -1581,8 +1594,9 @@ def _intent(text, markers=()):
|
||||
if driving.amount(t)[0] is None:
|
||||
return None # "I'll come back later", "come back tomorrow": talk
|
||||
continue # "come back 20 cm": a short drive
|
||||
if action == "make_way" and driving.direction(driving.clean(t)) not in (None, "back"):
|
||||
n, exact = driving.amount(t) # "왼쪽으로 20센티미터만 비켜 주게": that way, that far
|
||||
if action == "make_way" and driving.direction(driving.clean(t)) not in (None, "back") or \
|
||||
action == "make_way" and driving.direction(driving.clean(t)) == "back" and driving.amount(t)[0] is not None:
|
||||
n, exact = driving.amount(t) # "왼쪽으로 20센티미터만 비켜 주게", "뒤로 50센티 비켜": that far
|
||||
n = driving.DEFAULT_M if n is None else n
|
||||
if n == "?" or not driving.MOVE_MIN_M <= n <= MOVE_MAX_M:
|
||||
return None
|
||||
@@ -1629,8 +1643,9 @@ def _intent(text, markers=()):
|
||||
if action == "put":
|
||||
return ("put", "back" if re.search(r"\bback\b|\breturn\b|\bwhere (?:it was|you)\b|\bits (?:spot|place)\b|제자리|다시|원래|원위치|있던|도로", t)
|
||||
else "down")
|
||||
if action == "pick" and re.search(r"\b(?:grab|get|fetch|pick up|take) me\b|\bgimme\b", t):
|
||||
return ("fetch", text) # "go grab me a cup": brought to me, not only picked
|
||||
if action == "pick" and re.search(r"\b(?:grab|get|fetch|pick up|take) me\b|\bgimme\b|"
|
||||
r"\b(?:go |come )?(?:grab|get|fetch) (?:the |that |this |a |an )?\w+(?: \w+)? for me\b", t):
|
||||
return ("fetch", text) # "go grab me a cup", "go get the cup for me": brought to me
|
||||
if action in ("pick", "move_object") and far:
|
||||
return ("fetch", text) # "get me an orange at gate one": a trip there, not a pick here
|
||||
if action in ("pick", "move_object"):
|
||||
@@ -2860,6 +2875,7 @@ UNSURE = re.compile(r"\b(not sure|don't know|do not know|don't have (any )?(info
|
||||
QUESTION_START = re.compile(r"^\s*(where|what|how|why|when|which|who|do you|does|is|are|can i|could i)\b|어디 ?(있|에 있)|"
|
||||
r"(어디|뭐|왜|언제|몇)[^ ]*\s*\?*\s*$", re.I) # a question about a place, not a command
|
||||
ABILITY_Q = re.compile(r"(?<!줄 )(?<!주실 )(?<!줘 )(?<!받을 )수 ?있(?:어|나|니|을까|습니까)\S*\s*\?*\s*$|\bdo you know how\b|"
|
||||
r"\b(?:can|could) (?:you|u) (?:even|really)\b|"
|
||||
r"\bare you able\b|줄 ?(?:알아|아세요|알아요|아니|알지)\S*\s*\?+\s*$|"
|
||||
r"보이(?:십니까|세요|시나요|나요|니|냐)\s*[?.!]*\s*$|보여요?\s*\?+\s*$", re.I) # asks whether Lumi can ("손 흔들 줄 알아?");
|
||||
# "뒤가 보이십니까?", "등 좀 보이세요": about seeing / showing, no head turn
|
||||
|
||||
@@ -83,11 +83,23 @@ def _rule(words, markers):
|
||||
return rule
|
||||
|
||||
|
||||
def _then_go(m):
|
||||
""""이동한 다음에" -> "이동하고", "집은 후에" -> "집고"; a noun before 다음에 ("회의 다음에") stays."""
|
||||
c = m.group(1)
|
||||
n = ord(c) - 0xAC00
|
||||
if c == "은":
|
||||
return "고"
|
||||
if n % 28 == 4: # the -ㄴ form: 한 -> 하, 간 -> 가
|
||||
return chr(0xAC00 + n - 4) + "고"
|
||||
return m.group(0)
|
||||
|
||||
|
||||
def parts(text):
|
||||
"""The sentence cut at and / then / 그리고 / -고 / -서, messages to say kept whole, fillers and the name dropped."""
|
||||
text = re.sub(r"(?<![\w가-힣])([\w가-힣]+)[—–-]+\s*(?=\1)", "", text) # a stutter: "go ah— ahead", "센— 센티"
|
||||
cut, says = steps._cut_says(text)
|
||||
cut = re.sub(r"(?<=[가-힣])고\s*나서(?=[\s,]|$)", "고", cut) # "-고 나서" = "-고"
|
||||
cut = re.sub(r"([가-힣])\s+(?:다음에|후에)(?=[\s,])", _then_go, cut) # "-ㄴ 다음에" / "-은 후에" = "-고"
|
||||
cut = re.sub(r"(?<=[가-힣]{2}고)(?=(?:오른쪽|왼쪽|앞으로|뒤로|위로|아래로|손|고개|몸|팔|허리|나를?|저를?|이리|여기|저기|"
|
||||
r"p\d|[a-z]{3}))", " ", cut) # whisper's run-together "몸내리고오른쪽으로돌아주라": the next order apart
|
||||
out = []
|
||||
|
||||
@@ -26,7 +26,7 @@ TURN_MORE_DEG = 15.0 # deg; "a bit more" right after a turn: this much f
|
||||
|
||||
DIRS = (("back", r"\bback(?:wards?)?\b(?! down\b)|\bbackward\b|\breverse\b|\bretreat\b|^(?:let'?s )?(?:bake|big)\b(?= \d| half| a )|뒤로|뒤쪽|후진|"
|
||||
r"물러"), # whisper's "let's bake / big one meter"
|
||||
("forward", r"\bforwards?\b|\bahead\b|앞으로|앞쪽|전진"),
|
||||
("forward", r"\bforwards?\b|\bahead\b|\b(?:go|move|drive) (?:to the )?front\b|앞으로|앞쪽|전진"), # "you go front one meter"
|
||||
("left", r"\b(?:to the |to your )?left\b|왼 ?쪽|왼편|웬쪽|좌측"),
|
||||
("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|"
|
||||
|
||||
@@ -69,7 +69,7 @@ NOT_TO_LUMI = re.compile(
|
||||
r"(?:좋|멋지|예쁘|이쁘|귀엽|크|작|길|세|대단하|신기하|웃기)(?:네|네요|구나|군요)(?=[\s,.!~])", re.I)
|
||||
# plans, hypotheticals, announcements, praise and remarks: nobody asked Lumi to do anything now
|
||||
QUESTION = re.compile(r"^\W*(?:(?:hey|so|um+|uh+|lumi|okay|ok)\W+)*(?:what|where|why|how|when|who|whose|which|is|are|was|"
|
||||
r"were|do(?=\s+(?:you|i|we|they|robots?)\b)|does|did|have|has|had|should|shall i|may i|can i|could i)\b(?! about\b)|"
|
||||
r"were|do(?=\s+(?:i|we|they|robots?)\b|\s+you\b(?!\s+(?:shake|wave)\b))|does|did|have|has|had|should|shall i|may i|can i|could i)\b(?! about\b)|"
|
||||
r"어디|뭐|무엇|왜|언제|누구|어떻게|몇|어느|무슨|어떤|얼마|[가-힣]까\s*[??]+\s*$|봤(?:어|니|나|냐|어요|습니까)|본 ?적|"
|
||||
r"\bhave you (?:been|gone|ever)\b|(?:어|아|해|여)도 ?(?:돼|되|될까|괜찮)|[가-힣]도 ?(?:돼|되나|될까|괜찮아)\s*[??]|"
|
||||
r"알려 ?(?:줘|주|줄)|설명해|가르쳐|말해 ?(?:줘|봐|주)|\btell me\b|\bexplain\b|\bdescribe\b|"
|
||||
@@ -87,7 +87,7 @@ REPEAT = re.compile(r"^\W*(?:(?:\w+\W+){0,2})?(?:again|one more time|once more|d
|
||||
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|oops|first)\b|;|"
|
||||
r"(?!갖고|고고|에서)(?<!가)[가-힣](?:서|고)(?:[\s,.…]|$)|(?:으로|로|에) ?가서|"
|
||||
r"(?:흔들|흔드시|보시|돌|내리|올리|집어|내밀|숙이|들|봐 ?주시)고(?=[가-힣])|(?:쪽|나|날|위|아래|앞)보고(?=[가-힣])|(?:집어|와|가져와)서(?=[가-힣])|하고|셔서|면서|다가(?![와오])|갔다|다녀|아니|기다|대기|(?:가|와) ?있어|계세요|"
|
||||
r"(?:흔들|흔드시|보시|돌|내리|올리|집어|내밀|숙이|들|봐 ?주시)고(?=[가-힣])|(?:쪽|나|날|위|아래|앞)보고(?=[가-힣])|(?:집어|와|가져와)서(?=[가-힣])|하고|셔서|면서|다가(?![와오])|갔다|(?<!따라)다녀|아니|기다|대기|(?:가|와) ?있어|계세요|"
|
||||
r"계십시오", re.I)
|
||||
# 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|"
|
||||
@@ -775,8 +775,6 @@ def guarded(text):
|
||||
return "past"
|
||||
if told_ko(t):
|
||||
return "told"
|
||||
if re.match(r"^\W*야\s", t):
|
||||
return "someone else" # "야 커피코너에서 컵 좀 가져와": a friend called (야 루미 is cut before)
|
||||
name = NAME_CALL.match(t)
|
||||
if brain.to_someone_else(t) or brain.to_someone_else(brain.CALLING.sub("", t)) or name and name.group(1).lower() not in NOT_A_NAME:
|
||||
return "someone else"
|
||||
|
||||
+23
-6
@@ -139,7 +139,9 @@ NAME_ONLY = re.compile(r"^\s*(?:(?:hi|hey|hello|헤이|하이)[\s,]+)?(?:lumi|lo
|
||||
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|"
|
||||
r"머+엄*춰|머+엄*추(?:세요|십시오)|멈춰|멈추(?:게|시게|게나|시오|어라)|그만|정지|스톱|스땁|스떱|미션 ?취소|작업 ?취소|"
|
||||
r"거기 ?서(?: ?봐| ?있어)?(?=[\s!.~,]*$)|(?:^|[\s,])서(?:라|요)?(?=[\s!.~,]*$)|\bhold it(?: right)? (?:there|here)\b|"
|
||||
r"^\W*(?:\w+\W+){0,3}hold it\W*$|멈[처쳐]|그마+안|\bstahp\b|움직이지 ?마|\bemergency stop\b|\b(?:stay|hold|keep) still\b|"
|
||||
r"^\W*(?:\w+\W+){0,3}hold it\W*$|멈[처쳐]|그마+안|\bstahp\b|움직이지 ?(?:마|말아|말고)|꼼짝(?:하지)? ?마|"
|
||||
r"가만(?:히)? ?(?:있어|있어요|계세요|있으세요|있으십시오|있어 ?봐)|\bemergency stop\b|\b(?:stay|hold|keep) still\b|"
|
||||
r"(?:멈추|정지하|그만하)자|(?:멈춥|정지합|그만합)시다|거기 ?(?:한번 )?서(?:라|조|자)?(?:\s*(?:빨리|당장|좀|봐))*(?=[\s!.~,]*$)|거기 ?섭시다|"
|
||||
r"^\W*(?:wait|잠깐|잠깐만|기다려)\W*$", re.I) # not "거기서 기다려"
|
||||
FETCH_GIVE = re.compile(r"\bgive (it|that|this|the \w+)( to me)?\b|\bhand (it )?(over|to me)\b|줘|주세요|건네", re.I)
|
||||
FETCH_PLACE = re.compile(r"\b(put|place|set) (it|that|this|the \w+) (down|on the table)\b|테이블에 ?(놔|놓|둬)|내려 ?(놔|놓)", re.I)
|
||||
@@ -3898,7 +3900,7 @@ STOP_UNSAID = re.compile( # a stop that is taken back, for later, said about t
|
||||
rf"[가-힣](?:면|나면|으면)\s+(?:\S+\s+){{0,3}}{_STOPW}|" # "사람 나오면 그때 멈춰", "음악 멈추면 멈춰요"
|
||||
rf"\b{_STOPW}(?: \w+)? (?:when|once|after|until|as soon as|if) |\bwhen i give the signal\b|" # "stop when you get there"
|
||||
rf"\b(?:don'?t|do not|doesn'?t|didn'?t|won'?t) (?:\w+ ){{0,2}}{_STOPW}\b|{_STOPW}\s*하지 ?마|" # "you don't have to stop"
|
||||
rf"(?<!you )(?<!have )(?<!need )(?<!got )(?<!want )\bto {_STOPW}\b|\b(?:it|he|she) (?:doesn'?t|tried to|keeps?) |" # "waiting for it to freeze"
|
||||
rf"(?<!you )(?<!have )(?<!need )(?<!got )(?<!want )(?<! as )(?<!like you )\bto {_STOPW}\b|\b(?:it|he|she) (?:doesn'?t|tried to|keeps?) |" # "waiting for it to freeze"
|
||||
r"\b(?:heard|bet|like|guess) (?:that )?(?:you|it) (?:can|could)\b|\bi saw you\b|"
|
||||
r"리가 있나|내가 사람이다|퍽이나|[가-힣]겠다\W*$|했던데|그랬잖아|했잖아|(?:멈췄|정지했|그만했)(?:던데|잖아|으면)|"
|
||||
r"(?-i:\b(?!(?:Lumi|Loomi|Rumi|Robot|Hey|Hi|Okay|Ok|No|Please|Now|Wait|Hello|So|Oh|Yo|Stop)\b)[A-Z][a-z]+), (?:okay )?stop|"
|
||||
@@ -3928,10 +3930,14 @@ STOP_ONLY = re.compile( # a whole sentence that only says stop / enough / stay
|
||||
|
||||
|
||||
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 )?(?:go ahead and )?"
|
||||
r"(?:stop|halt|freeze|hold it(?: right)? (?:there|here))"
|
||||
r"\W*(?:(?:좀|지금|당장|잠깐|잠시|거기서?|이제|동작|모든 동작|하던 거|움직임|얼른|빨리)\s*)*(?:멈춰|멈춰 서|정지해|그만해|스톱해|스탑해|서|움직이지 말아|움직이지 마|가만히 있어)"
|
||||
r"(?: ?(?:줘|도|봐))?(?:\W*(?:부탁(?:드립니다|드려요|해요|해)|제발))?\W*|"
|
||||
r"\W*(?:(?:please|lumi|hey|okay|ok)\W+)*(?:(?:can|could|would|will) (?:you|u)|you can) (?:please |just |kindly |"
|
||||
r"be so kind as to )?(?:go ahead and )?"
|
||||
r"(?:stop(?: it| that| moving| everything)?|halt|freeze|cut it out|knock it off|hold it(?: right)? (?:there|here))"
|
||||
r"(?: (?:right )?(?:now|here|there|please))?(?: for (?:me|us|a (?:second|sec|moment|bit|minute)))?(?:,? please)?\W*|"
|
||||
r"\W*(?:please |just |c'?mon,? |go ahead and )?(?:cut it out|knock it off)(?:,? (?:please|buddy|now))?\W*|"
|
||||
r"\W*(?:stop|halt|freeze)(?:,? ok(?:ay)?)\W*|"
|
||||
r"\W*(?:would|do) you mind stopping(?: (?:now|here|there))?(?: for (?:me|us|a (?:second|moment)))?(?:,? please)?\W*", re.I)
|
||||
|
||||
|
||||
@@ -3944,7 +3950,18 @@ def stop_order(text, markers):
|
||||
bare = STOP_CALL.sub("", text or "")
|
||||
if re.fullmatch(r"\W*(?:wait|hold on|hang on|one (?:sec|second|moment)|잠깐(?:만)?(?:요)?|기다려(?:요)?)\W*", bare, re.I):
|
||||
return stop_order_said(text, markers) # "Lumi, wait": a mission halts for a talk (mission_talk), not ended
|
||||
return stop_order_said(text, markers) or bool(bare and bare != text and stop_order_said(bare, markers))
|
||||
return stop_order_said(text, markers) or bool(bare and bare != text and stop_order_said(bare, markers)) or \
|
||||
bool(STOP_CORE.fullmatch(EN_FRAME_END.sub("", EN_FRAME_START.sub("", bare or text or ""))))
|
||||
|
||||
|
||||
EN_FRAME_START = re.compile(r"^\W*(?:(?:please|hey|yo|c'?mon|okay|ok|lumi|now|just|so|whoa|go ahead and|you|u|"
|
||||
r"(?:could|would|can|will) (?:you|u)(?: please| kindly| be so kind as to)?|you can|can|"
|
||||
r"i(?: need| want| would like|'d like) (?:you|u) to)\W+)+", re.I)
|
||||
EN_FRAME_END = re.compile(r"(?:\W+(?:please|pls|plz|for me|for us|ok|okay|buddy|bro|dude|would ya|will ya|now|right now|"
|
||||
r"already|if you don'?t mind|thanks))+\W*$|\W+$", re.I)
|
||||
STOP_CORE = re.compile(r"stop(?: it| that| moving| everything| right there| right now| now| the robot)?|freeze|halt|cut it out|"
|
||||
r"knock it off|(?:stay|hold|keep) still|that'?s enough|emergency stop|don'?t move", re.I)
|
||||
# an English stop inside the frames people put around it: "I'd like you to cut it out", "could you stay still?"
|
||||
|
||||
|
||||
def order_after_stop(text, markers, b):
|
||||
|
||||
@@ -268,13 +268,17 @@ NO = [t for t in NO if t not in _said] # a wording
|
||||
|
||||
CAMERA = re.compile(r"\b(?:see|seeing|saw|look(?:s|ing)?|watch|camera|wearing|holding|in front of|behind|colou?r|"
|
||||
r"recogni[sz]e|remember)\b|보여|보이|보니|(?<!해 )(?<!해)(?<!쭤 )(?<!쭤)(?<!여쭈어 )봐(?!도 ?(?:돼|되|될|괜찮))|봤|입었|들고|색|카메라|앞에|뒤에|알아봐|기억", re.I)
|
||||
SPEC = re.compile(r"\b(?:what|which|how many|what kind of|what type of|what sort of) (?:depth )?cameras?\b|\bcameras? (?:do you (?:have|use)|"
|
||||
SPEC = re.compile(r"\b(?:what|which|how many|what kind of|what type of|what sort of) (?:depth )?cameras?\b|"
|
||||
r"\bwhere (?:are|is) (?:your|the) cameras?\b|\bcameras? how many\b|\bcameras? (?:do you (?:have|use)|"
|
||||
r"model|brand|type|range|resolution)\b|\b(?:recogni[sz]e|remember) (?:faces|people|anyone|who people are)\b|"
|
||||
r"\bface recognition\b|카메라(?:가|는|를)? ?(?:몇 ?개|몇 ?대|뭐 ?써|뭘 ?써|뭐 ?쓰|어떤 ?거|기종|모델|종류|제품|사양|스펙)|"
|
||||
r"얼굴 ?(?:인식|알아보|알아봐|기억)", re.I)
|
||||
r"얼굴 ?(?:인식|알아보|알아봐|기억)|카메라(?:가|는)? ?(?:어디|위치)", re.I)
|
||||
# the cameras and face recognition as facts ("what cameras do you have?", "얼굴 인식 돼요?"), not what they see now
|
||||
ABOUT_ME = re.compile(r"\b(?:(?<!can )(?<!could )(?<!may )i(?! (?:call|address) you\b)(?! (?:talk|speak|chat) (?:to|with) you\b)|i'm|am i|my|"
|
||||
r"(?<!tell )(?<!give )(?<!let )(?<!show )me|mine)\b|(?:^|\s)(?:나|내|제|저|난|전)(?:는|가|를|의)?\s", re.I)
|
||||
LUMI_FOR_ME = re.compile(r"\b(?:is it safe|safe for (?:me|my \w+)|how (?:do|can|should) i (?:stop|turn) you(?: off)?\b|"
|
||||
r"in an emergency|how do you (?:understand|hear) (?:me|my|what i)|can i touch you)\b", re.I)
|
||||
# a question about Lumi said with I / my: "Is it safe for my kids to be near you?", "How do I stop you in an emergency?"
|
||||
FRAGMENT = re.compile(r"^\W*(?:and|so|but|then|or|also|why|really|seriously|wait|what about|how about|how come|are you sure)\b|"
|
||||
r"^\W*(?:그럼|그러면|그리고|근데|그런데|그래서|아니|왜|진짜|정말|확실|설마|또)|"
|
||||
r"\b(?:that|(?<!is )(?<!was )(?<!is it )(?<!how's )(?<!how is )(?<!time )(?<!day )it(?! is (?:now|today))|they|them|"
|
||||
@@ -366,9 +370,25 @@ REMARK = re.compile(r"(?:(?:어+|아+|음+|um+|uh+)\s+)?(?:quick question|just (
|
||||
SENTENCES = re.compile(r"(?<=[??!])\s*|(?<=\.)\s+")
|
||||
|
||||
|
||||
TELL = re.compile(r"(이름|성함|나이|키|무게|몸무게|속도|최고 ?속도|시간|날짜|요일|만든 ?(?:데|곳|회사)|제조사|회사)(?:을|를|이|가)?"
|
||||
r"\s*(?:좀\s*)?(?:대|말해|말씀해|읊어)\s*(?:봐라|봐요|봐|보세요|라|줘|주세요|주십시오|주시겠어요)\W*$")
|
||||
# "이름 대 봐", "나이 말해 봐라", "이름을 말씀해 주십시오": a question said as "tell me X" (봐 is not a look)
|
||||
|
||||
|
||||
EN_SLANG = [(re.compile(rx, re.I), to) for rx, to in (
|
||||
(r"(?<![\w-])r u(?![\w-])", "are you"), (r"(?<![\w-])u(?![\w-])", "you"), (r"(?<![\w-])ur(?![\w-])", "your"),
|
||||
(r"(?<![\w-])ya(?![\w-])", "you"), (r"\bdoin\b", "doing"), (r"\s*\btho\b", ""), (r"^\W*sup\b", "what's up"),
|
||||
(r"\bwhat time's it\b", "what time is it"), (r"\bgonna\b", "going to"), (r"\bwanna\b", "want to"))]
|
||||
# chat spellings: "how old r u", "can u sing tho?", "how ya doin?"
|
||||
|
||||
|
||||
def _tidy(text):
|
||||
"""Stutters and words said twice taken out ("키가 얼— 얼마예요?", "너 너 몇 살이야"), laughs at the end."""
|
||||
t = re.sub(r"(?<![\w])(\w{1,4})[—–-]+\s*(?=\1)", "", text or "")
|
||||
"""Stutters and words said twice taken out ("키가 얼— 얼마예요?", "너 너 몇 살이야"), laughs at the end, "X 대 봐" as
|
||||
"X 뭐야"."""
|
||||
t = TELL.sub(lambda m: m.group(1) + " 뭐야?", text or "")
|
||||
for rx, to in EN_SLANG:
|
||||
t = rx.sub(to, t)
|
||||
t = re.sub(r"(?<![\w])(\w{1,4})[—–-]+\s*(?=\1)", "", t)
|
||||
t = re.sub(r"\b(\w+)(?:[\s,]+\1\b)+", r"\1", t)
|
||||
return re.sub(r"(?<=\S)[\s~^ㅎㅋ]+(?=[??!.]*$)|(?<=[??!.])[\s~^ㅎㅋ]+$", "", t).strip()
|
||||
|
||||
@@ -409,7 +429,7 @@ def guarded(text, history=()):
|
||||
return "closing" # "goodbye" is never a hello
|
||||
if CAMERA.search(SPEC.sub(" ", t)):
|
||||
return "camera"
|
||||
if ABOUT_ME.search(t):
|
||||
if ABOUT_ME.search(t) and not LUMI_FOR_ME.search(t):
|
||||
return "about the visitor"
|
||||
lead = re.match(r"^\W*(?:and|so|but|okay so|then)\W+", t, re.I)
|
||||
if lead and len(t[lead.end():].split()) >= 3 and NAMES_LUMI.search(t[lead.end():]):
|
||||
@@ -538,8 +558,9 @@ def _kind(text, history):
|
||||
best, top, margin, agree, _ = intent_bank._top(vecs @ q, _named, k=AGREE_K)
|
||||
sure = top >= SIM_MIN and margin >= MARGIN or agree and top >= SIM_AGREE and margin >= MARGIN_AGREE
|
||||
core = _core(text)
|
||||
if not sure: # "누가너를만들었습니까": a wording run together (whisper)
|
||||
best = _exact().get(_squeezed(core)) if re.fullmatch(r"\S*[가-힣]{4}\S*", core) else None
|
||||
if not sure: # "누가너를만들었습니까": a wording run together (whisper),
|
||||
best = _exact().get(_squeezed(core)) if re.search(r"[가-힣]", core) else None
|
||||
# or a Korean bank wording said as it is ("루미가 무슨 뜻이야")
|
||||
if best in (None, "no") or best in NEEDS and not re.search(NEEDS[best], text, re.I):
|
||||
return None
|
||||
if best == "hello" and history:
|
||||
|
||||
@@ -1521,11 +1521,17 @@ def _piece_of_someone(t):
|
||||
return None
|
||||
|
||||
|
||||
ORDER_FIRST = re.compile(r"^\W*(?:(?:please|okay|ok|lumi|hey|now|just)\W+)*(?:head|lift|raise|lower|tilt|bow|stand|go|come|turn|"
|
||||
r"move|spin|face|wave|follow|stop|sing|bring|get|take|pick|put|fold|open|close|reach|drive|back)\b", re.I)
|
||||
|
||||
|
||||
def _changed(t, last):
|
||||
""""I took my glasses off, now?", "모자를 벗었습니다. 지금은 쓰고 있습니까?", "앉았어요, 지금은?": the question about
|
||||
what they say changed, asked anew: (kind, words) or None."""
|
||||
if not (CHANGED.search(t) and (AGAIN.search(t) or "?" in t or re.search(r"어때|어떻|보여|보이|\bnow\W*$|\bwhich one\b", t, re.I))):
|
||||
return None
|
||||
if "?" not in t and ORDER_FIRST.match(t):
|
||||
return None # "lift your head now", "head to p3 now": an order, no look
|
||||
for rx, kind, en, ko in CHANGE_KINDS:
|
||||
if re.search(rx, t, re.I):
|
||||
return kind, ko if re.search(r"[가-힣]", t) else en
|
||||
|
||||
@@ -531,6 +531,27 @@ def _stem_aform(word):
|
||||
return aform(KO_L_DROP.get(word, word))
|
||||
|
||||
|
||||
NOUN_ASK = re.compile(r"(이동|회전|전진|후진|정지|좌회전|우회전|충전|복귀|출발|악수|후퇴)\s*(?:좀\s*)?"
|
||||
r"부탁(?:드립니다|드려요|드릴게요|드릴께요|해요|해|합니다|드려|할게요|합니다)")
|
||||
SUGGEST_FORMAL = re.compile(r"([가-힣])(?:으)?시다(?=[\s.,!?~]|$)")
|
||||
|
||||
|
||||
def _suggest_plain(m):
|
||||
"""하십시오체 suggestion -ㅂ시다 / -읍시다 as the plain -자: "갑시다" -> "가자", "집읍시다" -> "집자"."""
|
||||
c = m.group(1)
|
||||
n = ord(c) - 0xAC00
|
||||
if c == "읍" or "으시다" in m.group(0):
|
||||
return ("" if c == "읍" else c) + "자"
|
||||
if c in SUGGEST_L:
|
||||
return SUGGEST_L[c] + "자" # a ㄹ stem: "돕시다" (돌다) -> "돌자"
|
||||
if 0 <= n < 11172 and n % 28 == 17: # the syllable ends in ㅂ: 갑 -> 가
|
||||
return chr(0xAC00 + n - 17) + "자"
|
||||
return m.group(0)
|
||||
|
||||
|
||||
SUGGEST_L = {"돕": "돌", "듭": "들", "엽": "열", "놉": "놀"} # 흔듭시다 -> 흔들자 too
|
||||
|
||||
|
||||
def ko_plain(t):
|
||||
"""Korean request endings of every speech level and dialect as one plain form, so the readers see one wording:
|
||||
"가세요" / "가십시오" / "가요" / "가라" / "가이소" -> "가"; "따라오세요" / "따라온나" / "따라오라고" -> "따라와";
|
||||
@@ -538,6 +559,8 @@ def ko_plain(t):
|
||||
"흔드세요" -> "흔들어"; "해부러" / "혀" -> "해". Greetings ("안녕하세요", "들어가세요") stay; questions keep their "?"."""
|
||||
if not t or not re.search(r"[가-힣]", t):
|
||||
return t
|
||||
t = SUGGEST_FORMAL.sub(_suggest_plain, t) # "p3로 갑시다", "같이 봅시다" -> "가자", "보자"
|
||||
t = NOUN_ASK.sub(r"\1해 줘", t) # "p5로 이동 부탁드립니다" -> "p5로 이동해 줘"
|
||||
for rx, to in KO_PLAIN:
|
||||
if to in ("CAN_L", "CAN_N"):
|
||||
t = rx.sub(lambda m: _can_you(m, to), t)
|
||||
|
||||
Reference in New Issue
Block a user