Giter VIP home page Giter VIP logo

Comments (3)

masagrator avatar masagrator commented on May 28, 2024 1

This is my Python 3 CSTL extraction script that doesn't use regular expressions. There are no unknows left in terms of CSTL structure.

https://github.com/masagrator/NXGameScripts/blob/main/Cyanotype%20Daydream/CSTL_Extractor_PC.py

Just provide folder with cstl files as argument

f.e.

python CSTL_Extractor_PC.py scenes

from triggerstools.catsystem2.

lhy-cpu avatar lhy-cpu commented on May 28, 2024

Maybe you can try notepad++

from triggerstools.catsystem2.

ZillionClay avatar ZillionClay commented on May 28, 2024

you can easily do this with regular expressions.
this is a python script, which may be helpful.

# 用于粗略提取 CatSystem2 的 .cstl 文件中的翻译内容的脚本
# 输出在与脚本同目录下的 cstl_out.txt 文件中
# Script for rough extraction of translations in the cstl file of Catsystem2
# The output is in cstl_out.txt in the same directory as the script

import re

filename = "com04B.cstl"

f = open(filename, "r", encoding="utf-8", errors="ignore")

fo = open("cstl_out.txt","w", encoding="utf-8")

# 分割旁白的符号
# Symbols used to split narrations
dialogSep = re.compile(r"[\x00][\x00-\xff]")

# 分割对话与角色名的符号,但这可能不起作用
# Symbols used to split dialog and role names, but it may not work
roleSep = re.compile(r"[\x00-\xff]「|「")

unknowChar = re.compile(r"\\x[0-9a-f][0-9a-f]")

while True:
    line = f.readline()
    if not line:
        break
    line = re.sub(dialogSep, "\n", line)
    line = re.sub(roleSep, " 「", line)
    cstlStr = repr(line)

    # 替换剩余所有无法识别为文本的二进制为换行符
    # Replace any remaining binary unrecognized as text with a line break
    cstlStr = re.sub(unknowChar, "\n", cstlStr)

    cstlStr = cstlStr.split("\n")

    for s1 in cstlStr:
        betterStr = s1.split("\\n")

        for s2 in betterStr:

            # 过滤掉含日文假名的句子,目的是尽可能提取出翻译
            # Filter out sentences with Japanese kana 
            # in order to extract translations whenever possible
            if s2 and not re.search("[あ-んア-ン]", s2):
                fo.write('"{}"\n\n'.format(s2))

fo.close()

from triggerstools.catsystem2.

Related Issues (8)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.