mirror of
https://github.com/MarginaliaSearch/MarginaliaSearch.git
synced 2025-02-24 05:18:58 +00:00
(qs, WIP) Fix output determinism, fix tests
This commit is contained in:
parent
f82ebd7716
commit
4cc11e183c
@ -370,7 +370,9 @@ public class QWordGraph implements Iterable<QWord> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var branches = pathsByCommonWord.entrySet().stream().map(e -> {
|
var branches = pathsByCommonWord.entrySet().stream()
|
||||||
|
.sorted(Map.Entry.comparingByKey(reachability.topologicalComparator()))
|
||||||
|
.map(e -> {
|
||||||
String commonWord = e.getKey().word();
|
String commonWord = e.getKey().word();
|
||||||
String branchPart = new WordPaths(e.getValue()).render(reachability);
|
String branchPart = new WordPaths(e.getValue()).render(reachability);
|
||||||
return STR."\{commonWord} \{branchPart}";
|
return STR."\{commonWord} \{branchPart}";
|
||||||
@ -382,7 +384,7 @@ public class QWordGraph implements Iterable<QWord> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Remove any double spaces that may have been introduced
|
// Remove any double spaces that may have been introduced
|
||||||
return concat.toString().replaceAll("\\s+", " ");
|
return concat.toString().replaceAll("\\s+", " ").trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@ -99,8 +99,9 @@ class QWordGraphTest {
|
|||||||
QWordGraph graph = new QWordGraph("a", "b", "c");
|
QWordGraph graph = new QWordGraph("a", "b", "c");
|
||||||
graph.addVariant(graph.node("b"), "d");
|
graph.addVariant(graph.node("b"), "d");
|
||||||
|
|
||||||
assertEquals(" ^ a(b|d)c $ ", graph.compileToQuery());
|
assertEquals("a c ( b | d )", graph.compileToQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
void testCompile2() {
|
void testCompile2() {
|
||||||
// Construct a graph like
|
// Construct a graph like
|
||||||
@ -108,7 +109,7 @@ class QWordGraphTest {
|
|||||||
// ^ - a - b - c - $
|
// ^ - a - b - c - $
|
||||||
QWordGraph graph = new QWordGraph("a", "b", "c");
|
QWordGraph graph = new QWordGraph("a", "b", "c");
|
||||||
|
|
||||||
assertEquals(" ^ abc $ ", graph.compileToQuery());
|
assertEquals("a b c", graph.compileToQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -119,7 +120,7 @@ class QWordGraphTest {
|
|||||||
// \- d -/
|
// \- d -/
|
||||||
QWordGraph graph = new QWordGraph("a", "b", "c");
|
QWordGraph graph = new QWordGraph("a", "b", "c");
|
||||||
graph.addVariant(graph.node("a"), "d");
|
graph.addVariant(graph.node("a"), "d");
|
||||||
assertEquals(" ^ (a|d)bc $ ", graph.compileToQuery());
|
assertEquals("b c ( a | d )", graph.compileToQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -130,7 +131,7 @@ class QWordGraphTest {
|
|||||||
// \- d -/
|
// \- d -/
|
||||||
QWordGraph graph = new QWordGraph("a", "b", "c");
|
QWordGraph graph = new QWordGraph("a", "b", "c");
|
||||||
graph.addVariant(graph.node("c"), "d");
|
graph.addVariant(graph.node("c"), "d");
|
||||||
assertEquals(" ^ ab(c|d) $ ", graph.compileToQuery());
|
assertEquals("a b ( c | d )", graph.compileToQuery());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
@ -143,6 +144,6 @@ class QWordGraphTest {
|
|||||||
QWordGraph graph = new QWordGraph("a", "b", "c");
|
QWordGraph graph = new QWordGraph("a", "b", "c");
|
||||||
graph.addVariant(graph.node("c"), "d");
|
graph.addVariant(graph.node("c"), "d");
|
||||||
graph.addVariant(graph.node("b"), "e");
|
graph.addVariant(graph.node("b"), "e");
|
||||||
assertEquals(" ^ a(b|e)(c|d) $ ", graph.compileToQuery());
|
assertEquals("a ( b ( c | d ) | c e )", graph.compileToQuery());
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue
Block a user