0

Does anyone know of a Cangjie converter that can convert bulk texts to and from Cangjie codes?

Example conversions:

kb2 oiar grmbc jjomn oh egi --> 冇倉頡輸入法

冇倉頡輸入法 --> kb2 oiar grmbc jjomn oh egi

Thanks.

1 Answer 1

1

I found one (may be the only preexisted one throughout the Internet) on Github. Link: https://github.com/Jerryzhao-z/chinese2cangjie


Edit:

I've tried the script by following steps and it worked on Windows 10.

  1. Install Python 3.7 and configure system environment variants.
  2. Download source code ZIP and unzip it. Enter unzipped "chinese2cangjie-master" folder.
  3. Create a new .txt file in that folder and rename it into "Convert.bat" (Note: the extension is changed). Edit this file and input following command lines and save.
python c_transform.py --input input.txt --output output.txt --mode 0
pause
  1. Create a new .txt file in the folder and rename it into "input.txt". Edit this file and input Chinese characters need converting (such as "冇倉頡輸入法") and Save.
  2. Create a new .txt file in the folder and rename it into "output.txt". Leave it empty.
  3. Run "Convert.bat" and wait. After finishing, open "output.txt" and you'll get Cangjie codes (such as "xkb oiar grmbc jjomn oh egi").
  4. If you want to convert Cangjie to character, just input Cangjie codes in the "input.txt" and change the number 0 to 1 in "Convert.bat" and run. You will get characters in "output.txt".

By the way, I actually don't understand Cangjie but I found the sentence "kb2 oiar grmbc jjomn oh egi" you gave will not be converted into "冇倉頡輸入法" but "kb2倉頡輸入法" instead. That means "冇" is represented by "xkb" according to the reversed convertion, but not "kb2". I don't know which is right, however, you can modify the dictionary files ("Cangjie5.txt" and/or "char2cangjie.json") to avoid this if needed, I guess.

15
  • Thank you! Looking at the code, it seems it should be able to do what I want it to. But I'm encountering all sorts of errors and I'm not sure how to fix them. I know I can report issues on github, but have you gotten this working yourself? If so, could you give me some sample inputs to see if I'm just typing something wrong? Thanks!
    – YQ002lc2
    Aug 1, 2021 at 22:49
  • Sorry, I haven't tested the code yet. I will try it later this afternoon and reply to you then.
    – xzqsr
    Aug 2, 2021 at 3:35
  • Hi, I just edited my answer! @YQ002lc2
    – xzqsr
    Aug 2, 2021 at 9:48
  • Thank you for your edit! I followed your instructions and I'm getting an error. I'll try to add it below.
    – YQ002lc2
    Aug 2, 2021 at 10:13
  • Traceback (most recent call last): File "~/chinese2cangjie-master/c_transform.py", line 134, in <module> outfile = c_trans.chinese2cangjie(infile = args.input, outfile = args.output, mapfile = args.map) File "~/chinese2cangjie-master/c_transform.py", line 113, in chinese2cangjie self.__check_prepare(infile, mode, mapfile) File "~/chinese2cangjie-master/c_transform.py", line 33, in check_prepare mapfunction = json.load(open(mapfile), encoding="utf8") File "/usr/lib/python3.9/json/__init.py", line 293, in load return loads(fp.read(),
    – YQ002lc2
    Aug 2, 2021 at 10:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.