hldp(zhuyuan): integrate fifth-domain world tree and TCS brain
This commit is contained in:
parent
9782d04246
commit
4496f75857
42 changed files with 1720 additions and 268 deletions
|
|
@ -15,9 +15,19 @@ def recall(query, map_path=DEFAULT_MAP):
|
|||
terms = [part for part in needle.replace("/", " ").split() if part]
|
||||
matches = []
|
||||
for item in data["contributions"]:
|
||||
identifiers = [item["id"], item["arrival_id"], *item.get("project_ids", [])]
|
||||
keywords = item.get("keywords", [])
|
||||
haystack = " ".join([*identifiers, item["arrival_name"], item["title"], *keywords]).casefold()
|
||||
identifiers = [
|
||||
value
|
||||
for value in [item.get("id"), item.get("arrival_id"), *item.get("project_ids", [])]
|
||||
if isinstance(value, str) and value
|
||||
]
|
||||
keywords = [value for value in item.get("keywords", []) if isinstance(value, str) and value]
|
||||
searchable = [
|
||||
*identifiers,
|
||||
item.get("arrival_name"),
|
||||
item.get("title"),
|
||||
*keywords,
|
||||
]
|
||||
haystack = " ".join(value for value in searchable if isinstance(value, str) and value).casefold()
|
||||
score = 0
|
||||
reasons = []
|
||||
for identifier in identifiers:
|
||||
|
|
|
|||
|
|
@ -24,6 +24,12 @@ class RouteRecallTest(unittest.TestCase):
|
|||
def test_unknown_does_not_guess(self):
|
||||
self.assertEqual(recall("完全不存在的火星工程")["status"], "NO_TRUSTED_PATH")
|
||||
|
||||
def test_contribution_without_arrival_id_is_searchable(self):
|
||||
result = recall("光湖代码频道")
|
||||
self.assertEqual(result["status"], "FOUND_CONFIDENT_PATH")
|
||||
self.assertEqual(result["matches"][0]["contribution_id"], "ZY-CONTRIB-20260723-001")
|
||||
self.assertIsNone(result["matches"][0]["arrival"]["id"])
|
||||
|
||||
def test_all_canonical_paths_exist(self):
|
||||
data = json.loads(DEFAULT_MAP.read_text(encoding="utf-8"))
|
||||
missing = [path for item in data["contributions"] for path in item["canonical_paths"] if not (ROOT / path).exists()]
|
||||
|
|
|
|||
Loading…
Reference in a new issue