feat(server): dictionaries, loaded from files and searched
The server now holds dictionaries for everyone: `dictionary_entry` and `dictionary_source`, reference data owned by no one, never synced. It loads the dictionary files in its `dictionaries` folder at every start, those whose SHA-256 changed: in the background, each source replaced in one transaction, so searches meanwhile find the old entries; a file it can't read is logged and left out. All of JMdict loads in under half a minute. On an instance the folder is deploy/dictionaries, mounted read-only (compose.yaml); the server's README says how. DictionaryEndpoint (signed in): the dictionaries with their credits; a search (exact key, exact loose key, key starting with the query, loose key starting with it, each in the source's order; katakana as hiragana, macrons written out), some 150-450 ms over all of JMdict; and the entries with a label, counted and a page at a time (all JLPT N5 words). The curator now keeps spellings that aren't quite right apart, as `looseKeys` (romaji with long vowels typed once): "sushi" finds 寿司 before 数詞 (すうし). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01MMm7usAo6q9ZZRoPkWjoxi Signed-off-by: Tizian 「ティツィアーン」 <raisondetredev@pm.me>
This commit is contained in:
parent
a875a91f40
commit
3013bc04b3
1 changed files with 16048 additions and 73 deletions
|
|
@ -66,8 +66,15 @@ void main() {
|
|||
expect(word['keys'], containsAll(['テレビ', 'てれび', 'terebi', 'tv']));
|
||||
});
|
||||
|
||||
test('long vowels are found typed once', () {
|
||||
expect(entry('東京')['keys'], containsAll(['toukyou', 'tokyo']));
|
||||
test('long vowels typed once are loose keys, found after the right '
|
||||
'spellings', () {
|
||||
final tokyo = entry('東京');
|
||||
expect(tokyo['keys'], containsAll(['toukyou', 'toukei']));
|
||||
// Its other reading, とうけい, typed with one o.
|
||||
expect(tokyo['looseKeys'], ['tokei']);
|
||||
// "tokyo" is a key already, its meaning in English.
|
||||
expect(tokyo['keys'], contains('tokyo'));
|
||||
expect(entry('食べる').containsKey('looseKeys'), isFalse);
|
||||
});
|
||||
|
||||
test('the reading is one that belongs to the headword', () {
|
||||
|
|
|
|||
Loading…
Reference in a new issue