This is under development. And only a prototype is available for now.
Tools for MTL development, rewrote some tools from previous python scripts, and a few new tools.
The translate function takes a lot of resources, around 8gb of ram to load the model and then will keep your cpu usage upto brim, powerful cpu means less time for total translation.
You also need reasonable disk space, few GB to download the translation model’s data.
You need rust installed. Then just run the project.
Runs from cargo run
.
If you don’t want to install rust and compile it, download the zip from releases and then install pytorch
so that you have the libraries for it. Then just run the executable.
The compiled executable is in releases. Download the onegai-windows.zip
and run the executable onegai.exe
from powershell (cmd doesn’t do well with escape sequences). All the dlls are included in the zip.
Use -h
flag for usage instructions.
./target/release/onegai -h
#+RESULTS[8f7b02fb9b0c63c03269f792ad4b592980519ca8]:
onegai USAGE: onegai <SUBCOMMAND> OPTIONS: -h, --help Print help information SUBCOMMANDS: combine Build a html page for viewing the file contents download Download a web novel chapter from syosetu into a text file help Print this message or the help of the given subcommand(s) replace Replace the terms according to rules on json file translate Translate from Japanese to English
Use help <tool>
for further help:
./target/release/onegai help download
#+RESULTS[80e09722b3d703ae673c49a9a9d145edb4ef4e4e]:
onegai-download Download a web novel chapter from syosetu into a text file USAGE: onegai download <NCODE_URL> <OUTPUT_FILE> ARGS: <NCODE_URL> Chapter url Chapter url should be from syosetu.com. Examples of supported urls are: https://ncode.syosetu.com/n2267be/561/, ncode.syosetu.com/n2267be/561/, n2267be/561/, etc <OUTPUT_FILE> Output file to save the chapter OPTIONS: -h, --help Print help information
./target/release/onegai help replace
#+RESULTS[fbabf32e6abd21d8b6c10574733baffc3f46e44a]:
onegai-replace Replace the terms according to rules on json file USAGE: onegai replace [OPTIONS] --replacement-json <REPLACEMENT_JSON> <INPUT_FILE> <OUTPUT_FILE> ARGS: <INPUT_FILE> Input file <OUTPUT_FILE> Output file OPTIONS: -h, --help Print help information -r, --replacement-json <REPLACEMENT_JSON> Replacement Json Replacement Json must have 3 fields, rules honorifics and contents. `rules' contains the order of replacement and extra informations, honorifics are list of honorifics to cycle through for each name, and contents are the replacement contents. -t, --threshold <THRESHOLD> Replacement Threshold for names without honorifics For example, threshold of 3 means names with single kanji won't be replaced if it comes without honorifics. To make it easier to decide on this the length of strings are shown in square brackets after them. [default: 3]
You can run these commands as a test:
./target/release/onegai download ncode.syosetu.com/n2267be/561/ /tmp/demo-chapter.txt
#+RESULTS[9b3a03940cf12d60f1c038a1b948723061bfeb62]:
Requesting: https://ncode.syosetu.com/n2267be/561
./target/release/onegai replace -r data/replacements/rezero.json /tmp/demo-chapter.txt /tmp/demo-chapter-rep.txt
#+RESULTS[e58296de1a1d5eb133b472a928157cb6a4e28533]:
* Basic Symbols [basic]: ― [3] → - (386) 」 [3] → " (328) 『 [3] → " (27) 「 [3] → " (328) 』 [3] → " (27) △▼△▼△▼△ [21] → ******* (14) [3] → (904) * Important Names [names]: ナツキ・スバル [21] → Natsuki Subaru (10) グランヒルテ [18] → Granhiert (1) アストレア [15] → Astrea (1) スバル [9] → Subaru (258) * Not Important Names [full-names]: 菜月・昴 [12] → Natsuki Subaru (1) * Single Names [single-names]: * Semi Important Names [last-names]: * Special Terms [specials]: * Name like terms [name-like]: 姉様 [6] → Nee-sama (2) 姉ちゃん [12] → Nee-chan (4) お兄ちゃん [15] → Onii-chan (1) お兄さん [12] → Onii-san (1) お姉さん [12] → Onee-san (1)
There is protection built in so it doesn’t overwrite your old translation files accidentally. You can also append to old file and skip the translated lines for seamless continuation. Use --resume
for automatic resume. the combination of --append
and --skip-lines
can also it.