Improve place names in typed commands, give wording and approaches that are blocked
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
+8
-4
@@ -1749,7 +1749,7 @@ def _as_place(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*)?"
|
||||
_AT_OBJ_KO = (rf"\s*(?:(?:테이블|탁자|책상|table)\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
|
||||
|
||||
@@ -1768,14 +1768,18 @@ def _mentions(text, markers):
|
||||
for m in re.finditer(_place_re(markers), t):
|
||||
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) \
|
||||
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)) \
|
||||
or (re.match(r"\s+(?:까지\s*)?가서", after) and objs and m.start() < objs[-1].start()) \
|
||||
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)
|
||||
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.search(r"\b(go|drive|head|walk|carry it|take it|bring it)( over)? (the )?$", before) \
|
||||
or re.match(r"\s*(?:(?:포인트|point|지점|테이블|탁자|책상)\s*(?:위\s*)?)?(으로|로|에다|에|한테)(?!서)", after) or place == "here" \
|
||||
or re.match(r"\s+(?:까지\s*)?(?:가(?:서|요|\s*줘|\s*주세요)?|이동)(?![가-힣])", after):
|
||||
# ^ "and go exit point", "exit 가서", "exit 까지 가 줘": a drive there, said without "to" / 로
|
||||
out["dest"] = _as_place(place)
|
||||
for m in re.finditer(r"\bfrom (?:the )?([a-z]+)", t): # "from the kitchen": a place not on the map
|
||||
if not re.match(_place_re(markers), t[m.start(1):]) and "source" not in out:
|
||||
@@ -1787,7 +1791,7 @@ def _mentions(text, markers):
|
||||
if m.start() > after_obj and "dest" not in out and not re.match(rf"{_TABLE}|{_place_re(markers)}", t[m.start(1):]) \
|
||||
and m.group(1) not in ("put", "place", "hold", "give", "keep", "bring", "leave"):
|
||||
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"
|
||||
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)
|
||||
|
||||
Reference in New Issue
Block a user