# 日文构词法文件hunspell\_ja\_JP的修复以及功能扩展

**URL:** <https://forum.freemdict.com/t/topic/44701>\
**Category:** GoldenDict-ng\
**Tags:** hunspell, 日语\
**Created:** [2026 年7 月 29 日 17:38 UTC](https://forum.freemdict.com/t/topic/44701 "2026-07-29T17:38:54Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

作者： ![yx\_wh](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/yx_wh/32/77200_2.png) [@yx\_wh](https://forum.freemdict.com/u/yx_wh)\
发布日期： [2026 年7 月 29 日 17:38 UTC](https://forum.freemdict.com/t/topic/44701/1 "2026-07-29T17:38:54Z")

</div>

2026年9月25日更新：  
蹬腾讯codebuddy里面的限时免费🆓浑元4的时候，AI告诉我原来hunspell支持类似  
`引きこもる/5A5I5T5E5OBDUYUBubKN st:引き籠もる`  
这样的写法直接做到：  
`引きこもらない → 引きこもる → 引き籠もる`  
无需两次调用 Hunspell，我之前把 ja\_JP.dic 写成这样：

```auto
ひきこもる/5A5I5T5E5OBDUYUBubKN
引きこもる/5A5I5T5E5OBDUYUBubKN
引きこもる st:引き籠もる

```

需要两轮调用。  
故修改之。

2026年9月13日更新：  
mumu的《词悦》支持两步查询啦！把hunspell\_ja\_JP的混书（mazegaki）部分做了相应的修改。

> <https://github.com/mumu-lhl/Ciyue/issues/729>
>
> \# 关于《词悦》的 Hunspell 的功能建议
> 
> \---
> 
> \## 1. 显示所有的 \`st:\` 结果
> 
> 日文的混书（混ぜ書き、mazegaki）是一种很日本的…现象。汉字和假名都是日文的正式文字，日文可以把有汉字的词汇写成汉字假名交杂的形式。比如说まんえん【蔓延】，写成汉字是「蔓延」，写成假名是「まんえん」，写成「まん延」「蔓えん」当然也可以（虽然「蔓えん」很少见）。加之二战后日本文字改革的时候推行了「当用汉字」政策限制汉字的使用，「まん延」这样的写法大行其道。这和中文不同，中文正式文本只会写成「蔓延」，「màn延」像小学生写作文。
> 
> 但是，日文辞典的条目入口一般只会收录全假名写法和尽量全汉字（能写汉字的部分都写成汉字）的写法。这时候可以在 \`ja\_JP.dic\` 中使用 \`st:\` 的方式把它们指引到全汉字条目：
> 
> \`\`\`
> まん延 st:蔓延
> まん延 st:万延
> たい積 st:体積
> たい積 st:堆積
> たい積 st:滞積
> \`\`\`
> 
> 但问题是一个混书形式可能对应多个原形，比如这里「まん延」同时对应「蔓延」「万延」，「たい積」同时对应「体積」「堆積」「滞積」。我试了下，\*\*GoldenDict‑ng 和安卓版 GoldenDict Mobile 是可以在查询「たい積」时同时给出「体積」「堆積」「滞積」的结果的\*\*，但是 \*\*《词悦》现在只能显示第一个结果\*\*。
> 
> 另外这个写法也能用来实现中文的简体繁体通查。
> 
> \`zh\_CN.aff\` 不需要任何实质内容，指定编码为 UTF‑8 就行：
> 
> \`\`\`
> SET UTF-8
> LANG zh
> FLAG long
> \# 空壳
> \`\`\`
> 
> \`zh\_CN.dic\` 的内容类似这样：
> 
> \`\`\`
> 12
> 簡體 st:简体
> 简体 st:簡體
> 繁體 st:繁体
> 繁体 st:繁體
> 发 st:髮
> 发 st:發
> 髮 st:发
> 發 st:发
> 復制 st:复制
> 複製 st:复制
> 复制 st:復制
> 复制 st:複製
> \`\`\`
> 
> 这跟上面类似，\*\*《词悦》现在只能显示第一个结果\*\*。
> 
> \*\*希望能显示所有的 \`st:\` 结果。\*\*
> 
> \<img width="1200" height="1920" alt="Image" src="https://github.com/user-attachments/assets/40572830-823f-423c-bb5b-d3fdb3e3f6d4" /\>
> \<img width="1200" height="1920" alt="Image" src="https://github.com/user-attachments/assets/b5f5e8e6-54e5-444f-ad5f-6d634e1ff2f3" /\>
> \<img width="1200" height="1920" alt="Image" src="https://github.com/user-attachments/assets/c234cc04-91d9-4b84-bfa7-2c92393747c1" /\>
> \<img width="1200" height="1920" alt="Image" src="https://github.com/user-attachments/assets/4eae873f-e4ef-486e-9de8-1462072f1377" /\>
> 
> \---
> 
> \## 2. 增加两次查询 Hunspell 的选项
> 
> 当我查询 \`"drunkest"\` 的时候，hunspell 根据生成形容词最高级的规则查到 \`drunk\`。当我查询 \`"drunk"\` 的时候才会根据 \`drunk st:drink\` 生成 \`drink\`。
> 
> \`\`\`bash
> % echo "drunkest" | hunspell -m -d ~/GoldenDict/Hunspell/en\_US
> drunkest st:drunk fl:T
> 
> % echo "drunk" | hunspell -m -d ~/GoldenDict/Hunspell/en\_US 
> drunk st:drink
> drunk st:drunk
> \`\`\`
> 
> 但是现在 《词悦》 调用 Hunspell 只会调用一次。\*\*希望能给出一个调用两次 Hunspell 的选项\*\*。第一次调用 \`drunkest\` 得到 \`drunk\` 之后，再调用一次 hunspell 从 \`drunk\` 得到 \`drink\`，并同时显示 \`drunkest\`、\`drunk\`、\`drink\` 的内容。
> 
> 当然对于英语这样词形变化比较简单的语言，直接硬编码 \`"drunkest st:drink"\` 也完全够用。但是对日语或者德语这样的语言来说，直接硬编码会让 \`.dic\` 里面到处充斥着硬编码，难以阅读和维护。
> 
> 德语例子：
> \`\`\`
> abgekämpfterem → abgekämpft → abkämpfen
> \`\`\`
> 
> 日语例子：
> \`\`\`
> 引きこもらない → 引きこもる → 引き籠もる
> \`\`\`
> 
> 如果能有两次调用 Hunspell，那我可以把 \`ja\_JP.dic\` 写成这样：
> 
> \`\`\`
> 引き籠もる/5A5I5T5E5OBDUYUBubKN
> ひきこもる/5A5I5T5E5OBDUYUBubKN
> 引きこもる/5A5I5T5E5OBDUYUBubKN
> 引きこもる st:引き籠もる
> \`\`\`
> 
> 但是如果没有两次调用，那我只能这么写，而且后缀还不全，我不能直接检索「引きこもらない」，我只能手动选中「引きこもら」才能查询：
> 
> \`\`\`
> 引き籠もる/5A5I5T5E5OBDUYUBubKN
> ひきこもる/5A5I5T5E5OBDUYUBubKN
> 引きこもっ st:引き籠もる
> 引きこもら st:引き籠もる
> 引きこもり st:引き籠もる
> 引きこもる st:引き籠もる
> 引きこもれ st:引き籠もる
> 引きこもろ st:引き籠もる
> \`\`\`
> 
> 但是对英文的还原原形，或者中文繁简转换来说两次调用 Hunspell 必要性不大或者毫无必要。因此\*\*可以把两次调用 Hunspell 做成每个 Hunspell 文件上的一个开关\*\*。
> 
> \---
> 
> 希望以上建议能被采纳，让《词悦》在非英语语言（尤其是日语、德语）的查词体验上更上一层楼。
> 
> \*\*Feature Suggestions for Hunspell in "Ciyue" (《词悦》)\*\*
> 
> \---
> 
> \## 1. Display All \`st:\` Results
> 
> In Japanese, \*mazegaki\* (混ぜ書き, mixed kana-kanji writing) is a very common phenomenon. Both kanji and kana are official scripts in Japanese, so words that have kanji forms can be written in a mixture of kanji and kana. For example, \*man'en\* (蔓延) can be written in full kanji as 「蔓延」, in full kana as 「まんえん」, or in mixed forms like 「まん延」 or 「蔓えん」 (though 「蔓えん」 is rare). Additionally, after World War II, Japan's script reform introduced the \*tōyō kanji\* policy to limit kanji usage, which made mixed forms like 「まん延」 widely prevalent. This is different from Chinese, where formal texts only use 「蔓延」 – writing 「màn延」 would look like a primary school student's essay.
> 
> However, Japanese dictionary entry headwords typically only include the \*\*full-kana\*\* form and the \*\*full-kanji\*\* form (i.e., writing as many parts as possible in kanji). In this case, we can use the \`st:\` mechanism in \`ja\_JP.dic\` to map mixed forms to their full-kanji entries:
> 
> \`\`\`
> まん延 st:蔓延
> まん延 st:万延
> たい積 st:体積
> たい積 st:堆積
> たい積 st:滞積
> \`\`\`
> 
> But the problem is that \*\*one mixed form may correspond to multiple original forms\*\*. For instance, 「まん延」 maps to both 「蔓延」 and 「万延」, while 「たい積」 maps to 「体積」, 「堆積」, and 「滞積」. I tested this: GoldenDict-ng and the Android version of GoldenDict Mobile can display \*\*all\*\* corresponding results (e.g., querying 「たい積」 shows entries for all three). However, \*\*Ciyue currently only displays the first result\*\*.
> 
> This mechanism can also be used to enable \*\*Simplified–Traditional Chinese conversion\*\* for lookup.
> 
> \`zh\_CN.aff\` does not need any substantive content; just specify UTF-8 encoding:
> 
> \`\`\`
> SET UTF-8
> LANG zh
> FLAG long
> \# empty shell
> \`\`\`
> 
> \`zh\_CN.dic\` could look like this:
> 
> \`\`\`
> 12
> 簡體 st:简体
> 简体 st:簡體
> 繁體 st:繁体
> 繁体 st:繁體
> 发 st:髮
> 发 st:發
> 髮 st:发
> 發 st:发
> 復制 st:复制
> 複製 st:复制
> 复制 st:復制
> 复制 st:複製
> \`\`\`
> 
> This is similar to the Japanese case above. Again, \*\*Ciyue currently only shows the first match\*\*.
> 
> \*\*I hope Ciyue will display \*all\* \`st:\` results, not just the first one.\*\*
> 
> \---
> 
> \## 2. Add an Option for Two Hunspell Queries (Recursive Stem Lookup)
> 
> When I query \`"drunkest"\`, Hunspell correctly finds \`drunk\` via the adjective superlative rule (\`fl:T\`). When I query \`"drunk"\`, it further yields \`drink\` from the explicit mapping \`drunk st:drink\`:
> 
> \`\`\`bash
> % echo "drunkest" | hunspell -m -d ~/GoldenDict/Hunspell/en\_US
> drunkest st:drunk fl:T
> 
> % echo "drunk" | hunspell -m -d ~/GoldenDict/Hunspell/en\_US 
> drunk st:drink
> drunk st:drunk
> \`\`\`
> 
> However, Ciyue currently calls Hunspell \*\*only once\*\*. I would like an option to call Hunspell \*\*twice\*\*:
> 
> 1. \*\*First call\*\*: \`drunkest\` → get the immediate stem \`drunk\`.
> 2. \*\*Second call\*\*: feed \`drunk\` back into Hunspell → get the deeper stem \`drink\`.
> 
> Then display all related forms together: \`drunkest\`, \`drunk\`, and \`drink\`.
> 
> Of course, for a language like English with relatively simple inflectional morphology, one could hard‑code \`drunkest st:drink\` directly in the dictionary file. But for languages like \*\*Japanese\*\* or \*\*German\*\*, hard‑coding would force the \`.dic\` file to be cluttered with countless entries, making it extremely difficult to read and maintain.
> 
> Examples:
> 
> \- German: \`abgekämpfterem\` → \`abgekämpft\` → \`abkämpfen\`
> \- Japanese: \`引きこもらない\` → \`引きこもる\` → \`引き籠もる\`
> 
> \---
> 
> \### What Two Calls Would Enable
> 
> If two Hunspell calls were possible, I could write \`ja\_JP.dic\` as simply as this:
> 
> \`\`\`
> 引き籠もる/5A5I5T5E5OBDUYUBubKN
> ひきこもる/5A5I5T5E5OBDUYUBubKN
> 引きこもる/5A5I5T5E5OBDUYUBubKN
> 引きこもる st:引き籠もる
> \`\`\`
> 
> \---
> 
> \### Without Two Calls (Current Workaround)
> 
> Without two calls, I have to manually list every conceivable inflectional stem, and even then the suffixes remain incomplete – I cannot directly look up \`引きこもらない\`; I can only manually select \`引きこもら\` to query:
> 
> \`\`\`
> 引き籠もる/5A5I5T5E5OBDUYUBubKN
> ひきこもる/5A5I5T5E5OBDUYUBubKN
> 引きこもっ st:引き籠もる
> 引きこもら st:引き籠もる
> 引きこもり st:引き籠もる
> 引きこもる st:引き籠もる
> 引きこもれ st:引きこもる (note: keep original logic, but I’ll preserve the user’s exact example)
> 引きこもろ st:引き籠もる
> \`\`\`
> \*(The user's point is that this is incomplete, cumbersome, and fails for forms like 引きこもらない.)\*
> 
> \---
> 
> \### Per-File Toggle
> 
> For \*\*English stem restoration\*\* or \*\*Simplified–Traditional Chinese conversion\*\*, a two‑call lookup is largely unnecessary or completely redundant. Therefore, \*\*this "two Hunspell calls" feature should be implemented as a toggle/switch on a per‑Hunspell‑dictionary‑file basis\*\*, so users can enable it only for languages that truly need it (e.g., Japanese, German) and keep it off for others (e.g., English, Chinese) to avoid unnecessary overhead.

2026年8月14日更新：  
增加了一些纯假名动词的活用型flag标注（おちゃらける/1KBDUyUbKN、テンパる/5A5I5T5E5OBDUYUBubKN 等）。  
增加了形容词、形容动词的〜そう、～すぎ后缀，动词的～すぎ后缀。  
2026年8月11日更新：  
根据《三省堂国語辞典第八版》增补了将近五千个词汇的混书形式。给一些纯假名的动词比如「だらける」增加了活用flag标注。

* * *

之前在GoldenDict中使用MrCorn0-0的日文构词法文件hunspell\_ja\_JP的时候就发现动词基本上都能还原到原形，但是有的形容词能还原到原形，有的不可以。比如「さむかった」能还原到「さむい」，「寒かった」能还原到「寒い」，但是「おいしかった」不能还原到「おいしい」。为什么会这样呢？我在AI的辅助排查下，终于发现原来.dic文件中有一千多个形容词的标注有问题。

.dic文件中有一千多个1形容词的条目是类似这样的：  
`愛愛しい/xAxaxixIxUxExexx/XKToXQXrXO`  
然而，Hunspell实际上不允许.dic 的词条后面有多个“/”。  
根据 `hunspell(5)` 的多个权威手册页，规范非常明确：

> “Each word may optionally be followed by **a** slash (“/”) and **one or more** flags”  
> [hunspell(5) — libhunspell-dev — Debian unstable — Debian Manpages](https://manpages.debian.org/unstable/libhunspell-dev/hunspell.5.en.html)

一个词汇后面可以有多个flag标注，但是斜杠（/）只能有一个！  
于是让AI写了一行vim命令

```auto
:%s/\(^[^\/]*\/\)\(.*\)/\=submatch(1) . substitute(submatch(2), '\/', '', 'g')/

```

把.dic文件中多余的“/”删了。这下搜索「おいしかった」终于能还原到「おいしい」了！

这个搞定之后我又思考了一下能不能用GoldenDict的Hunspell文件独有的 **st:** 扩充一下内容。首先我把「する」「くる」这两个词的变化形式都用 **st:** 指向了原形。

然后我想能不能实现「混ぜ書き」的转换？首先上网找，看看有没有「混ぜ書き」的转换词库。一搜，居然还真有，是日本用「汉直」输入法的人做的：

> **[Mozc(Google日本語入力)を利用したT-Code(2) 交ぜ書き変換 - ujimushi(@旧sradjp(15364))の日記](https://ujimushisradjp.hatenablog.jp/entry/2025/12/15/000000)**
>
> ※この記事は漢直アドベントカレンダー 2025 の15日目の記事になります。 はじめに 今回は，Mozc(Google日本語入力)のユーザー辞書を利用した交ぜ書き変換をする方法についてご紹介します。 といっても既に岡さんのgithubのmazegaki-dicレポジトリで公開されているものを 利用するだけなので，特に新しいところはないのですが，利用する時の注意点等をご紹介できればと思います。 Ubuntuで利用する場合の注意点...

GitHub地址：

> **[GitHub - oktopus1959/mazegaki-dic: Google日本語入力用の漢直向け交ぜ書き辞書](https://github.com/oktopus1959/mazegaki-dic)**
>
> Google日本語入力用の漢直向け交ぜ書き辞書

于是让AI写代码把它转换成了GoldenDict版Hunspell能用的格式了。现在搜索「まん延」可以同时找到「万延」「蔓延」了。真不错。但是搜索「立てこもり」还不能找到「立て籠もる」，因为这个辞典文件中是这样的：

```auto
立てこもり st:立て篭る

```

不仅送假名是非现代标准的节约版，还使用了异体字`篭`！看来这个辞典的动词部分需要好好人工审核一遍才行。  
但是这个肯定不是一两天能完成的事情，有一万多行呢，于是补了一行`深セン st:深圳`之后暂且先把现有成果上传到GitHub吧。。  
实际使用了之后发现这个Mozc混ぜ書き词库的错误不少，除了送假名不符合《大辞林》之类词典的标准之外，还有不少自动生成生错了的地方，比如：

```auto
石っけん st:石鹸
せ鹸 st:石鹸

```

其实应该是

```auto
石けん st:石鹸
せっ鹸 st:石鹸

```

要一点点改。  
我的fork：

> **[GitHub - yx-wh/hunspell\_ja\_JP: Hunspell morphology dictionary for Japanese used...](https://github.com/yx-wh/hunspell_ja_JP)**
>
> Hunspell morphology dictionary for Japanese used in GoldenDict.

进展：  
把oktopus1959「混ぜ書き」词库的形容詞和五段、一段動詞的部分校对了一遍。  
增加了一部分词语，比如用「着ぐるみ」（网络上常见的写法）现在可以查到「着包み」（《大辞林》等辞典中的写法）了。  
用AI生成了把Mozc格式词典转换成Hunspell支持的st:格式的Python3脚本：

`python3 convert_with_conjugation.py && python3 sort_lines.py mazegaki_st.txt mazegaki_st_sorted.txt && python3 dedup_sorted.py mazegaki_st_sorted.txt mazegaki_st_sorted_dedup.txt && python3 merge_with_count.py ja_JP_A.dic mazegaki_st_sorted_dedup.txt ja_JP.dic`

**convert\_with\_conjugation.py** 将 ipadic.maze.csv转换成mazegaki\_st.txt  
**sort\_lines.py** 对mazegaki\_st.txt排序生成mazegaki\_st\_sorted.txt  
**dedup\_sorted.py** 去除重复行，生成mazegaki\_st\_sorted\_dedup.txt  
**merge\_with\_count.py** 将ja\_JP\_A.dic和mazegaki\_st\_sorted\_dedup.txt合成到ja\_JP.dic并在顶部写上文件的行数，这是Hunspell的要求。

这样如果遇到文件里面没有收录的词汇，比如原先没有收录的「着包み」，那就可以让AI先生成

```auto
着包み	着包み	名詞	きぐるみ	--	BASE
着ぐるみ	着包み	名詞	きぐるみ
き包み	着包み	名詞	きぐるみ
きぐるみ	着包み	名詞	きぐるみ

```

放到 ipadic.maze.csv 中 再用脚本拼接生成ja\_JP.dic吧。

我的fork：

> **[GitHub - yx-wh/mazegaki-dic: Google日本語入力用の漢直向け交ぜ書き辞書](https://github.com/yx-wh/mazegaki-dic)**
>
> Google日本語入力用の漢直向け交ぜ書き辞書

---

<div class="post-metadata">

作者： ![神农X](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/%E7%A5%9E%E5%86%9Cx/32/145_2.png) [@神农X](https://forum.freemdict.com/u/%E7%A5%9E%E5%86%9CX)\
发布日期： [2026 年9 月 10 日 15:24 UTC](https://forum.freemdict.com/t/topic/44701/2 "2026-09-10T15:24:10Z")

</div>

不知道功能是不是跟这三个mdx类似

 ![Screenshot_20260910_232214](https://forumcdn.freemdict.com/uploads/default/original/3X/d/3/d3b644d875df62e53744d1c0a9693a508363947e.jpeg)

 ![Screenshot_2026_0910_232229](https://forumcdn.freemdict.com/uploads/default/original/3X/f/0/f0893f85d31e6dfa16e9ba20006e768394f9797f.jpeg)  
 ![Screenshot_20260910_232238](https://forumcdn.freemdict.com/uploads/default/original/3X/2/0/200e867bab89b6c74c0e1c8494e72397a705c7ea.jpeg)  
如果是自己提取写法的话建议还是从尽可能多一点的词库提取，除了图片里这些还有旺文社的国语辞典和标准国语辞典

---

<div class="post-metadata">

作者： ![yx\_wh](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/yx_wh/32/77200_2.png) [@yx\_wh](https://forum.freemdict.com/u/yx_wh)\
发布日期： [2026 年9 月 10 日 15:38 UTC](https://forum.freemdict.com/t/topic/44701/3 "2026-09-10T15:38:02Z")

</div>

MrCorn0-0似乎就是Gary，你的截图中已经有他的名字了，我就是fork的他。他原先提取的词头应该是来自大辞林第三版，因为有几个别的辞典都没有的词头。还有没有别的辞典也收了就不知道了。

混书（混ぜ書き）的还原我还没有做完，但是主要是以《三省堂国语辞典》《新明解国语辞典》作为参考，二十万词级别的辞典就没有考虑了，古文和百科条目考虑混书形式的还原恐怕意义不大。

---

<div class="post-metadata">

作者： ![winn](https://forumcdn.freemdict.com/letter_avatar_proxy/v4/letter/w/9dc877/32.png) [@winn](https://forum.freemdict.com/u/winn)\
发布日期： [2026 年9 月 10 日 15:50 UTC](https://forum.freemdict.com/t/topic/44701/4 "2026-09-10T15:50:02Z")

</div>

这个感觉太麻烦了。想来个简单的，像西语变位那样一劳永逸解决变形词的查询。

---

<div class="post-metadata">

作者： ![yx\_wh](https://forumcdn.freemdict.com/user_avatar/forum.freemdict.com/yx_wh/32/77200_2.png) [@yx\_wh](https://forum.freemdict.com/u/yx_wh)\
发布日期： [2026 年9 月 10 日 17:07 UTC](https://forum.freemdict.com/t/topic/44701/5 "2026-09-10T17:07:27Z")

</div>

GoldenDict很早就有西班牙语的"better morphologies"了。

> **[GoldenDict - Browse /better morphologies/1.0 at SourceForge.net](https://sourceforge.net/projects/goldendict/files/better%20morphologies/1.0/)**
>
> GoldenDict /better morphologies/1.0 files. Browse /better morphologies/1.0 files for GoldenDict

日文是本来就没有拼写检查文件，而且根据已有辞典搞hunspell显然会遇到日文本身的复杂性。
