2022年1月11日 星期二

簡體中文 OCR -> 繁體


Convert PDF to image file.


$ sudo apt-get install imagemagick

  1. Open the policy.xml file in terminal by entering this command -

    sudo nano /etc/ImageMagick-6/policy.xml

  2. Now, directly edit the file in terminal, find <policy domain="coder" rights="none" pattern="PDF" /> and replace none with read|write as shown in the picture. Then press Ctrl+X to exit.


$ convert ../CHM.pdf 'test-%02d.jpg'

On Mac:

https://chuhw.pixnet.net/blog/post/229327724-%E5%9C%A8-mac-%E5%A6%82%E4%BD%95%E5%BF%AB%E9%80%9F%E5%9C%B0%E5%B0%87-pdf-%E6%89%80%E6%9C%89%E9%A0%81%E9%9D%A2%E8%BD%89%E6%88%90-jpg-%E6%88%96%E6%98%AF

Install OCR

$ sudo apt-get install tesseract-ocr-chi-sim

Run OCR

for i in `ls`; do echo tesseract $i $(basename $i .jpeg) -l chi_sim ; done

Convert Simplified to Traditional Chinese

$ sudo apt-get install opencc

for i in `ls *.txt` ; do opencc -i $i > ../CHM-TW/$i ; done

沒有留言:

張貼留言