fix(navigation): Resolve planner loop, semantic mapping, and structural verification

This commit is contained in:
2026-05-06 00:43:28 +02:00
parent 1fbc2140c7
commit 5389369cef
31 changed files with 832 additions and 641 deletions

42
scripts/debug_intent.py Normal file
View File

@@ -0,0 +1,42 @@
import re
from GramAddict.core.perception.intent_resolver import _humanize_desc
from GramAddict.core.perception.spatial_parser import SpatialParser
def main():
with open("tests/fixtures/user_profile_dump.xml", "r", encoding="utf-8") as f:
xml = f.read()
parser = SpatialParser()
root = parser.parse(xml)
candidates = parser.get_clickable_nodes(root)
intent_description = "tap 'following' list"
quotes = re.findall(r"['\"](.*?)['\"]", intent_description)
target_text = quotes[0].lower()
localized_targets = [target_text]
semantic_candidates = []
for node in candidates:
n_text = _humanize_desc((node.text or "").lower())
n_desc = _humanize_desc((node.content_desc or "").lower())
for loc_target in localized_targets:
pattern = r"\b" + re.escape(loc_target) + r"\b"
if (
re.search(pattern, n_text)
or re.search(pattern, n_desc)
or loc_target in (node.resource_id or "").lower()
):
semantic_candidates.append(node)
break
print(f"Quotes: {quotes}")
print(f"Num semantic candidates: {len(semantic_candidates)}")
for i, n in enumerate(semantic_candidates):
print(f"[{i}] id={n.resource_id} desc={n.content_desc} text={n.text}")
if __name__ == "__main__":
main()