59 lines
3.2 KiB
Go
59 lines
3.2 KiB
Go
package company
|
|
|
|
import "testing"
|
|
|
|
// Regression: the generic invent shapes (" is a … product from …" and
|
|
// " je … znamk|kategor|produkt …") matched any length of copy. In Slovenian " je "
|
|
// appears in almost every sentence and A1 spec lists start with "Znamka: <brand>",
|
|
// so real formula output was classified as invent fallback, discarded, and replaced
|
|
// with the supplier feed text — Review then showed Original ≈ Enriched.
|
|
func TestLooksLikeHeuristicSynthesize_keepsRealFormulaCopy(t *testing.T) {
|
|
t.Parallel()
|
|
slovenianFormulaCopy := "<h2>BRUNNER zložljiv stol ONE SHOT za udobje na poti</h2>" +
|
|
"<p>Zložljiv stol iz aluminija je zasnovan za dolge ure udobnega sedenja na terenu, na snemanju ali ob " +
|
|
"kampiranju. Okvir se razpre v enem gibu in ostane stabilen tudi na neravnih tleh, medtem ko tkanina " +
|
|
"sedišča prijetno diha in se hitro suši. Naslonjala za roke razbremenijo ramena, hrbtni del pa podpira " +
|
|
"naravno držo. Zaradi majhne teže ga brez napora prenesete od avtomobila do prizorišča.</p>" +
|
|
"<h2>Stabilnost in dolga življenjska doba</h2>" +
|
|
"<p>Konstrukcija združuje trpežne materiale in premišljene detajle. Aluminijasti profili so odporni proti " +
|
|
"koroziji, spoji pa so ojačani na mestih največjih obremenitev. Sivo črna kombinacija ostaja videti " +
|
|
"urejena tudi po sezoni uporabe na prostem, saj se madeži manj poznajo.</p>" +
|
|
"<ul><li>Znamka: BRUNNER</li><li>Model: ONE SHOT</li><li>Barva: sivo črna</li></ul>"
|
|
if LooksLikeHeuristicSynthesize(slovenianFormulaCopy) {
|
|
t.Fatal("real Slovenian formula copy must not read as invent fallback")
|
|
}
|
|
|
|
englishFormulaCopy := "<h2>Acme Monitor Pro</h2><p>This monitor is a strong choice for colour-critical work, " +
|
|
"with a factory-calibrated panel and a stand that adjusts through a wide range. Cable routing keeps the " +
|
|
"desk tidy, and the built-in hub means one cable to the laptop. Panel uniformity holds up across the " +
|
|
"whole surface, so gradients stay smooth from edge to edge in long editing sessions.</p>" +
|
|
"<ul><li>Brand: Acme</li><li>Key features: USB-C hub, height adjustment</li></ul>"
|
|
// "Key features" is ordinary section wording: suggestive enough to force a
|
|
// re-enhance, never enough to discard the copy.
|
|
if IsInventFallbackDescription(englishFormulaCopy) {
|
|
t.Fatal("real English formula copy must not read as invent fallback")
|
|
}
|
|
if IsInventFallbackDescription(slovenianFormulaCopy) {
|
|
t.Fatal("real Slovenian formula copy must not read as invent fallback")
|
|
}
|
|
}
|
|
|
|
func TestLooksLikeHeuristicSynthesize_stillCatchesInvent(t *testing.T) {
|
|
t.Parallel()
|
|
cases := []string{
|
|
"Vogel's WALL 3245 is a TV Mounts product from Vogel's. Key specs: width 45 cm, max_load 40 kg.",
|
|
"Gorenje EHT6020 je izdelek znamke Gorenje.",
|
|
"Samsung QLED je izdelek v kategoriji Televizorji.",
|
|
"Acme Widget is a catalog product with the known attributes.",
|
|
"Acme Widget — catalog product.",
|
|
"BRUNNER ONE SHOT — Stolčki, znamka BRUNNER. Širina: 44 cm.",
|
|
"<h2>Gorenje EHT6020</h2><p>Gorenje EHT6020 — Štedilniki, znamka Gorenje.</p>" +
|
|
"<h3>Ključne lastnosti</h3><ul><li>Širina: 60 cm</li></ul>",
|
|
}
|
|
for _, c := range cases {
|
|
if !LooksLikeHeuristicSynthesize(c) {
|
|
t.Fatalf("invent fallback must still be detected: %q", c)
|
|
}
|
|
}
|
|
}
|