GitHub - venkr/martial-lint: Cleans up awkward translations frequent in Wuxia, using an LLM

2 min read Original article ↗

martial-lint banner

Cleans up awkward translations frequent in Wuxia.

Works by running an LLM on each individual chapter, with instructions to modify the text to improve grammar/phrasing, while keeping modifications especially to proper nouns minimal.

On a relatively long Wuxia novel called "40 Millenniums of Cultivation" (2700 chapters, 5.4M words), this cost about $22.75 and took 4m50s with Gemini-2.5 Flash.

Here's a sample before/after on Chapter 1 of 40 Milleniums of Cultivation.

You might see better results with a larger model (eg: Claude Opus 4.5), but expect it to cost ~$250 instead.

Usage

Set your OpenRouter API Key (get one here):

export OPENROUTER_API_KEY=...

With uv (recommended):

uv tool install git+https://github.com/venkr/martial-lint
martial-lint

With pipx:

pipx install git+https://github.com/venkr/martial-lint
martial-lint

Usage:

martial-lint --help
Usage: martial-lint [OPTIONS] INPUT_EPUB

  Clean up Wuxia novel translations in EPUB format.

  Takes INPUT_EPUB and writes cleaned version to INPUT_EPUB.fixed.epub

Options:
  --model TEXT            OpenRouter model to use for cleanup  [default:
                          google/gemini-2.5-flash]
  --max-parallel INTEGER  Maximum number of parallel LLM calls  [default: 10]
  --limit INTEGER         Only process the first N chapters
  --debug                 Output plaintext chapter comparisons to debug/
                          directory
  --help                  Show this message and exit.

Run:

$ martial-lint "Forty Millenniums of Cultivation 1-2711 (Ranobes) (Z-Library).epub" --max-parallel 100

martial-lint
  Input:  Forty Millenniums of Cultivation 1-2711 (Ranobes) (Z-Library).epub
  Output: Forty Millenniums of Cultivation 1-2711 (Ranobes) (Z-Library).fixed.epub
  Model:  google/gemini-2.5-flash

Reading EPUB...
Found 2712 chapters
Max parallel: 100

 Progress         [█████████████████████████████░] 100% 
 Completed        2708/2712 (4 errors)                  
 Active           [-]                                   
 Cost so far      $22.7557                              
 Tokens           8,751,552 in / 8,058,344 out          
 Elapsed          4m 50s                                
 Est. total cost  $22.7893                              
 Est. total time  4m 50s  

 Errors (4):
  OEBPS/Text/0224_Chapter_225_Ding_Lingdangs_Secret.xhtml: Failed to produce valid XHTML after 3 
attempts
  OEBPS/Text/0951_Chapter_952_The_Hardest_First_Step.xhtml: Failed to produce valid XHTML after 3 
attempts
  OEBPS/Text/1936_Chapter_1937_Black_Triangle.xhtml: peer closed connection without sending 
complete message body (incomplete chunked read)
  OEBPS/Text/2408_Chapter_2409_Old_Song.xhtml: Failed to produce valid XHTML after 3 attempts

 Final Stats:
  Processed: 2708/2712 chapters
  Total cost: $22.7557
  Total tokens: 8,751,552 in / 8,058,344 out
  Total time: 4m 50s

Writing Forty Millenniums of Cultivation 1-2711 (Ranobes) (Z-Library).fixed.epub...
Done!

Note that errors may occur in some cases, we retry a few times, but if we can't recover, we ultimately use the original text.