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(java): follow #1315's English words in the two router assertions main is red on

Aashishefcf21e278b2
diff --git a/laya-java/laya-java/src/test/java/com/convaiinnovations/laya/RouterLifecycleTest.java b/laya-java/laya-java/src/test/java/com/convaiinnovations/laya/RouterLifecycleTest.java
index 2189ec1e..87269ab1 100644
--- a/laya-java/laya-java/src/test/java/com/convaiinnovations/laya/RouterLifecycleTest.java
+++ b/laya-java/laya-java/src/test/java/com/convaiinnovations/laya/RouterLifecycleTest.java
@@ -768,11 +768,11 @@ final class RouterLifecycleTest {
assertThrows(IllegalStateException.class, () -> router.load("english"));
assertThrows(IllegalStateException.class, () -> router.lease("english"));
router.close(); // idempotent
- // and routing a closed router is still harmless, because it touches nothing
- // Undecided, not identified English (analyse gives language=null), so it takes the
- // default -- which is multilingual. The point here is that routing still answers
- // after close, not which checkpoint it picks.
- assertEquals(Checkpoint.MULTILINGUAL,
+ // and routing a closed router is still harmless, because it touches nothing.
+ // Identified English, not undecided: `here` and `now` are English function words, so the
+ // reference routes this state to the English checkpoint instead of the default. The point
+ // here is that routing still answers after close, not which checkpoint it picks.
+ assertEquals(Checkpoint.ENGLISH,
router.route("plain english text here now").model());
}
diff --git a/laya-java/laya-java/src/test/java/com/convaiinnovations/laya/RouterTest.java b/laya-java/laya-java/src/test/java/com/convaiinnovations/laya/RouterTest.java
index 19405371..19bdb01a 100644
--- a/laya-java/laya-java/src/test/java/com/convaiinnovations/laya/RouterTest.java
+++ b/laya-java/laya-java/src/test/java/com/convaiinnovations/laya/RouterTest.java
@@ -517,9 +517,18 @@ class RouterTest {
assertTrue(decided.reason().startsWith("non-Latin script"), decided.reason());
assertTrue(decided.detection() != null, "detection ran, so it is reported");
+ // `C.UTF-8` names a locale, not a language, so the hint abstains and detection decides.
+ // Detection's answer for this state is `English Latin text` -- `here` and `now` are English
+ // function words now -- which is the same pair the `lang-agnostic-C-falls-through` row of
+ // router.json records. The reason is compared exactly, not by a "Latin script" prefix: that
+ // prefix was also the reason detection gives when it cannot identify a language, so it
+ // showed the hint stayed out only as long as plain English stayed undecided.
Router agnostic = Router.builder().langGuess(Router.LanguageHint.of("C.UTF-8")).build();
- assertTrue(agnostic.route("plain english words here now").reason()
- .startsWith("Latin script"), "a code naming no language must not decide");
+ Router.RouteDecision fallback = agnostic.route("plain english words here now");
+ assertEquals("English Latin text", fallback.reason(),
+ "a code naming no language must not decide; detection's reason shows who did");
+ assertEquals(Router.Checkpoint.ENGLISH, fallback.model());
+ assertTrue(fallback.detection() != null, "detection ran, so it is reported");
}
@Test