MCPcopy Create free account
hub / github.com/AMAP-ML/Thinking-with-Map / find_coords_json

Function find_coords_json

api_evaluation/api_test.py:32–46  ·  view source on GitHub ↗

提取包含 lat/lon/city/country 的 JSON 对象

(text)

Source from the content-addressed store, hash-verified

30 return objects
31
32def find_coords_json(text):
33 """
34 提取包含 lat/lon/city/country 的 JSON 对象
35 """
36 json_candidates = extract_all_json_objects(text)
37
38 for cand in json_candidates:
39 try:
40 obj = json.loads(cand)
41 except json.JSONDecodeError:
42 continue
43
44 if all(k in obj for k in ("lat", "lon", "city", "country")):
45 return obj
46 return None
47
48def extract_solution(solution_str):
49 result = find_coords_json(solution_str)

Callers 1

extract_solutionFunction · 0.70

Calls 1

extract_all_json_objectsFunction · 0.70

Tested by

no test coverage detected