src.dackar.RCA.equipment_similarity.equipment_spec_builder¶
equipment_spec_builder — EquipmentSpecBuilder.
Converts KG element_definition properties + failure mode data into a natural-language spec string suitable for embedding. No NLP, no LLM — pure deterministic string assembly. Missing properties are silently omitted.
Attributes¶
Classes¶
Builds a natural-language equipment spec string for embedding. |
Module Contents¶
- src.dackar.RCA.equipment_similarity.equipment_spec_builder._DEFINITION_PROPS = [('domain_category', 'Type'), ('structural_kind', 'Structural kind'), ('nominal_size', 'Nominal...[source]¶
- class src.dackar.RCA.equipment_similarity.equipment_spec_builder.EquipmentSpecBuilder[source]¶
Builds a natural-language equipment spec string for embedding.
The output is intentionally verbose — more context helps the embedding model place the component accurately in semantic space. Downstream similarity is purely cosine distance between these representations.
Example output:
Equipment: Main coolant pump (MCP-A) Type: centrifugal pump Structural kind: horizontal split-case, 4-stage Nominal size: 500 GPM Design pressure: 150 psig Design temperature: 300°F Material: 316 stainless steel Manufacturer: Flowserve Model: VPC-4-150 Failure modes: bearing wear, seal degradation, impeller erosion Failure mechanisms: fatigue, abrasion, corrosion
- build_spec_text(component_id, component_name, definition_props, failure_mode_names=None, failure_mechanisms=None)[source]¶
Build and return the spec text for one component.
- Parameters:
component_id (str) – KG element_usage node ID.
component_name (Optional[str]) – Human-readable name of the component instance.
definition_props (JsonDict) – Dict of element_definition node properties. Keys expected:
domain_category,structural_kind,nominal_size,design_pressure,design_temperature,material_spec,manufacturer,model_number. Missing keys are skipped.failure_mode_names (Optional[List[str]]) – List of failure mode names linked to this component.
failure_mechanisms (Optional[List[str]]) – List of failure mechanism labels (e.g. “fatigue”, “corrosion”).
- Return type:
str