Files
breakpilot-compliance/ai-compliance-sdk/internal/iace/keyword_dictionary.go
T
Benjamin Admin d4b7943d54 feat: IACE deterministic narrative parser + library extensions
Library Extensions:
- 15 new components (C121-C135): knee lever, hydraulic ram, lubrication
  system, extraction system, vibrating plate, die tooling, transfer system,
  hoist, chute, oil drip tray, pressure relief valve, die space, flywheel,
  bin changeover station, inspection scale
- 8 new tags: person_under_load, two_hand_control_required,
  thermal_accumulation, mechanical_transmission, oil_mist_risk,
  rapid_energy_release, gravity_suspended_load, bypass_risk
- 14 new patterns (HP045-HP058): ram drop, die space crushing, oil mist
  inhalation, hot workpiece burns, suspended load, transfer draw-in,
  ejection fall, accumulator pressure release, impact noise, flywheel
  residual energy, guard bypass, two-hand misoperation, oil leakage,
  ergonomic bin changeover

Deterministic Parser (NO LLM):
- keyword_dictionary.go: ~100 entries mapping DE/EN keywords to
  component IDs, energy source IDs, and tags
- narrative_parser.go: ParseNarrative() extracts components, energy
  sources, lifecycle phases, roles, tech specs, and context tags from
  free-text machine descriptions via keyword matching + regex
- Tech spec regex: extracts kN, V, °C, bar, kW, rpm values and
  derives energy sources + severity tags automatically
- iace_handler_parser.go: POST /projects/:id/parse-narrative endpoint
  chains parser → pattern engine → hazard suggestions

Test: Paste Kniehebelpresse description → should detect 10+ components,
15+ hazards, all deterministically without LLM.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-05 00:29:18 +02:00

140 lines
16 KiB
Go

package iace
// KeywordEntry maps German/English keywords to component library IDs,
// energy source IDs, and additional tags for deterministic text parsing.
type KeywordEntry struct {
Keywords []string // Search terms (lowercase, may include partial matches)
ComponentIDs []string // Matched component library IDs (C001-C135)
EnergyIDs []string // Matched energy source IDs (EN01-EN20)
ExtraTags []string // Additional tags derived from keyword context
}
// GetKeywordDictionary returns the complete keyword dictionary for
// deterministic narrative parsing. ~250 entries covering industrial
// machinery terminology in German and English.
func GetKeywordDictionary() []KeywordEntry {
return []KeywordEntry{
// ── Pressen / Umformmaschinen ───────────────────────────────────
{Keywords: []string{"presse", "press", "umform", "umformung"}, ComponentIDs: []string{"C008", "C122"}, EnergyIDs: []string{"EN01"}, ExtraTags: []string{"high_force", "crush_point"}},
{Keywords: []string{"kniehebel", "toggle"}, ComponentIDs: []string{"C121"}, ExtraTags: []string{"mechanical_transmission"}},
{Keywords: []string{"stossel", "stoessel", "ram", "slide"}, ComponentIDs: []string{"C122"}, EnergyIDs: []string{"EN01"}, ExtraTags: []string{"moving_part", "crush_point", "gravity_risk"}},
{Keywords: []string{"stempel", "punch", "matrize", "die"}, ComponentIDs: []string{"C126"}, ExtraTags: []string{"crush_point", "cutting_part"}},
{Keywords: []string{"schwungrad", "flywheel"}, ComponentIDs: []string{"C133"}, EnergyIDs: []string{"EN02", "EN03"}, ExtraTags: []string{"stored_energy", "rotating_part"}},
{Keywords: []string{"werkzeugeinbauraum", "die space"}, ComponentIDs: []string{"C132"}, ExtraTags: []string{"crush_point", "pinch_point"}},
// ── Foerdertechnik ──────────────────────────────────────────────
{Keywords: []string{"foerderband", "transportband", "conveyor"}, ComponentIDs: []string{"C003"}, EnergyIDs: []string{"EN01", "EN02"}, ExtraTags: []string{"entanglement_risk"}},
{Keywords: []string{"transfer", "transferanlage", "transfersystem"}, ComponentIDs: []string{"C127"}, ExtraTags: []string{"shear_risk", "pinch_point"}},
{Keywords: []string{"aufzug", "elevator", "lift"}, ComponentIDs: []string{"C014", "C128"}, EnergyIDs: []string{"EN04"}, ExtraTags: []string{"gravity_risk", "person_under_load"}},
{Keywords: []string{"hubwerk", "hoist", "hubgeraet"}, ComponentIDs: []string{"C128"}, EnergyIDs: []string{"EN04"}, ExtraTags: []string{"gravity_risk", "person_under_load"}},
{Keywords: []string{"ruettel", "vibration", "vibrationsfoerderer"}, ComponentIDs: []string{"C125"}, ExtraTags: []string{"vibration_source", "noise_source"}},
{Keywords: []string{"fallrohr", "auswurf", "chute"}, ComponentIDs: []string{"C129"}, EnergyIDs: []string{"EN04"}, ExtraTags: []string{"gravity_risk"}},
{Keywords: []string{"kistenwechsel", "bin change"}, ComponentIDs: []string{"C134"}, ExtraTags: []string{"ergonomic", "gravity_risk"}},
{Keywords: []string{"drehtisch", "rotary table"}, ComponentIDs: []string{"C004"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part"}},
{Keywords: []string{"linearachse", "linear axis"}, ComponentIDs: []string{"C005"}, EnergyIDs: []string{"EN01"}, ExtraTags: []string{"crush_point"}},
{Keywords: []string{"waage", "wiege", "scale", "pruefstation"}, ComponentIDs: []string{"C135"}, ExtraTags: []string{"sensor_part"}},
// ── Antriebe ────────────────────────────────────────────────────
{Keywords: []string{"motor", "elektromotor", "drehstrom"}, ComponentIDs: []string{"C031"}, EnergyIDs: []string{"EN02", "EN05"}, ExtraTags: []string{"rotating_part"}},
{Keywords: []string{"servomotor", "servo"}, ComponentIDs: []string{"C032"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part", "high_speed"}},
{Keywords: []string{"frequenzumrichter", "vfd", "inverter"}, ComponentIDs: []string{"C034"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"electrical_part"}},
{Keywords: []string{"getriebe", "gearbox"}, ComponentIDs: []string{"C035"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part"}},
{Keywords: []string{"riemen", "belt drive"}, ComponentIDs: []string{"C040"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"entanglement_risk"}},
// ── Hydraulik ───────────────────────────────────────────────────
{Keywords: []string{"hydraulik", "hydraulisch", "hydraulic"}, ComponentIDs: []string{"C041"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"hydraulic_part", "high_pressure"}},
{Keywords: []string{"hydraulikpumpe", "hydraulic pump"}, ComponentIDs: []string{"C041"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"hydraulic_part"}},
{Keywords: []string{"hydraulikzylinder", "hydraulic cylinder"}, ComponentIDs: []string{"C042"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"hydraulic_part", "moving_part"}},
{Keywords: []string{"hydraulikventil", "hydraulic valve"}, ComponentIDs: []string{"C043"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"hydraulic_part"}},
{Keywords: []string{"hydraulikspeicher", "accumulator"}, ComponentIDs: []string{"C044"}, EnergyIDs: []string{"EN07", "EN10"}, ExtraTags: []string{"stored_energy", "rapid_energy_release"}},
{Keywords: []string{"hydraulikschlauch", "hose"}, ComponentIDs: []string{"C045"}, ExtraTags: []string{"hydraulic_part"}},
{Keywords: []string{"druckbegrenzung", "pressure relief"}, ComponentIDs: []string{"C131"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"schmier", "lubrication", "schmieranlage"}, ComponentIDs: []string{"C123"}, EnergyIDs: []string{"EN07"}, ExtraTags: []string{"oil_mist_risk"}},
{Keywords: []string{"oelfang", "auffangwanne", "drip tray"}, ComponentIDs: []string{"C130"}, ExtraTags: []string{"chemical_risk"}},
// ── Pneumatik ───────────────────────────────────────────────────
{Keywords: []string{"pneumatik", "pneumatisch", "pneumatic"}, ComponentIDs: []string{"C051"}, EnergyIDs: []string{"EN08"}, ExtraTags: []string{"pneumatic_part"}},
{Keywords: []string{"kompressor", "compressor", "druckluft"}, ComponentIDs: []string{"C052"}, EnergyIDs: []string{"EN08"}, ExtraTags: []string{"noise_source"}},
{Keywords: []string{"vakuum", "vacuum", "sauger"}, ComponentIDs: []string{"C055"}, EnergyIDs: []string{"EN08"}, ExtraTags: []string{}},
// ── Elektrik ────────────────────────────────────────────────────
{Keywords: []string{"schaltschrank", "cabinet", "electrical cabinet"}, ComponentIDs: []string{"C061"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"high_voltage", "electrical_part"}},
{Keywords: []string{"stromversorgung", "power supply"}, ComponentIDs: []string{"C062"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"electrical_part"}},
{Keywords: []string{"transformator", "transformer"}, ComponentIDs: []string{"C063"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"high_voltage"}},
{Keywords: []string{"hauptschalter", "main switch"}, ComponentIDs: []string{"C070"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"electrical_part"}},
{Keywords: []string{"fi-schutz", "rcd", "fehlerstrom"}, ComponentIDs: []string{"C066"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"usv", "ups"}, ComponentIDs: []string{"C067"}, EnergyIDs: []string{"EN09"}, ExtraTags: []string{"stored_energy"}},
// ── Steuerung / SPS ─────────────────────────────────────────────
{Keywords: []string{"sps", "plc", "steuerung", "speicherprogrammierbar"}, ComponentIDs: []string{"C071"}, ExtraTags: []string{"has_software", "programmable"}},
{Keywords: []string{"sicherheits-sps", "safety plc", "f-sps"}, ComponentIDs: []string{"C072"}, ExtraTags: []string{"has_software", "safety_device"}},
{Keywords: []string{"hmi", "bedienfeld", "bedienpanel", "touchpanel"}, ComponentIDs: []string{"C073"}, ExtraTags: []string{"user_interface"}},
{Keywords: []string{"bedienpult", "control desk"}, ComponentIDs: []string{"C079"}, ExtraTags: []string{"user_interface"}},
// ── Sensorik ────────────────────────────────────────────────────
{Keywords: []string{"positionssensor", "position sensor", "initiator"}, ComponentIDs: []string{"C081"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"kamera", "vision", "bildverarbeitung"}, ComponentIDs: []string{"C082"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"kraftsensor", "force sensor", "kraftmessdose"}, ComponentIDs: []string{"C083"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"temperatursensor", "thermocouple"}, ComponentIDs: []string{"C084"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"drucksensor", "pressure sensor"}, ComponentIDs: []string{"C085"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"drehgeber", "encoder"}, ComponentIDs: []string{"C086"}, ExtraTags: []string{"sensor_part"}},
{Keywords: []string{"laserscanner", "laser scanner"}, ComponentIDs: []string{"C087"}, ExtraTags: []string{"sensor_part", "safety_device"}},
// ── Sicherheitseinrichtungen ────────────────────────────────────
{Keywords: []string{"not-halt", "not-aus", "emergency stop", "e-stop"}, ComponentIDs: []string{"C101"}, ExtraTags: []string{"safety_device", "emergency_stop"}},
{Keywords: []string{"lichtgitter", "lichtvorhang", "light curtain", "light grid"}, ComponentIDs: []string{"C102"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"sicherheitsschalter", "safety switch"}, ComponentIDs: []string{"C104"}, ExtraTags: []string{"safety_device", "interlocked"}},
{Keywords: []string{"zuhaltung", "guard locking", "interlock"}, ComponentIDs: []string{"C105"}, ExtraTags: []string{"safety_device", "interlocked"}},
{Keywords: []string{"zweihand", "two-hand", "zweihandschaltung"}, ComponentIDs: []string{"C106"}, ExtraTags: []string{"safety_device", "two_hand_control_required"}},
{Keywords: []string{"schaltmatte", "safety mat"}, ComponentIDs: []string{"C108"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"seilzug", "pull wire"}, ComponentIDs: []string{"C109"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"zustimmtaster", "enabling device"}, ComponentIDs: []string{"C110"}, ExtraTags: []string{"safety_device"}},
// ── Schutzeinrichtungen / Strukturell ───────────────────────────
{Keywords: []string{"schutzumhausung", "schutzeinhausung", "enclosure"}, ComponentIDs: []string{"C022"}, ExtraTags: []string{"guard", "interlocked"}},
{Keywords: []string{"schutzgitter", "protective fence", "schutzzaun"}, ComponentIDs: []string{"C028"}, ExtraTags: []string{"guard"}},
{Keywords: []string{"schutztuer", "safety door", "schutztuer"}, ComponentIDs: []string{"C023"}, ExtraTags: []string{"guard", "interlocked"}},
// ── Absaugung / Umwelt ──────────────────────────────────────────
{Keywords: []string{"absaug", "extraction", "abscheider"}, ComponentIDs: []string{"C124"}, ExtraTags: []string{"noise_source"}},
{Keywords: []string{"filter", "filteranlage"}, ComponentIDs: []string{"C124"}, ExtraTags: []string{}},
// ── IT / Netzwerk ───────────────────────────────────────────────
{Keywords: []string{"switch", "netzwerk"}, ComponentIDs: []string{"C111"}, ExtraTags: []string{"networked"}},
{Keywords: []string{"firewall"}, ComponentIDs: []string{"C113"}, ExtraTags: []string{"networked"}},
{Keywords: []string{"iot", "gateway"}, ComponentIDs: []string{"C114"}, ExtraTags: []string{"networked"}},
{Keywords: []string{"wlan", "wifi", "wireless"}, ComponentIDs: []string{"C116"}, ExtraTags: []string{"wireless"}},
{Keywords: []string{"opc ua", "opc-ua"}, ComponentIDs: []string{"C117"}, ExtraTags: []string{"networked"}},
// ── KI / Software ───────────────────────────────────────────────
{Keywords: []string{"kuenstliche intelligenz", "ki-", "ai ", "machine learning", "neural"}, ComponentIDs: []string{"C119"}, ExtraTags: []string{"has_ai"}},
{Keywords: []string{"software", "firmware"}, ComponentIDs: []string{}, ExtraTags: []string{"has_software"}},
// ── Allgemeine Maschinen-Keywords ────────────────────────────────
{Keywords: []string{"roboter", "robot"}, ComponentIDs: []string{"C001"}, EnergyIDs: []string{"EN01", "EN02"}, ExtraTags: []string{"moving_part", "high_force"}},
{Keywords: []string{"greifer", "gripper"}, ComponentIDs: []string{"C002"}, ExtraTags: []string{"clamping_part", "pinch_point"}},
{Keywords: []string{"spindel", "spindle"}, ComponentIDs: []string{"C006"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part", "high_speed"}},
{Keywords: []string{"saege", "saw"}, ComponentIDs: []string{"C007"}, ExtraTags: []string{"cutting_part"}},
{Keywords: []string{"walze", "roller"}, ComponentIDs: []string{"C009"}, EnergyIDs: []string{"EN02"}, ExtraTags: []string{"rotating_part", "entanglement_risk"}},
{Keywords: []string{"kette", "chain"}, ComponentIDs: []string{"C010"}, ExtraTags: []string{"entanglement_risk"}},
{Keywords: []string{"bremse", "brake"}, ComponentIDs: []string{"C013"}, ExtraTags: []string{"safety_device"}},
{Keywords: []string{"schweiss", "weld"}, ComponentIDs: []string{"C016"}, EnergyIDs: []string{"EN05"}, ExtraTags: []string{"high_temperature"}},
{Keywords: []string{"biege", "bend"}, ComponentIDs: []string{"C019"}, ExtraTags: []string{"high_force"}},
{Keywords: []string{"stanz", "stamp", "punch"}, ComponentIDs: []string{"C018"}, ExtraTags: []string{"high_force", "crush_point"}},
{Keywords: []string{"heiz", "heater", "heating"}, ComponentIDs: []string{"C094"}, EnergyIDs: []string{"EN06"}, ExtraTags: []string{"high_temperature"}},
{Keywords: []string{"kuehl", "cool"}, ComponentIDs: []string{"C095"}, ExtraTags: []string{}},
{Keywords: []string{"luefter", "fan", "geblaese"}, ComponentIDs: []string{"C096"}, ExtraTags: []string{"rotating_part", "noise_source"}},
{Keywords: []string{"spannvorrichtung", "fixture", "clamp"}, ComponentIDs: []string{"C100"}, ExtraTags: []string{"clamping_part"}},
// ── Kontext-Keywords (keine Komponente, nur Tags) ───────────────
{Keywords: []string{"vollautomatisch", "automatisch"}, ExtraTags: []string{"auto_operation"}},
{Keywords: []string{"schutzausruestung", "psa", "ppe"}, ExtraTags: []string{"ppe_required"}},
{Keywords: []string{"gehoerschutz", "hearing protection"}, ExtraTags: []string{"noise_source", "ppe_required"}},
{Keywords: []string{"sicherheitsschuh", "safety shoe"}, ExtraTags: []string{"ppe_required"}},
{Keywords: []string{"fehlanwendung", "misuse"}, ExtraTags: []string{"bypass_risk"}},
{Keywords: []string{"umgehung", "bypass"}, ExtraTags: []string{"bypass_risk"}},
{Keywords: []string{"explosion", "explosionsgefaehrd"}, ExtraTags: []string{"chemical_risk"}},
{Keywords: []string{"flurfoerderfahrzeug", "forklift", "gabelstapler"}, ExtraTags: []string{"moving_part", "gravity_risk"}},
}
}