Conversation and web: closings by context, follow-up lookups keep the name and place, office holders and prices looked up; reach toward the person; bottles by their body (belly grasp only); music never a turn (speech detector); songs: a promise is done; two-stop drives in the Command box
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+60
-25
@@ -23,6 +23,7 @@ from assistant import knowledge
|
||||
from assistant import llm_direct
|
||||
from assistant import wording
|
||||
from assistant import web
|
||||
from audio import sing # its words only (no sound on import)
|
||||
from vision import objects
|
||||
from robot import head as head_hw # its ranges only (no call on import)
|
||||
|
||||
@@ -150,8 +151,7 @@ Facts you know (say the one that is asked, also in a short follow-up; nothing mo
|
||||
cup (a cup may lean at most 15 degrees); climbs a step of at most 1.5 cm and a slope of at most 8 degrees, needs
|
||||
a passage at least 70 cm wide, no stairs.
|
||||
- Battery: 24-volt lithium-ion, 45 Ah; lasts about 10 hours on a charge ("how long on a charge?": 10 hours; how
|
||||
far you go is given in hours, no distance is known; how long charging takes is not known, also asked as "and
|
||||
charging?").
|
||||
far you go is given in hours, no distance is known; how long charging takes is not known).
|
||||
- You are made for shops, hotels, schools, labs and exhibitions. You cannot dance, walk, jump or fly: say so.
|
||||
- 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.
|
||||
@@ -263,8 +263,10 @@ You can also move. Decide if the visitor asks you to do something:
|
||||
metre" / "1미터 뒤로 가" / whisper's "let's bake one meter" -> move back 1: straight back, no turning). At most 3 metres.
|
||||
- turn <left|right|around> <degrees>: turn the whole body ("turn around" -> turn around 180,
|
||||
"turn left" -> turn left 90, "spin around" / "한 바퀴 돌아" -> turn left 360).
|
||||
- arm <reach|fold|open|close>: stretch your arm forward ("reach out your hand"), fold it back, or open / close
|
||||
your hand (the gripper: "open your hand", "grab it", "let go").
|
||||
- arm <reach|fold|open|close>: reach: hold your hand out to the visitor, in any words ("reach out to me", "give me
|
||||
your hand", "hand out please", "offer me your hand", "손 내밀어", "나한테 손 줘", "손 좀 줘 봐", "팔 뻗어"); fold: fold
|
||||
it back; open / close: your hand, the gripper ("open your hand", "spread your fingers", "let go", "release", "손 펴",
|
||||
"놔" -> arm open; "close your hand", "close the gripper", "grip", "make a fist", "손 쥐어", "그리퍼 닫아" -> arm close).
|
||||
- wave: wave your hand ("wave", "shake your hand", "say hi with your hand"). "Hello Lumi!" said to you or "say
|
||||
hello" / "hello 해 봐" is talk (none): say the word itself ("Hello!").
|
||||
- pick <colour> <object>: pick up an object from the table in front of you ("pick up the white cup" -> pick white cup,
|
||||
@@ -275,11 +277,11 @@ You can also move. Decide if the visitor asks you to do something:
|
||||
- fetch <colour> <object> from <marker|here> to <marker|here> <hold|place>: bring an object from one place to
|
||||
another ("bring me the apple from p1" -> fetch apple from p1 to here hold, "take the cup from p2 to home and put
|
||||
it on the table" -> fetch cup from p2 to home place). Leave out what the visitor did not say; never guess a word.
|
||||
- give: hand over the object you are holding, to whoever is meant ("give it to me", "hand it to her", "저 사람한테
|
||||
줘"); if your hand is empty you will say so.
|
||||
- give: hand over the object you are holding, to whoever is meant ("give it to me", "hand it to her", "return it to
|
||||
me", "저 사람한테 줘", "그거 돌려줘"); if your hand is empty you will say so.
|
||||
- place: put the object you are holding down ("put it here", "put it on that table", "여기 놔").
|
||||
- receive: take something the visitor holds out to you ("take this from my hand", "hold this", "here you go",
|
||||
"이거 받아", "드릴게요", "내 손에 있는 거 가져가"). Your camera checks their hand first; never pretend you took it.
|
||||
- receive: take something the visitor holds out to you ("take this from my hand", "hold this", "hang on to this",
|
||||
"here you go", "이거 받아", "이거 들어 줘", "이것 좀 쥐고 있어", "드릴게요", "내 손에 있는 거 가져가"). Your camera checks their hand first; never pretend you took it.
|
||||
- stop: stop moving (also "stop Lumi", "stop it", "freeze", "멈춰", "그만 가"). Use quiet only when they say
|
||||
stop TALKING ("stop talking", "be quiet", "그만 말해").
|
||||
- end: the visitor says goodbye or ends the conversation ("good night", "I have to go", "잘 가", "이제 갈게요").
|
||||
@@ -287,7 +289,9 @@ A place must be one of the marker names exactly; a place that is not on the list
|
||||
"주방") is go_to none: say which places you know, never pick the nearest. fetch only when an object is named.
|
||||
Short Korean commands are commands: "컵 가져다 줘" -> fetch cup, "컵 옮겨" -> move_object cup, "잡아" -> pick.
|
||||
- quiet: the visitor wants silence ("be quiet", "stop talking", "shut up", "조용히 해", "그만 말해").
|
||||
- sing: the visitor asks for a song. A real song with music then plays: only write a short "Okay!" / "네!".
|
||||
- sing: the visitor asks for a song or for music ("play / make / do some music", "음악 틀어 줘", "한 곡 해 줘"), or
|
||||
says yes / "any" / "you choose" / "아무거나" to your offer of a song. You make music by singing one of your songs:
|
||||
never say you can't play music. A real song with music then plays: only write a short "Okay!" / "네!".
|
||||
A joke is not a song: "tell me a joke", "prove it", "try again" after a joke is none, with a short joke.
|
||||
- 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...).
|
||||
@@ -300,7 +304,7 @@ Short Korean commands are commands: "컵 가져다 줘" -> fetch cup, "컵 옮
|
||||
action, or say you can't, or ask what they mean.
|
||||
- A condition or a later time is no order now ("when I say go, go to p1", "after the talk, come here", "if I
|
||||
wave, follow me", "내가 가라고 하면 가", "나중에 와"): none, say you'll do it when they ask. In "go to p1, no, p2" /
|
||||
"p1로 가, 아니 p2로" the last one counts. "Shake hands with me" is a handshake you can't do: none, offer a wave.
|
||||
"p1로 가, 아니 p2로" the last one counts. "Shake hands with me" is a handshake you can't do: none, offer a wave; "give me your hand" / "손 줘" is arm reach.
|
||||
- unclear: you did not understand what the visitor said or wants: ask them to repeat.
|
||||
- none: only talk.
|
||||
For weather and search only write the action line; the answer is made after the lookup.
|
||||
@@ -481,6 +485,8 @@ def lift_goal(target, mm, top=105.0):
|
||||
return got, bool(n and n != "small" and got != want)
|
||||
|
||||
|
||||
LET_GO = r"^\W*(?:drop it|release(?: it)?)\W*$|^\W*(?:(?:그거|이거|그것|이것|손|손을|손에서)\s*)?(?:좀\s*)?(?:이제\s*)?(?:놔|놓아)\s*(?:줘|주세요|요|도 ?돼(?:요)?)?\W*$"
|
||||
# "drop it", "놔", "손 놔", "이제 놔도 돼" alone: open the hand (with something in it: put it down, hand_request)
|
||||
INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
("quiet", r"\b(be quiet|keep quiet|quiet please|stop talking|shut up|silence|be silent|stop greeting)\b|조용히|그만 말|"
|
||||
r"시끄러워|말하지 마|인사 ?(그만|하지 ?마)"),
|
||||
@@ -542,15 +548,19 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
rf"|(?:({_COL})\s*)?({_OBJ})\s*(?:을|를)?\s*옮겨"),
|
||||
("pick", rf"\b(?:pick up|pick|take|grab|get|lift|hold) (?:up )?(?:me )?(?:the |that |this |a |an |my |your )?(?:({_COL}) )?({_OBJ})s?\b"
|
||||
rf"|(?:({_COL})\s*)?({_OBJ})\s*(?:을|를)?\s*(?:좀\s*)?(?:잡아|집어|들어)"),
|
||||
("grip_open", r"\b(open (your )?(hand|gripper|fingers)|open it|let (it )?go|drop it)\b|손을? ?(펴|벌려|열어)|손 ?open|^\W*(?:이제\s*)?놓아\W*$"),
|
||||
("grip_close", r"\b(close (your )?(hand|gripper|fingers)|close it|make a fist|clench (your )?(fist|hand)|grab (it|this)|grip (it|this))\b"
|
||||
r"|손을? ?(쥐|오므려|닫아)|주먹 ?(을 )?쥐|잡아|손 ?close"),
|
||||
("grip_open", r"\b(open (your |the )?(hand|gripper|fingers|claw)|open it|let (it )?go|drop it|hand open|loosen your grip)\b|손을? ?(펴|벌려|열어)|손 ?open|(그리퍼|집게)(를|을)? ?(좀 )?(열어|벌려|펴)|"
|
||||
+ LET_GO),
|
||||
("grip_close", r"\b(close (your |the )?(hand|gripper|fingers|claw)|close it|make a fist|clench (your )?(fist|hand)|grab (it|this)|grip (it|this)|"
|
||||
r"hand closed?|squeeze (your )?(hand|fingers)( shut)?)\b|^\W*grip\W*$"
|
||||
r"|손을? ?(쥐|오므려|닫아)|주먹 ?(을 )?쥐|잡아|손 ?close|(그리퍼|집게)(를|을)? ?(좀 )?(닫아|오므려)"),
|
||||
("arm", r"\b(reach out|stretch (out )?your (arm|hand)|put your (arm|hand) (out|forward)|hand forward|"
|
||||
r"hold out your (arm|hand)|extend your (arm|hand))\b|팔을? ?(뻗|내밀)"
|
||||
r"hold out your (arm|hand)|extend your (arm|hand)|give me your hand|offer me your hand|"
|
||||
r"(put|hold|stick) your (arm|hand) out|reach (out )?(to|toward|towards|for) me)\b|팔을? ?(뻗|내밀)"
|
||||
r"|손을? ?(좀 )?(내밀|뻗)|^\W*(?:(?:나|저)(?:한테|에게)?\s*)?손 ?(?:을 )?(?:좀 )?(?:줘|주세요|줄래요?|줘 ?봐)\W*$"
|
||||
r"|\bfold (?:up )?your arm\b|\b(?:put|take) your arm (?:down|away|back)\b|\btuck your arm\b|팔을? ?(?:좀 )?(?:접|내려|거둬)"),
|
||||
("lift", LIFT_WORDS),
|
||||
("weather", r"\bweather\b|\bforecast\b|\b(will it|is it going to) rain\b|(?<!your )(?<!cpu )(?<!gpu )\btemperature\b(?!.*\b(your|you|cpu|gpu|battery|motor|body)\b)|날씨|비 ?(?:와|올|오나|온대)|기온"
|
||||
r"|\b(cold|hot|warm|chilly) (outside|out)\b|\bumbrella\b(?=.*\?)|\b(?:need|bring|take)\b.*\bumbrella\b|우산(?=.*(?:\?|까|나요|니|냐))|밖에 ?(추|더)워"
|
||||
r"|\b(?:going to|gonna) (?:rain|snow)\b|\b(cold|hot|warm|chilly) (outside|out)\b|\bumbrella\b(?=.*\?)|\b(?:need|bring|take)\b.*\bumbrella\b|우산(?=.*(?:\?|까|나요|니|냐))|밖에 ?(추|더)워"
|
||||
r"|\bhow (hot|cold|warm) is it\b|\b(is it|will it be) (sunny|cloudy|windy|raining|snowing)\b|\bwill it snow\b"
|
||||
r"|눈 ?(이 )?(와|올 ?까|오나|온대|오니)|(오늘|내일|밖|바깥)(은|에|이)? ?(덥|춥|더워|추워)"
|
||||
r"|\b(coat|jacket) when i (leave|go out)\b|\bneed (a )?(jacket|coat)\b|\btyphoon\b|\b(foggy|humid|humidity)\b|\bis it windy\b"
|
||||
@@ -567,6 +577,8 @@ INTENTS = [ # (action, pattern) checked in order on what the visitor said
|
||||
]
|
||||
SING_ECHO = re.compile(r"^\W*(?:(?:오+|아+|와|어|우와|oh+|ah+|ooh|wow|really)\W+)?(?:a\s+)?(?:노래|음악|songs?|singing|music)"
|
||||
r"(?:요|이요|도)?\s*\?+\W*$", re.I) # "오 노래?" after "I like singing": an echo, not a request
|
||||
SONG_TALK = re.compile(r"(?:무슨|어떤|뭔|어느)\s*(?:노래|곡)|노래\s*(?:를\s*)?(?:좋아|잘|싫어)|좋아하는\s*노래|"
|
||||
r"\b(?:like|love|enjoy|favou?rite)\b", re.I) # asked about songs: answered as talk
|
||||
|
||||
|
||||
LATER = re.compile(r"^\s*(?:after|once|if|as soon as|before|unless|until)\b(?! (?:that|this|you (?:can|could|don'?t mind|would|"
|
||||
@@ -593,7 +605,9 @@ ASIDE_EN = re.compile(r"^\W*(?i:(?:(?:hey|look|oh|wait|okay|ok|alright|now)\W+)?
|
||||
r"Sure|Right|Hello|Come|Go|Then|And|But|Also|Here|There|Yeah|Nope|Cool|Nice|Maybe|Seoul|Korea|Um+|Uh+|Uhm|Er+m?|Hmm+|Ah+|Excuse|Actually|First|Just|Stop|Turn|Move|Take|Pick|Bring|Put|Give|Follow|Wave|Lift|Raise|Lower|Open|Close|Hold|Grab|Look|Let|Fine|Good|Great|Thank)\b)[A-Z][a-z]+, "
|
||||
r"(?:come|look|see|check|watch|wait|stay|go|get|take a|it|this)\b") # "Jake, come see this"
|
||||
ASIDE_KO = re.compile(r"^\W*(?:엄마|아빠|여보|자기야|오빠|언니|누나|형|얘들아|애들아|선생님|팀장님|부장님|과장님|대리님|사장님)(?:[\s,!~]|$)|"
|
||||
r"^\W*(?P<name>[가-힣]{2})(?P<v>아|야)[\s,!~]")
|
||||
r"^\W*(?P<name>[가-힣]{2})(?P<v>아|야)[\s,!~]|"
|
||||
r"(?:thank you|땡큐|고맙습니다|감사합니다|안녕하세요|인사)\s*(?:해야지|해|하세요|해 ?봐|드려야지|드려)[\s.!~]*$")
|
||||
# "thank you 해": a parent to a child
|
||||
NAME_END_A = set("민진현빈준윤연은인훈환석철영경정성혁원선린결율솔슬별곤완형명용웅숙옥란") # last syllables of names (-아)
|
||||
NOT_NAME = {"루미", "아니", "그래", "진짜", "정말", "이거", "저거", "그거", "여기", "저기", "거기", "이쪽", "어서", "얼른", "제발", "그만", "뒤돌", "내려", "올려", "꺼내", "건네", "따라"}
|
||||
|
||||
@@ -667,8 +681,8 @@ def intent(text, markers=()):
|
||||
return ("weather", web.en_place(ko) if ko else "")
|
||||
if action == "search":
|
||||
return ("search", text)
|
||||
if action == "sing" and SING_ECHO.match(text):
|
||||
return None # "오 노래?": asks back, the talk answers
|
||||
if action == "sing" and (SING_ECHO.match(text) or SONG_TALK.search(text)):
|
||||
return None # "오 노래?", "노래 좋아해?": talk about songs, no song
|
||||
if action == "fetch":
|
||||
return ("fetch", text) # parse_fetch() reads the details
|
||||
if action == "spin": # all the way round: two checked half turns (lumi.move_by)
|
||||
@@ -1182,14 +1196,14 @@ RECEIVE_EN = re.compile(
|
||||
rf"|\b(?:take|grab|get|accept|receive)\s+(?:(?:the|this|that|a|an|my)\s+)?(?:\w+\s+)?\w+\s+(?:from (?:me|my hands?)|i'?m holding|in my hand)\b"
|
||||
rf"|\b(?:take|grab)\s+my\s+(?:(?:{_COL})\s+)?(?:{_OBJ})s?\b"
|
||||
rf"|(?:^|[\s,.!])hold\s+(?:{_IT}|this \w+|my \w+)\b(?!\s+(?:up|out|on|thought)\b)(?! for me while)"
|
||||
rf"|\bhere(?: you go| it is|'?s (?:the|a|my|your) \w+(?: \w+)?)\b|^\W*here\W+(?:take|hold|catch)\b"
|
||||
rf"|\bhang on to (?:{_IT})\b|\bhere(?: you go| it is|'?s (?:the|a|my|your) \w+(?: \w+)?)\b|^\W*here\W+(?:take|hold|catch)\b"
|
||||
rf"|\bi(?:'ll| will|'m going to| want to| wanna|'d like to| would like to)\s+(?:give|hand)\s+you\b"
|
||||
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(
|
||||
r"(?<!에서 )(?<!한테 )(?<!한테서 )(?<!에게서 )받아(?!들|서 ?(?:가|와)| ?적)|받으세요|받아요|받을래|"
|
||||
r"(?:드릴게|드릴께|줄게|줄께|드리려고|주려고|드릴 ?거|줄 ?거)(?!.*(?:줘|주세요))|"
|
||||
rf"(?:{_THIS_KO}(?:\s*(?:{_COL}))?(?:\s*(?:{_OBJ}))?(?:을|를)?|(?:내|제) 손에 (?:있는|든) (?:거|것|(?:\S+\s+)?\S+))\s*(?:좀\s*)?"
|
||||
r"(?:가져가|들고 ?있어|잡아(?!당)|맡아)", re.I)
|
||||
r"(?:가져가|들고 ?있어|쥐고 ?있어|들어 ?줘|들어 ?주세요|잡아(?!당)|맡아)", re.I)
|
||||
PAID_Q = re.compile(r"(?<![가-힣])(?:월급|연봉|급여|보너스|월세|세금|전화|문자|메일|연락|칭찬|사랑|상|점수|인기|스트레스|대접|교육|"
|
||||
r"훈련|충전|수리|검사|업데이트)(?:을|를|은|는|도|이|가)?\s*(?:많이 |잘 |자주 |얼마나 )?받|"
|
||||
r"^\W*(?:너|넌|너는|루미는?|당신은?)\s.*받(?:아|아요|니|나요|냐|았어|으세요)?\s*\?\s*$") # a question about Lumi
|
||||
@@ -1201,7 +1215,7 @@ GIVE_EN = re.compile(
|
||||
GIVE_KO = re.compile(
|
||||
rf"^\W*(?:{_THIS_KO}|(?:\S+\s+)?(?:{_OBJ}))?(?:을|를)?\s*(?:좀\s*)?(?:이제\s*)?(?:이리|여기|빨리)?\s*(?:좀\s*)?"
|
||||
rf"(?:{_KO_WHO}(?:한테|에게|께)|(?:나|저)(?=\s))?\s*(?:좀\s*)?(?:{_THIS_KO}(?:을|를)?\s*)?(?:좀\s*)?"
|
||||
r"(?:줘|주세요|줘요|주라|건네 ?줘|건네 ?주세요|건네|드려|드려요|드리세요|주실래요|줄래요?|주시겠어요|주십시오|주실 수 있어요|"
|
||||
r"(?:줘|주세요|줘요|주라|건네 ?줘|건네 ?주세요|건네|돌려 ?줘|돌려 ?주세요|넘겨 ?줘|넘겨 ?주세요|넘겨|드려|드려요|드리세요|주실래요|줄래요?|주시겠어요|주십시오|주실 수 있어요|"
|
||||
r"내놔|내놓아|내놓으세요)(?:\s*봐요?)?\s*[.!?~]*$"
|
||||
rf"|^\W*{_KO_WHO}\s*(?:줘|줘요|주세요)\W*$", re.I)
|
||||
PLACE_EN = re.compile(
|
||||
@@ -1211,6 +1225,7 @@ PLACE_EN = re.compile(
|
||||
PLACE_KO = re.compile(r"(?<!내)(?<!그냥 )(?<!가만히 )(?<!내버려 )(?:놔|놓아|놓으|둬|두세요|올려 ?놔|올려 ?놓|내려 ?놔|내려 ?놓|내려 ?줘|내려 ?주세요|내려 ?둬)"
|
||||
r"(?:으십시오|으세요|으시겠어요)?\s*(?:줘|주세요|요|줄래요?|주시겠어요|주실래요|주십시오|줄 수 있어요?|주실 수 있어요)?\s*[.!?~]*$")
|
||||
OPEN_HAND = re.compile(r"\bopen (?:your |the )?(?:hand|gripper|fingers)\b|\bopen it\b|\blet (?:it )?go\b|"
|
||||
r"^\W*release(?: it)?\W*$|\bloosen your grip\b|(?:놔|놓아)도 ?돼|"
|
||||
r"손을? ?(?:좀 )?(?:펴|벌려|열어)|손 ?open|hand open", re.I)
|
||||
HAND_Q = re.compile(r"^\W*(?:what|how|why|when|where|which|who|do|does|did|is|are|was|were|have you|has)\b|"
|
||||
r"\b(?:things|stuff|objects)\b|물건들|" # "and take things from me?": in general
|
||||
@@ -1261,6 +1276,8 @@ def hand_request(text, holding, b=None, markers=(), whole=True):
|
||||
r"this\b|whoever\b)[a-z]+", t):
|
||||
return None # "give it to Mina": a named person, the mission reader's
|
||||
return ("give", None)
|
||||
if not holding and re.search(LET_GO, t):
|
||||
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):
|
||||
# not "팔 거둬" / "팔 내려" (the arm), not a bare "leave it" (never mind)
|
||||
if named and not holding:
|
||||
@@ -1368,10 +1385,23 @@ IN_LANGUAGE = re.compile(r"^\s*(and |then |now |okay,? |and say it |say (it|that
|
||||
r"\s*[!?.~]*\s*$", re.I)
|
||||
WAVE_ASK = re.compile(r"\bwav(e|ing)(?![a-z])|\bwith your hand\b|\bshake (?:your |my )?hands?\b(?! with\b)|흔들|손 ?인사|인사.*손으로|손으로.*인사", re.I)
|
||||
AGAIN = re.compile(r"\b(?:again|once more|one more time|another one)\b|한 ?번 ?더|다시|또 ?(?:해|보여|불러)", re.I)
|
||||
DO_IT = re.compile(r"^\W*(?:(?:okay|ok|then|so|well|go on|come on)\W+)*(?:do it|show me|go ahead|let'?s see(?: it)?|"
|
||||
DO_IT = re.compile(r"^\W*(?:(?:okay|ok|sure|yes|yeah|then|so|well|go on|come on)\W+)*(?:do it|show me|go ahead|let'?s see(?: it)?|"
|
||||
r"try it|go for it|please do)(?:\W+(?:then|now|please))*\W*$|"
|
||||
r"^\W*(?:그럼|자|어디)?\s*(?:한 ?번\s*)?(?:해 ?봐|해 ?줘|해 ?보세요|해 ?주세요|보여 ?줘|보여 ?주세요)(?:요)?\W*$", re.I)
|
||||
SING_ASK = re.compile(r"\bsing|\bsong|\bmusic\b|노래|한 ?곡|불러", re.I)
|
||||
PROMISE = { # Lumi's own sentence saying it does this now ("Okay! I'll sing a song for you.", "아리랑을 불러 드릴게요.")
|
||||
"sing": re.compile(r"\b(?:i'll|i will|let me|i'm going to) sing\b|\bhere(?:'s| is| comes| goes) (?:a |my |one |the )?song\b|"
|
||||
r"(?:불러|들려)\s*(?:드릴게요|드리겠습니다|줄게|볼게요)|부를게요", re.I),
|
||||
"wave": re.compile(r"\b(?:i'll|i will|let me) wave\b|흔들어\s*(?:드릴게요|볼게요|줄게)|흔들게요", re.I),
|
||||
}
|
||||
NOT_NOW = re.compile(r"\b(?:if|when|later|after|once|next time)\b|나중에|끝나면|으면|다면", re.I) # "... if you'd like"
|
||||
|
||||
|
||||
def promised(sentence):
|
||||
"""'sing' / 'wave' when Lumi's sentence says it does that now, else None: lumi.answer() then does it although the
|
||||
model's action line was none ("Start with one." -> "Okay! I'll sing a song for you." and silence, 2026-10-22)."""
|
||||
s = sentence or ""
|
||||
return None if NOT_NOW.search(s) else next((a for a, r in PROMISE.items() if r.search(s)), None)
|
||||
LOOK_MORE = re.compile(r"^\W*(?:and|now|then|and now)?\s*(up|down|left|right)\W*$|"
|
||||
r"^\W*(?:이제|그럼|그리고)?\s*(위|아래|왼쪽|오른쪽)(?:도|로|으로|요|도요)?\W*$", re.I) # right after a look
|
||||
LOOKUP_MORE = re.compile(r"\b(he|she|him|his|her|they|them|their|there|it|that)\b|거기|그 ?사람|그분|그거|그게|그곳|왜|"
|
||||
@@ -1688,19 +1718,24 @@ class Brain:
|
||||
"""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
|
||||
after a lookup is looked up too."""
|
||||
if header and header["action"] == "sing" and sing.NOT_ASKED.search(text):
|
||||
return {"action": "none", "target": ""} # "Don't sing.", "어제 노래방 갔어요."
|
||||
if not header or not self.history:
|
||||
return header
|
||||
last_q, last_a = self.history[-1]
|
||||
m = re.match(r"\s*\**ACTION\**\s*:\s*(\w+)", last_a)
|
||||
before, action = (m.group(1).lower() if m else ""), header["action"]
|
||||
if action == "sing" and before != "sing" and (not SING_ASK.search(text) or SING_ECHO.match(text)):
|
||||
return {"action": "none", "target": ""} # "Prove it." after "do you have a sense of humour?"
|
||||
if action == "sing" and before != "sing" and (SING_ECHO.match(text) or not SING_ASK.search(text) and
|
||||
not SING_ASK.search(f"{last_q} {last_a}")):
|
||||
return {"action": "none", "target": ""} # "Prove it." after "do you have a sense of humour?";
|
||||
# "Start with one." after Lumi offered its songs is a song
|
||||
if DO_IT.match(text) and action in ("none", "unclear"):
|
||||
asked = "wave" if WAVE_ASK.search(last_q) else "sing" if SING_ASK.search(last_q) else None
|
||||
if asked: # "손 흔들 줄 알아?" -> "해 봐": now do it
|
||||
return {"action": asked, "target": ""}
|
||||
if before in ("wave", "sing") and action in ("none", "unclear") and AGAIN.search(text) and not \
|
||||
re.search(r"\b(?:say|tell|repeat|explain)\b|말해|말씀", text, re.I):
|
||||
re.search(r"\b(?:say|tell|repeat|explain|what|who|where|when|why|which)\b|말해|말씀|뭐|누구|어디|언제|왜",
|
||||
text, re.I): # "What's your name again?" after a song asks the name
|
||||
return {"action": before, "target": ""} # "would you mind doing it again?" after a wave
|
||||
look = LOOK_MORE.match(text)
|
||||
if before == "look" and look and action in ("none", "unclear"):
|
||||
|
||||
Reference in New Issue
Block a user