This commit is contained in:
2026-08-23 20:49:40 +02:00
parent 3b678ca857
commit f3d4fb56ed
31 changed files with 3608 additions and 111 deletions
+40 -1
View File
@@ -9,7 +9,10 @@ import (
var (
reQuotedNameSlot = regexp.MustCompile(`"([^"]+)"`)
reNameFormulaTail = regexp.MustCompile(`(?is)formuli\s*:\s*(.*?)(?:\.?\s*Ne uporabljaj|\.?$)`)
// Slovenian legacy ("… po formuli: … Ne uporabljaj vejic.") and the English
// platform-default translation ("… using this formula: … Do not use commas.").
reNameFormulaTail = regexp.MustCompile(`(?is)formuli\s*:\s*(.*?)(?:\.?\s*Ne uporabljaj|\.?$)`)
reNameFormulaTailEN = regexp.MustCompile(`(?is)formula\s*:\s*(.*?)(?:\.?\s*Do not use|\.?$)`)
)
// TitleFormulaElement is one ordered slot in categories.title_template.
@@ -183,6 +186,8 @@ func extractLegacyNameSlots(rules string) []string {
body := rules
if m := reNameFormulaTail.FindStringSubmatch(rules); len(m) == 2 {
body = m[1]
} else if m := reNameFormulaTailEN.FindStringSubmatch(rules); len(m) == 2 {
body = m[1]
}
raw := reQuotedNameSlot.FindAllStringSubmatch(body, -1)
out := make([]string, 0, len(raw))
@@ -203,6 +208,40 @@ func mapLegacyNameSlot(slot string) (TitleFormulaElement, bool) {
return TitleFormulaElement{}, false
}
low := strings.ToLower(s)
// English platform-default slots (defaults/default-category-prompts.json) are
// matched before the Slovenian legacy vocabulary. Slovenian rules below are
// deliberately unchanged: A1's derived templates are already stored, and adding
// keywords there would churn them on every repair pass.
switch {
case strings.Contains(low, "product model"), strings.Contains(low, "device model"),
strings.Contains(low, "model of the device"):
return TitleFormulaElement{Type: "variable", Label: "Model", Value: "product_model", Description: s, Example: "EHT6020"}, true
case strings.Contains(low, "brand"):
return TitleFormulaElement{Type: "variable", Label: "Brand", Value: "brand", Description: s, Example: "Samsung"}, true
case strings.Contains(low, "product type"):
return TitleFormulaElement{Type: "variable", Label: "Product type", Value: "product_type", Description: s, Example: "Bluetooth speaker"}, true
case strings.Contains(low, "graphics card"):
return TitleFormulaElement{Type: "variable", Label: "GPU", Value: "graficna_kartica", Description: s}, true
case strings.Contains(low, "processor"):
return TitleFormulaElement{Type: "variable", Label: "CPU", Value: "procesor", Description: s}, true
case strings.Contains(low, "memory"):
return TitleFormulaElement{Type: "variable", Label: "Memory", Value: "kapaciteta_ram_pomnilnika", Description: s}, true
case strings.Contains(low, "screen diagonal"), strings.Contains(low, "screen size"):
return TitleFormulaElement{Type: "variable", Label: "Diagonal", Value: "diagonala_zaslona", Description: s}, true
case strings.Contains(low, "refresh rate"):
return TitleFormulaElement{Type: "variable", Label: "Refresh rate", Value: "refresh_rate", Description: s}, true
case strings.Contains(low, "weight group"):
return TitleFormulaElement{Type: "variable", Label: "Weight group", Value: "weight_group", Description: s}, true
case strings.Contains(low, "wash capacity"), strings.Contains(low, "capacity"):
return TitleFormulaElement{Type: "variable", Label: "Capacity", Value: "kapaciteta", Description: s}, true
case strings.Contains(low, "connector type"), strings.Contains(low, "socket type"),
strings.Contains(low, "cable type"):
return TitleFormulaElement{Type: "variable", Label: "Connector", Value: "connector", Description: s}, true
case strings.Contains(low, "colour"), strings.Contains(low, "color"):
return TitleFormulaElement{Type: "variable", Label: "Color", Value: "barva", Description: s}, true
case strings.Contains(low, "dimensions"):
return TitleFormulaElement{Type: "variable", Label: "Dimensions", Value: "dimensions", Description: s}, true
}
switch {
case strings.Contains(low, "znamka"):
return TitleFormulaElement{Type: "variable", Label: "Brand", Value: "brand", Description: s, Example: "Samsung"}, true