我不知道这是否会有所帮助,但参考您的陈述“如果有一些 java 代码显示如何从二进制字典中读取单词会很棒”,也许this 会是一个好的开始。 This is the GIT
它说它返回一个单词列表,但我不确定它返回的格式是什么,也不知道它的外观。此代码 sn-p 来自此页面的第 240 行。
> * Returns the list of cached files for a specific locale, one for each category.
> *
> * This will return exactly one file for each word list category that matches
> * the passed locale. If several files match the locale for any given category,
> * this returns the file with the closest match to the locale. For example, if
> * the passed word list is en_US, and for a category we have an en and an en_US
> * word list available, we'll return only the en_US one.
> * Thus, the list will contain as many files as there are categories.
> *
> * @param locale the locale to find the dictionary files for, as a string.
> * @param context the context on which to open the files upon.
> * @return an array of binary dictionary files, which may be empty but may not be null.
> */
> private static File[] getCachedWordLists(final String locale,
> final Context context) {
> final File[] directoryList = getCachedDirectoryList(context);
> if (null == directoryList) return EMPTY_FILE_ARRAY;
> final HashMap<String, FileAndMatchLevel> cacheFiles =
> new HashMap<String, FileAndMatchLevel>();
> for (File directory : directoryList) {
> if (!directory.isDirectory()) continue;
> final String dirLocale = getWordListIdFromFileName(directory.getName());
> final int matchLevel = LocaleUtils.getMatchLevel(dirLocale, locale);
> if (LocaleUtils.isMatch(matchLevel)) {
> final File[] wordLists = directory.listFiles();
> if (null != wordLists) {
> for (File wordList : wordLists) {
> final String category = getCategoryFromFileName(wordList.getName());
> final FileAndMatchLevel currentBestMatch = cacheFiles.get(category);
> if (null == currentBestMatch || currentBestMatch.mMatchLevel < matchLevel) {
> cacheFiles.put(category, new FileAndMatchLevel(wordList, matchLevel));
> }
> }
> }
> }
> }
> if (cacheFiles.isEmpty()) return EMPTY_FILE_ARRAY;
> final File[] result = new File[cacheFiles.size()];
> int index = 0;
> for (final FileAndMatchLevel entry : cacheFiles.values()) {
> result[index++] = entry.mFile;
> }
> return result;
> }
至于如何将 .dict 二进制文件转换为人类可读的形式,我知道这不是您要专门寻找的,但也许它会给您一个良好的开端。看起来你可能需要自己写一些东西来进行转换,就像他们在Here 所做的那样。他们编写了这个脚本来处理这个过程。
"Lingoes Converter 是一个用 PHP 编写的脚本,可以转换
将 Lingoes 的 .LD2/.LDX 字典转换为人类可读的文本文件。这
脚本是基于朱小云分析(lingoes-extractor)上的
LD2/LDX 字典格式。”
我希望其中的一些内容至少能给你一个开始。这是一个利基需求,肯定需要提供一个好的解决方案。希望你能解决!