Skip to content

armgit / laya

Public Imported from GitHub
0

Non-autoregressive System 1 decision engine. Typed choice, score and yes/no decisions over any text in a single forward pass, in 100+ languages, with a router that picks the right checkpoint per request.

test(cpp): lang boundary cases recorded from Python

Adeshina Lasisice9b12d863d0
diff --git a/laya-cpp/tests/lang_boundary.inc b/laya-cpp/tests/lang_boundary.inc
new file mode 100644
index 00000000..07ff31e0
--- /dev/null
+++ b/laya-cpp/tests/lang_boundary.inc
@@ -0,0 +1,25 @@
+ {"alors aber alors aber", "latin", "fr", false, 0.0, 0.0},
+ {"alors algo alors algo", "latin", "fr", false, 0.0, 0.0},
+ {"alors agora alors agora", "latin", "fr", false, 0.0, 0.0},
+ {"alors abbiamo alors abbiamo", "latin", "fr", false, 0.0, 0.0},
+ {"alors aan alors aan", "latin", "fr", false, 0.0, 0.0},
+ {"alors appen alors appen", "latin", "fr", false, 0.0, 0.0},
+ {"alors aceasta alors aceasta", "latin", "fr", false, 0.0, 0.0},
+ {"alors abar alors abar", "latin", "fr", false, 0.0, 0.0},
+ {"alors amma alors amma", "latin", "fr", false, 0.0, 0.0},
+ {"aber algo aber algo", "latin", "de", false, 0.0, 0.0},
+ {"the invoice and we will have it café xxxxxxxxxxxxx", "latin", "en", true, 0.02, 0.0},
+ {"the invoice and we will have it café xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx", "latin", "en", true, 0.01, 0.0},
+ {"the cat and the dog are here with us all day é and so on and so forth", "latin", "en", true, 0.0145, 0.0},
+ {"abonnemanget kan inte", "latin", "sv", false, 0.0, 0.0},
+ {"abonnemanget kan inte nu", "latin", "", true, 0.0, 0.0},
+ {"aterbetalning abonnemanget jag", "latin", "sv", false, 0.0, 0.0},
+ {"ʯʯʯ", "latin", "", true, 0.0, 0.0},
+ {"ʰʰʰ hello", "latin", "", true, 0.0, 0.375},
+ {"aaaaaaaa жж", "cyrillic", "", false, 0.0, 0.2},
+ {"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa жжжжжжжжжж", "cyrillic", "", false, 0.0, 0.1},
+ {"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa жжжжжжжжж", "latin", "", true, 0.0, 0.09},
+ {"Ich kann mich nicht in mein Konto einloggen und das Passwort funktioniert nicht жжжжжжжжжжжжжжжжж a", "cyrillic", "", false, 0.0, 0.2},
+ {"Ich kann mich nicht in mein Konto einloggen und das Passwort funktioniert nicht жжжжжжжж aaaaa", "latin", "de", false, 0.0, 0.1},
+ {"veux deux were doesnt pas é xxxxxxxxxxxxxxxxxxxxxx", "latin", "fr", false, 0.02, 0.0},
+ {"be dans comment ma haven his é xxxxxxxxxxxxxxxxxxx", "latin", "fr", false, 0.02, 0.0},
diff --git a/laya-cpp/tests/lang_test.cpp b/laya-cpp/tests/lang_test.cpp
index 9842dcd6..da0937f8 100644
--- a/laya-cpp/tests/lang_test.cpp
+++ b/laya-cpp/tests/lang_test.cpp
@@ -123,3 +123,21 @@ TEST(Lang, InvalidUtf8MatchesPython) {
EXPECT_EQ(lg::StateText(pv::Value::String(bytes)), text.value(i).as_string()) << "row " << i;
}
}
+
+// Boundary cases (ties, exact thresholds, 3 vs 4 words, the Latin range edge) with expectations
+// recorded from laya.lang by laya-e2e/cpp-lane/fuzz-c1/gen_boundary.py. They are source text, not a
+// golden, so they run in every build and pin the mutants the parity rows alone do not.
+TEST(Lang, BoundaryCasesMatchPython) {
+ struct Row { const char* text; const char* script; const char* language; bool english; double rate; double nl; };
+ static const Row rows[] = {
+#include "lang_boundary.inc"
+ };
+ for (const Row& r : rows) {
+ lg::Analysis a = lg::Analyze(std::string_view(r.text));
+ EXPECT_EQ(a.script, r.script) << r.text;
+ EXPECT_EQ(a.language, r.language) << r.text;
+ EXPECT_EQ(a.english, r.english) << r.text;
+ EXPECT_EQ(a.diacritic_rate, r.rate) << r.text;
+ EXPECT_EQ(a.non_latin_fraction, r.nl) << r.text;
+ }
+}