Artikash / Textractor

Extracts text from video games and visual novels. Highly extensible.
GNU General Public License v3.0
2k stars 201 forks source link

Develop Textractor Extensions with Python #1268

Open voidpenguin-28 opened 3 months ago

voidpenguin-28 commented 3 months ago

Technically this post is not reporting an issue, but I felt this was the best place to put this to inform any potential future developers looking to develop Textractor extension functionality using Python code.

Normally Textractor extensions would be developed in C++ since that is the native language of the application; however, I have developed a C++ Textractor extension that allows you to write and run python code as if it were an extension for Textractor. For those familiar with existing Textractor extensions, this is fairly similar to the Lua extension.

This extension is called PythonInterpretter. The extension essentially serves as a middle man between Textractor and an underlying Python process that is maintained by this extension, therefore allowing you to write/use a python script which you can tell the extension to use.

The repo comes with 2 existing python scripts that can be used for testing:

  1. An example script which simply showcases how the script works and provides comprehensive documentation on how to define a Textractor-compatable script. Functionality-wise, all it does is increment a number each time it processing a sentence and prepends it to the sentence.
  2. A script that leverages a python NLP library (cutlet) to convert/append jp to romaji text.


This can all be found in the following GitHub repo. Source code/documentation: https://github.com/voidpenguin-28/Textractor-ExtraExtensions/tree/main/Textractor.PythonInterpretter

Example python script with documentation: https://github.com/voidpenguin-28/Textractor-ExtraExtensions/blob/main/Textractor.PythonInterpretter/scripts/ScriptExample/extension-script-ex.py

Extension and scripts download (under PythonInterpretter releases): https://github.com/voidpenguin-28/Textractor-ExtraExtensions/releases

Example image of the extension in use: Example