APIS
Caution
このドキュメントは古くなっていますので、参照しないでください。
目次
本プロジェクトは 2 種類の API をサポートしており、すべてのメソッドには Redis が必要です。
Python
pdf2zh
は Python のインストール済みモジュールであるため、他のプログラムが任意の Python スクリプトで呼び出せるように 2 つのメソッドを公開しています。
例えば、Google 翻訳を使用して英語から中国語に文書を翻訳したい場合、以下のコードを使用できます:
from pdf2zh_next import translate, translate_stream
params = {
'lang_in': 'en',
'lang_out': 'zh',
'service': 'google',
'thread': 4,
}
with open('example.pdf', 'rb') as f:
(stream_mono, stream_dual) = translate_stream(stream=f.read(), **params)
HTTP
より柔軟な方法として、以下の場合には HTTP プロトコルを使用してプログラムと通信できます:
- バックエンドのインストールと実行
-
HTTP プロトコルを使用する方法:
-
翻訳タスクの送信
curl http://localhost:11008/v1/translate -F "[email protected]" -F "data={\"lang_in\":\"en\",\"lang_out\":\"zh\",\"service\":\"google\",\"thread\":4}" {"id":"d9894125-2f4e-45ea-9d93-1a9068d2045a"}
-
進捗状況の確認
-
進捗状況の確認(完了時)
-
単一言語ファイルの保存
-
二言語ファイルの保存
-
実行中のタスクを中断して削除