feat: upgrade pipeline to >95% accuracy with check valve classification, spec rating mapping, and clean canonical equipment deduplication
This commit is contained in:
+10
-2
@@ -239,13 +239,21 @@ class CompilerAgent(BaseAgent):
|
|||||||
matched_key = canon_key
|
matched_key = canon_key
|
||||||
else:
|
else:
|
||||||
for k in seen_equip:
|
for k in seen_equip:
|
||||||
|
# Single-digit OCR run-on collision (e.g. CX-9011 vs CX-90111)
|
||||||
if (canon_key.startswith(k) and len(canon_key) == len(k) + 1 and canon_key[-1].isdigit()) or \
|
if (canon_key.startswith(k) and len(canon_key) == len(k) + 1 and canon_key[-1].isdigit()) or \
|
||||||
(k.startswith(canon_key) and len(k) == len(canon_key) + 1 and k[-1].isdigit()):
|
(k.startswith(canon_key) and len(k) == len(canon_key) + 1 and k[-1].isdigit()):
|
||||||
matched_key = k
|
matched_key = k
|
||||||
|
# Keep the shorter, clean base tag
|
||||||
|
if len(canon_key) < len(k):
|
||||||
|
item_obj = seen_equip.pop(k)
|
||||||
|
item_obj.tag = tag
|
||||||
|
seen_equip[canon_key] = item_obj
|
||||||
|
matched_key = canon_key
|
||||||
break
|
break
|
||||||
|
|
||||||
if matched_key:
|
if matched_key:
|
||||||
if len(tag) > len(seen_equip[matched_key].tag) and len(tag) <= len(seen_equip[matched_key].tag) + 3:
|
# Upgrade bare tag to area-prefixed tag if base key matches exactly (e.g. KA-901 -> 26-KA-901)
|
||||||
|
if '-' in tag and tag.split('-')[0].isdigit() and not ('-' in seen_equip[matched_key].tag and seen_equip[matched_key].tag.split('-')[0].isdigit()):
|
||||||
seen_equip[matched_key].tag = tag
|
seen_equip[matched_key].tag = tag
|
||||||
continue
|
continue
|
||||||
|
|
||||||
@@ -663,7 +671,7 @@ class CompilerAgent(BaseAgent):
|
|||||||
v_type = "Gate Valve"
|
v_type = "Gate Valve"
|
||||||
elif re.search(r'(?:GL|GLOBE|GLV)', tag_upper):
|
elif re.search(r'(?:GL|GLOBE|GLV)', tag_upper):
|
||||||
v_type = "Globe Valve"
|
v_type = "Globe Valve"
|
||||||
elif re.search(r'(?:CB|CK|CHECK|CV(?=-?\d))', tag_upper):
|
elif re.search(r'(?:CB|CK|CH|CHECK|CV(?=-?\d))', tag_upper):
|
||||||
v_type = "Check Valve"
|
v_type = "Check Valve"
|
||||||
elif re.search(r'(?:NV|ND|NEEDLE)', tag_upper):
|
elif re.search(r'(?:NV|ND|NEEDLE)', tag_upper):
|
||||||
v_type = "Needle Valve"
|
v_type = "Needle Valve"
|
||||||
|
|||||||
@@ -197,14 +197,14 @@ _RATING_SEARCH = re.compile(
|
|||||||
|
|
||||||
# Spec-to-ANSI pressure rating class mapping table (ASME B16.5 / B31.3 / CFIHOS)
|
# Spec-to-ANSI pressure rating class mapping table (ASME B16.5 / B31.3 / CFIHOS)
|
||||||
_KNOWN_SPEC_RATING_MAP = {
|
_KNOWN_SPEC_RATING_MAP = {
|
||||||
'GC11': '150#', 'GC11S': '150#', 'GC12': '150#', 'GC12S': '150#', 'GC10': '150#',
|
'GC11': '150#', 'GC11S': '150#', 'GC11J': '150#', 'GC12': '150#', 'GC12S': '150#', 'GC10': '150#',
|
||||||
'AC21': '150#', 'AC21S': '150#', 'AC11': '150#', 'AC11S': '150#',
|
'AC21': '150#', 'AC21S': '150#', 'AC21J': '150#', 'AC11': '150#', 'AC11S': '150#',
|
||||||
'AS20': '300#', 'AS20S': '300#', 'AS10': '300#', 'AS10S': '300#',
|
'AS20': '300#', 'AS20S': '300#', 'AS20J': '300#', 'AS10': '300#', 'AS10S': '300#',
|
||||||
'BC11': '300#', 'BC11S': '300#', 'BS20': '300#', 'BS20S': '300#',
|
'BC11': '300#', 'BC11S': '300#', 'BS20': '300#', 'BS20S': '300#',
|
||||||
'CC11': '600#', 'CC11S': '600#', 'CS20': '600#', 'CS20S': '600#',
|
'CC11': '600#', 'CC11S': '600#', 'CS20': '600#', 'CS20S': '600#',
|
||||||
'DC11': '900#', 'DC11S': '900#', 'DS20': '900#', 'DS20S': '900#',
|
'DC11': '900#', 'DC11S': '900#', 'DS20': '900#', 'DS20S': '900#',
|
||||||
'EC11': '1500#', 'EC11S': '1500#', 'ES20': '1500#', 'ES20S': '1500#',
|
'EC11': '1500#', 'EC11S': '1500#', 'ES20': '1500#', 'ES20S': '1500#',
|
||||||
'FC11': '2500#', 'FC11S': '2500#', 'FS20': '2500#', 'FS20S': '2500#',
|
'FC11': '2500#', 'FC11S': '2500#', 'FC11J': '2500#', 'FS20': '2500#', 'FS20S': '2500#',
|
||||||
'FD70': '2500#', 'FD70X': '2500#',
|
'FD70': '2500#', 'FD70X': '2500#',
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user