--- license: cc-by-sa-4.0 task_categories: - text-retrieval - text-generation language: - de tags: - wiktionary - dictionary - german - linguistics - morphology - semantics - normalized size_categories: - 100K get database async { if (_database != null) return _database!; _database = await initDB(); return _database!; } Future initDB() async { final dir = await getApplicationDocumentsDirectory(); final dbPath = join(dir.path, 'de_wiktionary.db'); // Download and decompress on first run if (!await File(dbPath).exists()) { final url = 'https://huggingface.co/datasets/cstr/de-wiktionary-sqlite-normalized/resolve/main/de_wiktionary_normalized.db'; print('Downloading database...'); final response = await http.get(Uri.parse(url)); final gzPath = join(dir.path, 'de_wiktionary.db.gz'); await File(gzPath).writeAsBytes(response.bodyBytes); print('Decompressing...'); final gzFile = File(gzPath); final dbFile = File(dbPath); // Decompress gzip final bytes = gzFile.readAsBytesSync(); final archive = GZipDecoder().decodeBytes(bytes); await dbFile.writeAsBytes(archive); // Clean up await gzFile.delete(); print('Database ready!'); } return await openDatabase(dbPath, version: 1); } // Get word forms with grammatical tags Future>> getWordForms(String word) async { final db = await database; return await db.rawQuery(''' SELECT f.form_text, GROUP_CONCAT(t.tag, ', ') as tags FROM entries e JOIN forms f ON e.id = f.entry_id LEFT JOIN form_tags ft ON f.id = ft.form_id LEFT JOIN tags t ON ft.tag_id = t.id WHERE e.word = ? AND e.lang = 'Deutsch' GROUP BY f.id ''', [word]); } // Get synonyms Future> getSynonyms(String word) async { final db = await database; final results = await db.rawQuery(''' SELECT s.synonym_word FROM entries e JOIN synonyms s ON e.id = s.entry_id WHERE e.word = ? AND e.lang = 'Deutsch' ''', [word]); return results.map((r) => r['synonym_word'] as String).toList(); } // Get IPA pronunciation Future> getIPA(String word) async { final db = await database; final results = await db.rawQuery(''' SELECT s.ipa FROM entries e JOIN sounds s ON e.id = s.entry_id WHERE e.word = ? AND s.ipa IS NOT NULL ''', [word]); return results.map((r) => r['ipa'] as String).toList(); } // Get definitions Future> getDefinitions(String word) async { final db = await database; final results = await db.rawQuery(''' SELECT g.gloss_text FROM entries e JOIN senses se ON e.id = se.entry_id JOIN glosses g ON se.id = g.sense_id WHERE e.word = ? AND e.lang = 'Deutsch' ''', [word]); return results.map((r) => r['gloss_text'] as String).toList(); } // Autocomplete search Future> searchWords(String prefix) async { final db = await database; final results = await db.rawQuery(''' SELECT DISTINCT word FROM entries WHERE word LIKE ? AND lang = 'Deutsch' ORDER BY word LIMIT 20 ''', ['$prefix%']); return results.map((r) => r['word'] as String).toList(); } } ``` ## 🔍 Example Queries ### Get complete grammatical analysis ```sql SELECT e.word, f.form_text, GROUP_CONCAT(DISTINCT t.tag) as grammatical_tags, s.ipa FROM entries e JOIN forms f ON e.id = f.entry_id LEFT JOIN form_tags ft ON f.id = ft.form_id LEFT JOIN tags t ON ft.tag_id = t.id LEFT JOIN sounds s ON e.id = s.entry_id WHERE e.word = 'lieben' GROUP BY f.id; ``` ### Find words by grammatical features ```sql SELECT DISTINCT e.word FROM entries e JOIN forms f ON e.id = f.entry_id JOIN form_tags ft ON f.id = ft.form_id JOIN tags t ON ft.tag_id = t.id WHERE t.tag = 'irregular' AND e.pos = 'verb' LIMIT 100; ``` ### Get words with semantic relationships ```sql SELECT e.word, s.synonym_word, a.antonym_word FROM entries e LEFT JOIN synonyms s ON e.id = s.entry_id LEFT JOIN antonyms a ON e.id = a.entry_id WHERE e.word = 'gut'; ``` ## 📱 Platform Support - **iOS**: ✅ Full support via sqflite - **Android**: ✅ Full support via sqflite - **Windows**: ✅ Via sqflite_common_ffi - **macOS**: ✅ Via sqflite_common_ffi - **Linux**: ✅ Via sqflite_common_ffi - **Web**: ⚠️ Via sql.js (WASM) ## 🚀 Performance Typical query times (modern hardware): - Word lookup: < 1ms - Get all forms: < 5ms - Complex multi-table joins: < 20ms - Autocomplete search: < 10ms ## 🔗 Source Original data: [cstr/de-wiktionary-extracted](https://huggingface.co/datasets/cstr/de-wiktionary-extracted) ## 📜 License CC-BY-SA 4.0 (same as source) ## 🛠️ Technical Details - **SQLite Version**: 3.x compatible - **Encoding**: UTF-8 - **Foreign Keys**: Enabled - **Indexes**: 38 indexes for optimal performance - **Normalization**: 3NF with deduplicated tags/topics/categories ## 📊 Schema Overview ``` entries (970K rows) ├── senses (3.1M) → glosses (3.1M) ├── forms (6.1M) → form_tags (26M) → tags (185) ├── sounds (2.3M) → sound_tags ├── translations (1.1M) → translation_tags ├── synonyms (162K) → synonym_tags ├── antonyms └── hyphenations (954K) ``` ## 🤝 Contributing Found an issue? Please report it on the source dataset repository.