# 全新的mdx/mdd词典制作工具

**URL:** <https://forum.freemdict.com/t/topic/6621>\
**Category:** 软件经验交流展望\
**Tags:** mdx工具\
**Created:** [2021 年6 月 3 日 10:04 UTC](https://forum.freemdict.com/t/topic/6621 "2021-06-03T10:04:48Z")\
**Posts on this page:** 20\
**Page:** 6

<div class="post-metadata">

**Author:** ![random](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/random/32/19006_2.png) [@random](https://forum.freemdict.com/u/random)\
**Post date:** [2021 年9 月 4 日 17:40 UTC](https://forum.freemdict.com/t/topic/6621/105 "2021-09-04T17:40:34Z")

</div>

## 可以了。不过又遇到个问题，就是生成的mdx文件不可以通过 [mdict-utils](https://www.pdawiki.com/forum/forum.php?mod=viewthread&tid=33808&highlight=util) 解压mdx到txt了。

又试了下，用wikit解压没问题。

> Try Brutal Force on Encrypted Key Blocks  
> — Elapsed time: 0.000798 seconds —  
> Traceback (most recent call last):  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 101, in **init**  
> self.\_key\_list = self.\_read\_keys()  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 350, in \_read\_keys  
> key\_block\_info\_list = self.\_decode\_key\_block\_info(key\_block\_info)  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 134, in \_decode\_key\_block\_info  
> assert(key\_block\_info\_compressed[:4] == b’\x02\x00\x00\x00’)  
> AssertionError
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):  
> File “/Users/xxxx/Library/Python/3.9/bin/mdict”, line 8, in   
> sys.exit(run())  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/ **main**.py”, line 102, in run  
> reader.unpack(args.exdir, args.mdict, split=split, convert\_chtml=args.convert\_chtml)  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/reader.py”, line 157, in unpack  
> mdx = MDX(source, encoding, substyle, passcode)  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 505, in **init**  
> MDict. **init** (self, fname, encoding, passcode)  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 104, in **init**  
> self.\_key\_list = self.\_read\_keys\_brutal()  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 382, in \_read\_keys\_brutal  
> assert key\_block\_info[:4] == b’\x02\x00\x00\x00’  
> AssertionError

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 5 日 00:31 UTC](https://forum.freemdict.com/t/topic/6621/106 "2021-09-05T00:31:03Z")

</div>

wikit dict --create TLD.mdx --output TLD.dictionary 执行到最后提示：

```auto
mac dictionary development kit is not installed, install now?

```

我已经安装了 development kit ， 放在实用工具目录下了

 ![CleanShot 2021-09-05 at 08.30.09@2x](https://forumcdn.freemdict.com/uploads/default/original/2X/1/12a491f88eb817c811edce99247ba9daed468b15.jpeg)

或者说要如何才能让wikit检测到词典套件呢？

---

<div class="post-metadata">

**Author:** ![biu](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@biu](https://forum.freemdict.com/u/biu)\
**Post date:** [2021 年9 月 5 日 01:59 UTC](https://forum.freemdict.com/t/topic/6621/107 "2021-09-05T01:59:15Z")

</div>

> [@青稚Quentin](#):
>
> wikit dict --create TLD.mdx --output TLD.dictionary 执行到最后提示：
> 
> ```auto
> mac dictionary development kit is not installed, install now?
> 
> ```
> 
> 我已经安装了 development kit ， 放在实用工具目录下了
> 
> ![CleanShot 2021-09-05 at 08.30.09@2x](https://forumcdn.freemdict.com/uploads/default/original/2X/1/12a491f88eb817c811edce99247ba9daed468b15.jpeg)
> 
> 或者说要如何才能让wikit检测到词典套件呢？

这个问题其实我也想过, 不过考虑到了如下几点, 目前不允许用户将 ddk(dictionary development kit) 安装到其他目录:

1. ddk 需要用户在苹果官网注册帐号才能下载, 对于非开发者(占大多数)而言这个过程是比较烦人的
2. 苹果自家的工具经常性的发生名称改动或者存入不同的安装包里面, 比如 ddk 在最开始位于 Auxiliary Tools for Xcode, 现在又位于 Additional Tools for Xcode 包中, 很难保证苹果不在下一个版本任性的将其放到另外一个包中.
3. 以 Xcode 12.5 的 Additional Tools for Xcode 为例, 其大小为 24M, 实际上 ddk 部分只有 1M 多.
4. 如果后续逆向出了 mac 的词典格式, wikit 自己管理的 ddk 可以直接去掉, 用户使用上是无感的.

因此, 我单独提取了 ddk, 放在[这里](https://github.com/ikey4u/macddk), 启动程序时会提示自动下载安装,  
如果你不想让它下载安装, wikit 会提示你应该把该工具安装到哪里, 你手动下载安装到指定位置然后重新使用 wikit 制作词典即可.

---

<div class="post-metadata">

**Author:** ![biu](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@biu](https://forum.freemdict.com/u/biu)\
**Post date:** [2021 年9 月 5 日 02:03 UTC](https://forum.freemdict.com/t/topic/6621/108 "2021-09-05T02:03:16Z")

</div>

> [@random](#):
>
> Try Brutal Force on Encrypted Key Blocks  
> — Elapsed time: 0.000798 seconds —  
> Traceback (most recent call last):  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 101, in **init**  
> self.\_key\_list = self.\_read\_keys()  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 350, in \_read\_keys  
> key\_block\_info\_list = self.\_decode\_key\_block\_info(key\_block\_info)  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 134, in \_decode\_key\_block\_info  
> assert(key\_block\_info\_compressed[:4] == b’\x02\x00\x00\x00’)  
> AssertionError
> 
> During handling of the above exception, another exception occurred:
> 
> Traceback (most recent call last):  
> File “/Users/xxxx/Library/Python/3.9/bin/mdict”, line 8, in  
> sys.exit(run())  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/ **main**.py”, line 102, in run  
> reader.unpack(args.exdir, args.mdict, split=split, convert\_chtml=args.convert\_chtml)  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/reader.py”, line 157, in unpack  
> mdx = MDX(source, encoding, substyle, passcode)  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 505, in **init**  
> MDict. **init** (self, fname, encoding, passcode)  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 104, in **init**  
> self.\_key\_list = self.\_read\_keys\_brutal()  
> File “/Users/xxxx/Library/Python/3.9/lib/python/site-packages/mdict\_utils/base/readmdict.py”, line 382, in \_read\_keys\_brutal  
> assert key\_block\_info[:4] == b’\x02\x00\x00\x00’  
> AssertionError

这个问题看着像是 mdict-utils 检测压缩方式不为 2(zlib压缩), 现在 wikit 生成的 mdx 默认是不压缩的(为 0), 它这里断言失败了. 不过目前没有更多精力去兼容其他工具了.

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 5 日 11:48 UTC](https://forum.freemdict.com/t/topic/6621/109 "2021-09-05T11:48:24Z")

</div>

😄 想问问作者，对于复杂的mdx词典转换怎么处理， 比如在用 PYGLOSSARY 转换成功后，处理词典xml文件的问题 ：链接跳转，发音、图片等， 还有转换语音文件 ，有些词典的发音文件是spx格式，需要转换成wav格式或者mp3 ，完成后再进行编译词典。 wikit 这一部分是怎么处理的呢？

---

<div class="post-metadata">

**Author:** ![biu](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@biu](https://forum.freemdict.com/u/biu)\
**Post date:** [2021 年9 月 5 日 14:56 UTC](https://forum.freemdict.com/t/topic/6621/110 "2021-09-05T14:56:13Z")

</div>

> [@青稚Quentin](#):
>
> 链接跳转，发音、图片等， 还有转换语音文件 ，有些词典的发音文件是spx格式，需要转换成wav格式或者mp3 ，完成后再进行编译词典。

这些属于完善功能的部分, 目前暂无这方面的计划.

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 6 日 00:10 UTC](https://forum.freemdict.com/t/topic/6621/111 "2021-09-06T00:10:33Z")

</div>

目前制作mac 词典的话 可以添加有发音的词典吗？

---

<div class="post-metadata">

**Author:** ![endnote](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/e/9de0a6/32.png) [@endnote](https://forum.freemdict.com/u/endnote)\
**Post date:** [2021 年9 月 6 日 05:26 UTC](https://forum.freemdict.com/t/topic/6621/112 "2021-09-06T05:26:02Z")

</div>

> [@biu](#):
>
> mdict-utils 检测压缩方式不为 2(zlib压缩)

这就是没有统一 specifications 的弊端。  
虽然可以说mdx2.0是个基本上已经开源的格式，看上去实现不难。但大大小小的坑是真的多，导致不同程序之间的各类兼容性问题。

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 8 日 12:56 UTC](https://forum.freemdict.com/t/topic/6621/113 "2021-09-08T12:56:00Z")

</div>

在转换词典有个报错 ，词典是简明Bing

```auto
Error: [src/main.rs].[204]: Failed to create mac dictionary

Caused by:
    0: [src/mac.rs].[180]: cannot run command '/Users/vivian/Library/Application Support/wikit/macddk/bin/build_dict.sh' 'concisebing' '/Users/vivian/Downloads/dict/wikit/concise_bing.xml' '/Users/vivian/Downloads/dict/wikit/concise_bing.css' '/Users/vivian/Downloads/dict/wikit/concise_bing.plist'
    1: [src/util.rs].[95]: /Users/vivian/Downloads/dict/wikit/concise_bing.xml:6: parser error : attributes construct error
                        <link href="concise_bing.css" rel="stylesheet" type="text/css"
                                                                                      ^
       /Users/vivian/Downloads/dict/wikit/concise_bing.xml:6: parser error : Couldn't find end of Start Tag link
                        <link href="concise_bing.css" rel="stylesheet" type="text/css"
                                                                                      ^
       /Users/vivian/Downloads/dict/wikit/concise_bing.xml : failed to parse
       Error.

```

---

<div class="post-metadata">

**Author:** ![last\_idol](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/last_idol/32/2205_2.png) [@last\_idol](https://forum.freemdict.com/u/last_idol)\
**Post date:** [2021 年9 月 8 日 13:41 UTC](https://forum.freemdict.com/t/topic/6621/114 "2021-09-08T13:41:12Z")

</div>

作者前面有说。

> [@biu](#):
>
> 因为 mac 词典开发套件使用的是 XHTML, 也就是更严格的 HTML 标准, 这里的问题是 link 标签, 在 html 中 link 标签是可以不封闭的, 也就是说下面的写法是正确的
> 
> ```auto
> <link rel="stylesheet" href="rhwdae.css">
> 
> ```
> 
> 但是 XHTML 要求任何标签都必须是封闭的, 因此要写成
> 
> `<link rel="stylesheet" href="rhwdae.css" />`

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 8 日 22:08 UTC](https://forum.freemdict.com/t/topic/6621/115 "2021-09-08T22:08:26Z")

</div>

这个我已经改好标签了， 就是不知道如何进行下一步

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 10 日 08:42 UTC](https://forum.freemdict.com/t/topic/6621/116 "2021-09-10T08:42:05Z")

</div>

作者，请问我修改了xml标签后，如何对词典进行下一步呢？

---

<div class="post-metadata">

**Author:** ![biu](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@biu](https://forum.freemdict.com/u/biu)\
**Post date:** [2021 年9 月 10 日 14:09 UTC](https://forum.freemdict.com/t/topic/6621/117 "2021-09-10T14:09:27Z")

</div>

> [@青稚Quentin](#):
>
> 目前制作mac 词典的话 可以添加有发音的词典吗？

我看 mac 词典是支持发音的, 但是暂时没有支持计划.

---

<div class="post-metadata">

**Author:** ![biu](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@biu](https://forum.freemdict.com/u/biu)\
**Post date:** [2021 年9 月 10 日 14:11 UTC](https://forum.freemdict.com/t/topic/6621/118 "2021-09-10T14:11:22Z")

</div>

> [@青稚Quentin](#):
>
> 这个我已经改好标签了， 就是不知道如何进行下一步

MDX 单独发我一下, 我看一下是什么问题.

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 11 日 01:27 UTC](https://forum.freemdict.com/t/topic/6621/119 "2021-09-11T01:27:10Z")

</div>

这个报错 是因为生成的xml 错误

```auto
<link href="concise_bing.css" rel="stylesheet" type="text/css"/ />

```

我手动修改了xml 文件

```auto
<link href="concise_bing.css" rel="stylesheet" type="text/css" />

```

不清楚如何进行下一步编译词典， 用 pyglossary 转换词典的时候是输入 `make`

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 11 日 01:48 UTC](https://forum.freemdict.com/t/topic/6621/120 "2021-09-11T01:48:32Z")

</div>

邮件已发送 ！！

---

<div class="post-metadata">

**Author:** ![biu](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@biu](https://forum.freemdict.com/u/biu)\
**Post date:** [2021 年9 月 11 日 03:16 UTC](https://forum.freemdict.com/t/topic/6621/121 "2021-09-11T03:16:15Z")

</div>

> [@青稚Quentin](#):
>
> 这个报错 是因为生成的xml 错误
> 
> ```auto
> <link href="concise_bing.css" rel="stylesheet" type="text/css"/ />
> 
> ```
> 
> 我手动修改了xml 文件
> 
> ```auto
> <link href="concise_bing.css" rel="stylesheet" type="text/css" />
> 
> ```

更改一下制作 mac 词典的逻辑, 在转换到 xhtml 这一步出错的时候, 用户可以修改中间文件, 然后再执行转换, 实现之后我发个版本.

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 11 日 05:35 UTC](https://forum.freemdict.com/t/topic/6621/122 "2021-09-11T05:35:51Z")

</div>

可以 坐等 😄

---

<div class="post-metadata">

**Author:** ![biu](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/b/b782af/32.png) [@biu](https://forum.freemdict.com/u/biu)\
**Post date:** [2021 年9 月 11 日 12:30 UTC](https://forum.freemdict.com/t/topic/6621/123 "2021-09-11T12:30:25Z")

</div>

> [@青稚Quentin](#):
>
> 可以 坐等 😄

必应这本词典太大了, mac ddk 已经跑了一个小时了, 还没完事儿…

---

<div class="post-metadata">

**Author:** ![青稚Quentin](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E9%9D%92%E7%A8%9Aquentin/32/14413_2.png) [@青稚Quentin](https://forum.freemdict.com/u/%E9%9D%92%E7%A8%9AQuentin)\
**Post date:** [2021 年9 月 11 日 21:56 UTC](https://forum.freemdict.com/t/topic/6621/124 "2021-09-11T21:56:52Z")

</div>

400多万词条， 简明英汉的增强版 我的最爱 😀 😀

[上一页](https://forum.freemdict.com/t/topic/6621.md?page=5)

[下一页](https://forum.freemdict.com/t/topic/6621.md?page=7)
