| 1234567891011121314151617181920212223242526272829303132 |
- import json, collections, re
- p='.scratch/cockpit-real-data-wayfinding/verify/artifacts/t67/geom-none.json'
- with open(p,encoding='utf-8') as f: d=json.load(f)
- feats=d['data']['features']
- print('features:', len(feats))
- # 1) 是否存在 location / 位置描述类字段
- keys=collections.Counter()
- for ft in feats: keys.update((ft.get('properties') or {}).keys())
- print('property keys:', dict(keys))
- # 2) code 前缀分布
- pref=collections.Counter()
- for ft in feats:
- code=str((ft.get('properties') or {}).get('code') or '')
- m=re.match(r'^([A-Za-z]{2})', code)
- pref[m.group(1) if m else '(none)']+=1
- print('code 2-letter prefix:', dict(pref))
- # 3) 按 source 分组看前缀
- bysrc=collections.defaultdict(collections.Counter)
- for ft in feats:
- pr=ft.get('properties') or {}
- code=str(pr.get('code') or '')
- m=re.match(r'^([A-Za-z]{2})', code)
- bysrc[pr.get('source')][m.group(1) if m else '(none)']+=1
- for k,v in bysrc.items(): print('source', k, dict(v))
- # 4) 样例
- for ft in feats[:3]:
- print('SAMPLE', json.dumps(ft.get('properties'), ensure_ascii=False)[:400])
- # 5) 看 name/remark 里是否含 城南/城北/太常
- for word in ['城南','城北','太常']:
- hits=[ (ft.get('properties') or {}).get('code') for ft in feats if word in json.dumps(ft.get('properties') or {}, ensure_ascii=False)]
- print(word, 'appears in', len(hits), 'features; sample codes:', hits[:3])
|