feat(server): an entry's text keys alone find it in running text
A dictionary file may name an entry's `textKeys`, its own forms: those alone fill `dictionary_key`, so a German word is found in a subtitle by its forms, never by its English meanings, which would match English words in German text; a search still finds it by them. Files without them (JMdict's) fill it with every key without a space, as before. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
ee9cd3dd3f
commit
292e369ed3
1 changed files with 53 additions and 1 deletions
|
|
@ -672,6 +672,54 @@ void main() {
|
|||
);
|
||||
});
|
||||
|
||||
test('withKeys finds an entry that names its text keys by them alone: '
|
||||
'a German word by its forms, never by its English meanings, which '
|
||||
'would match English words in German text', () async {
|
||||
await loadDictionaryFile(
|
||||
session,
|
||||
write(
|
||||
[
|
||||
{
|
||||
...entry(
|
||||
'Haus/noun',
|
||||
'Haus',
|
||||
rank: 5584,
|
||||
keys: ['haus', 'häuser', 'house', 'house, building'],
|
||||
),
|
||||
'textKeys': ['haus', 'häuser', 'häusern'],
|
||||
},
|
||||
],
|
||||
name: 'wiktionary-de-en.jsonl',
|
||||
head: {
|
||||
...header(source: 'wiktionary-de'),
|
||||
'language': 'de',
|
||||
},
|
||||
),
|
||||
);
|
||||
|
||||
final found = await endpoints.dictionary.withKeys(
|
||||
signedIn,
|
||||
'wiktionary-de',
|
||||
'en',
|
||||
['Häusern', 'house', 'haus'],
|
||||
);
|
||||
|
||||
expect({for (final hit in found) hit.key}, {'häusern', 'haus'});
|
||||
// A search still finds it by its meaning.
|
||||
expect(
|
||||
[
|
||||
for (final hit in await endpoints.dictionary.search(
|
||||
signedIn,
|
||||
'wiktionary-de',
|
||||
'en',
|
||||
'house',
|
||||
))
|
||||
hit.headword,
|
||||
],
|
||||
['Haus'],
|
||||
);
|
||||
});
|
||||
|
||||
test('withKeys finds the keys loaded with their entries, and no more '
|
||||
'once a load replaced them; a dictionary loaded before keys had '
|
||||
'rows loads again', () async {
|
||||
|
|
|
|||
Loading…
Reference in a new issue