############################################################## python - googleTrans を使用した自動翻訳ツール ############################################################## ========================================================= webベースの自動翻訳ツールにおいてコピペの手間を省く ========================================================= * 論文翻訳時にpdfから :red:`日本訳pdfを直接生成するツール` を作成 * 現在版は、 :blue:`Google翻訳` を使用. + エンジン部分でDeeplのpython APIを叩けば、Deeplの使用が同様に可能. + そのうち拡張予定. --------------------------------------------------------- 制約 --------------------------------------------------------- * ネットへの接続が必要. * 無料版では、 :blue:`500000字` までの制限があるらしい. + ただし、今のところ、公共無線LANから接続している(IPが都度変わる)からか、制約をくらったことはない. | ========================================================= 使用方法 (1例) ========================================================= * pathが通る場所 ( e.g. /usr/local/bin/ ) に translator__usingGoogleTrans.py を置いておく. * importする他のコード( nkTextProcess.convert__text2pdf.py, nkTextProcess.extract__textFromPDF.py ) はpython path の通ったところにおいておく( nkTextProcess )、もしくは、同一ファイル内に入れておく. * 実行権限を付与しておく + $ sudo chmod +x translator__usingGoogleTrans.py をしておく + shebang ( = pythonファイルの先頭のおまじない) はすでに設定.適宜変更. --------------------------------------------------------- 実行コマンド --------------------------------------------------------- :: $ translator__usingGoogleTrans.py --input_pdf pdf/sample.pdf | :: $ translator__usingGoogleTrans.py --input_pdf pdf/sample.pdf --output_pdf pdf/output.pdf --english_text text_en.txt --japanese_text text_ja.txt --intermediate True --fontsize 8.0 --show True | ========================================================= コード ========================================================= --------------------------------------------------------- github --------------------------------------------------------- :: $ git clone https://github.com/wfw-pgr/nkTextProcess.git | ----------------------------------------------------------------------------------------- translator__usingGoogleTrans.py ( スタンドアロン:ライブラリ同梱バージョン ) ----------------------------------------------------------------------------------------- .. literalinclude:: translator__usingGoogleTrans_allinone.py :language: python | ========================================================= nkTextProcess 参照ver. ========================================================= --------------------------------------------------------- translator__usingGoogleTrans.py --------------------------------------------------------- .. literalinclude:: translator__usingGoogleTrans.py :language: python | --------------------------------------------------------- convert__text2pdf.py --------------------------------------------------------- .. literalinclude:: convert__text2pdf.py :language: python | --------------------------------------------------------- extract__textFromPDF.py --------------------------------------------------------- .. literalinclude:: extract__textFromPDF.py :language: python |