fix: Struktureller Fix — Maschinentyp-Filter fuer Keywords + Patterns
PROBLEM: Cobot-Projekt hatte 52 Pressen-Hazards weil Keywords wie "stempel" und "stoessel" ohne Maschinentyp-Kontext matchten. FIX an 3 Stellen: 1. KeywordEntry.MachineTypes — Pressen-Keywords nur fuer press/*_press 2. ParseNarrative(text, machineType) — Parser laedt Maschinentyp aus Projekt 3. HazardPattern.MachineTypes — Pressen-Patterns (HP045-HP058) nur fuer Pressen Verhindert zukuenftig falsche Zuordnungen bei neuen Kundenprojekten. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -94,7 +94,9 @@ var roleKeywords = map[string]string{
|
||||
// ParseNarrative extracts components, energy sources, lifecycle phases,
|
||||
// roles, and tags from a machine description text. Fully deterministic,
|
||||
// no LLM required.
|
||||
func ParseNarrative(text string) ParseResult {
|
||||
// machineType is optional — if provided, keywords with MachineTypes
|
||||
// restrictions are only matched when the machine type is in the list.
|
||||
func ParseNarrative(text string, machineType ...string) ParseResult {
|
||||
result := ParseResult{}
|
||||
if text == "" {
|
||||
return result
|
||||
@@ -122,7 +124,27 @@ func ParseNarrative(text string) ParseResult {
|
||||
seenEnergy := make(map[string]bool)
|
||||
tagSet := make(map[string]bool)
|
||||
|
||||
// Resolve machine type for filtering
|
||||
var mType string
|
||||
if len(machineType) > 0 {
|
||||
mType = machineType[0]
|
||||
}
|
||||
|
||||
for _, entry := range dictionary {
|
||||
// Skip keywords restricted to other machine types
|
||||
if len(entry.MachineTypes) > 0 && mType != "" {
|
||||
matched := false
|
||||
for _, mt := range entry.MachineTypes {
|
||||
if mt == mType {
|
||||
matched = true
|
||||
break
|
||||
}
|
||||
}
|
||||
if !matched {
|
||||
continue // This keyword is for a different machine type
|
||||
}
|
||||
}
|
||||
|
||||
for _, kw := range entry.Keywords {
|
||||
kwNorm := strings.ToLower(kw)
|
||||
kwNorm = strings.ReplaceAll(kwNorm, "ä", "ae")
|
||||
|
||||
Reference in New Issue
Block a user