過濾指定的筆畫數

在 AI 算字資源有限的情況下, 想先加強去訓練”常用字” 且 “高筆畫字” 的字, 該怎麼做?


前置作業

筆畫的json字典檔需要手動下載:
https://github.com/max32002/MaxFontScripts

Max腳本檔案下載:
https://github.com/max32002/MaxFontScripts/blob/master/filter_characters.py


Python 腳本 filter_characters.py,參數說明:

  • –input: 讀取指定的文字檔
  • –output: 結果輸出到指定檔案
  • –radical:只保留部首為該值的字
  • –radical_count:只保留部首筆畫數等於該值的字
  • –strokes_more 只保留筆畫數大於等於該值的字

使用方式

準備輸入文字檔, 建立 input.txt,內容如下:

漢字測試中字典筆畫

篩選筆畫數大於等於 9 的字

python filter_characters.py --input input.txt --strokes_more 9 --output output.txt

結果:

漢測試筆畫

篩選部首為「水」的字

python filter_characters.py --input input.txt --radical 水 --output output.txt

結果:

漢測

篩選部首筆畫數 >= 3

python filter_characters.py --input input.txt --radical_count 3 --output output.txt

結果:

字字

篩選 筆畫數 ≥ 9 且 部首為「水」 的字:

python filter_characters.py --input input.txt --strokes_more 9 --radical 水 --output output.txt

結果:

漢測