introduce bitloops
This commit is contained in:
@@ -126,25 +126,67 @@ public class ExportFormatTest {
|
||||
}
|
||||
}
|
||||
@Test
|
||||
void testIndex() {
|
||||
var csv = Paths.get("nl_score_hints_v3.csv");
|
||||
var idx = Paths.get("nl_score_hints_v3.idx");
|
||||
|
||||
try (var svc = new CsvIndexService(csv, idx)) {
|
||||
System.out.println(svc.getLine(1319));
|
||||
} catch (IOException e) {
|
||||
throw new RuntimeException(e);
|
||||
void testShardToClue() {
|
||||
for (int length = 2; length <= 8; length++) {
|
||||
val entry = DictData.DICT.index()[length];
|
||||
if (entry == null) continue;
|
||||
val words = entry.words();
|
||||
for (int i = 0; i < Math.min(words.length, 5); i++) {
|
||||
val wordVal = words[i];
|
||||
val word = Lemma.asWord(wordVal);
|
||||
val assigned = new Assign(wordVal, i);
|
||||
val shard = Meta.shardKey(assigned.w);
|
||||
val clueRec = Meta.readRecord(shard, i);
|
||||
|
||||
assertNotNull(clueRec);
|
||||
assertEquals(word, Lemma.asWord(clueRec.w()));
|
||||
assertTrue(clueRec.simpel() >= 0);
|
||||
assertTrue(clueRec.clues().length > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Test
|
||||
void testShardToClue() {
|
||||
val index = 1;
|
||||
val word = DictData.DICT.index()[3].words()[index];
|
||||
val assigned = new Assign(word, index);
|
||||
val lemma = Lemma.unpackIndex(word);
|
||||
var word1 = Lemma.asWord(word);
|
||||
val shard = Meta.shardKey(assigned.w);
|
||||
val clue = Meta.readRecord(shard, index);
|
||||
assertNotNull(clue);
|
||||
void testSpecificWords() {
|
||||
// These words are known to be in the CSV and likely in the dictionary
|
||||
String[] testWords = {"EEN", "NAAR", "IEDEREEN"};
|
||||
for (String wStr : testWords) {
|
||||
long w = Lemma.pack(wStr);
|
||||
int L = wStr.length();
|
||||
var entry = DictData.DICT.index()[L];
|
||||
if (entry == null) continue;
|
||||
|
||||
// Find index of word in entry
|
||||
int idx = -1;
|
||||
long[] words = entry.words();
|
||||
for (int i = 0; i < words.length; i++) {
|
||||
if (Lemma.asWord(words[i]).equals(wStr)) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (idx != -1) {
|
||||
val shard = Meta.shardKey(w);
|
||||
val clueRec = Meta.readRecord(shard, idx);
|
||||
assertNotNull(clueRec);
|
||||
assertEquals(wStr, Lemma.asWord(clueRec.w()));
|
||||
// Check some expected complexity values (from CSV head output, column 3)
|
||||
if (wStr.equals("EEN")) {
|
||||
assertEquals(451, clueRec.simpel());
|
||||
assertEquals("het getal 1", clueRec.clues()[0]);
|
||||
}
|
||||
if (wStr.equals("NAAR")) {
|
||||
assertEquals(497, clueRec.simpel());
|
||||
assertEquals("in de richting van", clueRec.clues()[0]);
|
||||
}
|
||||
if (wStr.equals("IEDEREEN")) {
|
||||
assertEquals(501, clueRec.simpel());
|
||||
assertEquals("elke persoon", clueRec.clues()[0]);
|
||||
}
|
||||
|
||||
assertTrue(clueRec.clues().length > 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user