This commit is contained in:
恍兮惚兮 2024-11-08 17:07:24 +08:00
parent dc0c7db1a5
commit 8e37d6dc64
18 changed files with 66 additions and 88 deletions

View File

@ -4,6 +4,7 @@ import subprocess
rootDir = os.path.dirname(__file__)
if not rootDir:
rootDir = os.path.abspath(".")
rootDir=os.path.abspath(os.path.join(rootDir,'../../cpp/LunaHook'))
if len(sys.argv) and sys.argv[1] == "loadversion":
os.chdir(rootDir)
with open("CMakeLists.txt", "r", encoding="utf8") as ff:

View File

@ -9,6 +9,8 @@ if not rootDir:
rootDir = os.path.abspath(".")
else:
rootDir = os.path.abspath(rootDir)
rootthisfiledir=rootDir
rootDir=os.path.abspath(os.path.join(rootDir,'../../py'))
if sys.argv[1] == "loadversion":
os.chdir(rootDir)
with open("../cpp/version.cmake", "r", encoding="utf8") as ff:
@ -258,7 +260,7 @@ if __name__ == "__main__":
shutil.rmtree(os.path.join(os.path.dirname(py37Path), "Lib\\test"))
shutil.rmtree(os.path.join(os.path.dirname(py37Path), "Lib\\unittest"))
# 放弃3.8需要安装KB2533623才能运行3.7用不着。
subprocess.run(f"{py37Path} collectpyruntime.py")
subprocess.run(f"{py37Path} {os.path.join(rootthisfiledir,'collectpyruntime.py')}")
elif sys.argv[1] == "merge":
createPluginDirs()
downloadsomething()
@ -291,12 +293,24 @@ if __name__ == "__main__":
dirs_exist_ok=True,
)
os.chdir(rootDir + "/../cpp/scripts")
subprocess.run(f"python copytarget.py 1")
subprocess.run(f"python copytarget.py 0")
os.makedirs('../../py/files/plugins/DLL32',exist_ok=True)
shutil.copy('../builds/_x86/shareddllproxy32.exe','../../py/files/plugins')
shutil.copy('../builds/_x86/winrtutils32.dll','../../py/files/plugins/DLL32')
shutil.copy('../builds/_x86/winsharedutils32.dll','../../py/files/plugins/DLL32')
shutil.copy('../builds/_x86/wcocr.dll','../../py/files/plugins/DLL32')
shutil.copy('../builds/_x86/LunaOCR32.dll','../../py/files/plugins/DLL32')
os.makedirs('../../py/files/plugins/DLL64',exist_ok=True)
shutil.copy('../builds/_x64/shareddllproxy64.exe','../../py/files/plugins')
shutil.copy('../builds/_x64/hookmagpie.dll','../../py/files/plugins')
shutil.copy('../builds/_x64/winrtutils64.dll','../../py/files/plugins/DLL64')
shutil.copy('../builds/_x64/winsharedutils64.dll','../../py/files/plugins/DLL64')
shutil.copy('../builds/_x64/wcocr.dll','../../py/files/plugins/DLL64')
shutil.copy('../builds/_x64/LunaOCR64.dll','../../py/files/plugins/DLL64')
if arch == "x86":
os.chdir(rootDir)
os.system("python collectall.py 32")
os.system(f"python {os.path.join(rootthisfiledir,'collectall.py')} 32")
else:
os.chdir(rootDir)
os.system("python collectall.py 64")
os.system(f"python {os.path.join(rootthisfiledir,'collectall.py')} 64")

View File

@ -3,6 +3,13 @@ import platform
import sys
from importanalysis import importanalysis
rootDir = os.path.dirname(__file__)
if not rootDir:
rootDir = os.path.abspath(".")
else:
rootDir = os.path.abspath(rootDir)
rootthisfiledir=rootDir
rootDir=os.path.abspath(os.path.join(rootDir,'../../py'))
x86 = platform.architecture()[0] == "32bit"
if sys.argv[1] == "32":
targetdir = r"build\LunaTranslator_x86"

View File

@ -3,6 +3,13 @@ import modulefinder, shutil, os, sys
import builtins, platform
import sys
rootDir = os.path.dirname(__file__)
if not rootDir:
rootDir = os.path.abspath(".")
else:
rootDir = os.path.abspath(rootDir)
rootthisfiledir=rootDir
rootDir=os.path.abspath(os.path.join(rootDir,'../../py'))
pyversion = platform.python_version()
pyversion2 = "".join(pyversion.split(".")[:2])
x86 = platform.architecture()[0] == "32bit"

View File

@ -1,8 +1,12 @@
import os, shutil, sys
os.chdir(os.path.dirname(__file__))
rootDir = os.path.dirname(__file__)
if not rootDir:
rootDir = os.path.abspath(".")
rootDir=os.path.abspath(os.path.join(rootDir,'../../cpp/LunaHook'))
os.chdir(rootDir)
for f in os.listdir("../builds"):
if os.path.isdir("../builds/" + f) == False:
continue

View File

@ -36,7 +36,7 @@ jobs:
python-version: '3.7.9'
architecture: ${{ matrix.architecture }}
- run: python py/build.py pyrt ${{ matrix.architecture }} 3.7.9
- run: python .github/scripts/build_lunatranslator.py pyrt ${{ matrix.architecture }} 3.7.9
- uses: actions/upload-artifact@v4
with:
name: pyrt_${{ matrix.architecture }}
@ -54,7 +54,7 @@ jobs:
with:
sdk-version: 22621
- run: python py/build.py cpp ${{ matrix.architecture }}
- run: python .github/scripts/build_lunatranslator.py cpp ${{ matrix.architecture }}
- uses: actions/upload-artifact@v4
with:
name: cpp_${{ matrix.architecture }}
@ -76,7 +76,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
path: build
- run: python py/build.py merge ${{ matrix.architecture }}
- run: python .github/scripts/build_lunatranslator.py merge ${{ matrix.architecture }}
- uses: actions/upload-artifact@v4
with:
name: ${{ matrix.fname }}

View File

@ -22,8 +22,8 @@ jobs:
- uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 22621
- run: python cpp/LunaHook/build.py build ${{ matrix.language }} winxp
- run: python cpp/LunaHook/scripts/pack.py
- run: python .github/scripts/build_lunahook.py build ${{ matrix.language }} winxp
- run: python .github/scripts/packlunahook.py
- uses: actions/upload-artifact@v4
with:
@ -65,8 +65,8 @@ jobs:
arch: ${{ matrix.qtarch }}
dir: ${{ runner.temp }}
setup-python: true
- run: python cpp/LunaHook/build.py ${{ matrix.cmd }}
- run: python cpp/LunaHook/scripts/pack.py
- run: python .github/scripts/build_lunahook.py ${{ matrix.cmd }}
- run: python .github/scripts/packlunahook.py
# - name: Generate attestation for artifact
# uses: actions/attest-build-provenance@v1
@ -99,7 +99,7 @@ jobs:
- uses: GuillaumeFalourd/setup-windows10-sdk-action@v2
with:
sdk-version: 22621
- run: python cpp/LunaHook/build.py build ${{ matrix.language }} ${{matrix.bits}}
- run: python .github/scripts/build_lunahook.py build ${{ matrix.language }} ${{matrix.bits}}
- uses: actions/upload-artifact@v4
with:
@ -114,7 +114,7 @@ jobs:
- uses: actions/download-artifact@v4
with:
path: cpp/LunaHook/build
- run: python cpp/LunaHook/build.py merge
- run: python .github/scripts/build_lunahook.py merge
- uses: softprops/action-gh-release@v2
with:
tag_name: LunaHook

View File

@ -54,7 +54,7 @@
- **日语分词及假名显示** 支持使用 Mecab 等分词和显示假名
- **查词** 支持使用 **离线辞书** ( MDICT、小学馆、灵格斯词典、EDICT/EDICT2 ) 和 **在线辞书** ( 有道、weblio、Goo、Moji、jisho ) 进行单词查询
- **查词** 支持使用 **离线辞书** ( MDICT、小学馆、灵格斯词典、EDICT/EDICT2 ) 和 **在线辞书** ( 有道、weblio、Goo、Moji、jisho、JapanDict ) 进行单词查询
- **Anki** 支持使用一键添加单词到anki中

View File

@ -1,6 +1,6 @@
cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/x86
cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14
cmake ..\CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ..\build\x86
cmake --build ..\build\x86 --config Release --target ALL_BUILD -j 14
cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/x64
cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14
python copytarget.py
cmake ..\CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ..\build\x64
cmake --build ..\build\x64 --config Release --target ALL_BUILD -j 14
robocopy ..\builds\Release_English ..\..\..\py\files\plugins\LunaHook

View File

@ -1,2 +0,0 @@
import shutil,sys
shutil.copytree('../builds/Release_English','../../../py/files/plugins/LunaHook',dirs_exist_ok=True)

View File

@ -1 +0,0 @@
python pack.py

View File

@ -1,4 +1,5 @@
python fetchwebview2.py
cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ../build/x86
cmake --build ../build/x86 --config Release --target ALL_BUILD -j 14
python copytarget.py 1
cmake ..\CMakeLists.txt -G "Visual Studio 17 2022" -A win32 -T host=x86 -B ..\build\x86
cmake --build ..\build\x86 --config Release --target ALL_BUILD -j 14
copy .\builds\_x86\shareddllproxy32.exe ..\..\py\files\plugins
robocopy ..\builds\_x86 ..\..\py\files\plugins\DLL32

View File

@ -1,4 +1,7 @@
python fetchwebview2.py
cmake ../CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ../build/x64
cmake --build ../build/x64 --config Release --target ALL_BUILD -j 14
python copytarget.py 0
cmake ..\CMakeLists.txt -G "Visual Studio 17 2022" -A x64 -T host=x64 -B ..\build\x64
cmake --build ..\build\x64 --config Release --target ALL_BUILD -j 14
copy ..\builds\_x64\shareddllproxy64.exe ..\..\py\files\plugins
copy ..\builds\_x64\hookmagpie.dll ..\..\py\files\plugins
robocopy ..\builds\_x64 ..\..\py\files\plugins\DLL64

View File

@ -1,17 +0,0 @@
import shutil,sys,os
x86=int(sys.argv[1])
if x86:
os.makedirs('../../py/files/plugins/DLL32',exist_ok=True)
shutil.copy('../builds/_x86/shareddllproxy32.exe','../../py/files/plugins')
shutil.copy('../builds/_x86/winrtutils32.dll','../../py/files/plugins/DLL32')
shutil.copy('../builds/_x86/winsharedutils32.dll','../../py/files/plugins/DLL32')
shutil.copy('../builds/_x86/wcocr.dll','../../py/files/plugins/DLL32')
shutil.copy('../builds/_x86/LunaOCR32.dll','../../py/files/plugins/DLL32')
else:
os.makedirs('../../py/files/plugins/DLL64',exist_ok=True)
shutil.copy('../builds/_x64/shareddllproxy64.exe','../../py/files/plugins')
shutil.copy('../builds/_x64/hookmagpie.dll','../../py/files/plugins')
shutil.copy('../builds/_x64/winrtutils64.dll','../../py/files/plugins/DLL64')
shutil.copy('../builds/_x64/winsharedutils64.dll','../../py/files/plugins/DLL64')
shutil.copy('../builds/_x64/wcocr.dll','../../py/files/plugins/DLL64')
shutil.copy('../builds/_x64/LunaOCR64.dll','../../py/files/plugins/DLL64')

View File

@ -52,7 +52,7 @@ Supports almost all conceivable translation engines, including:
- **Japanese Word Segmentation and Kana Display** Supports word segmentation and kana display using Mecab, etc.
- **Vocabulary Lookup** Supports **offline dictionaries** (MDICT, Shougakukan, Lingoes Dictionary, EDICT/EDICT2) and **online dictionaries** (Youdao, weblio, Goo, Moji, jisho) for word lookup
- **Vocabulary Lookup** Supports **offline dictionaries** (MDICT, Shougakukan, Lingoes Dictionary, EDICT/EDICT2) and **online dictionaries** (Youdao, weblio, Goo, Moji, jisho, JapanDict) for word lookup
- **Anki** Supports one-click addition of words to Anki

View File

@ -54,7 +54,7 @@
- **Сегментация японских слов и отображение глифов** Поддерживает использование Mecab и других для сегментации и отображения глифов
- **Поиск слов** Поддерживает использование **оффлайн словарей** ( MDICT, Shougakukan, Lingoes Dictionary, EDICT/EDICT2 ) и **онлайн словарей** ( Youdao, weblio, Goo, Moji, jisho ) для поиска слов
- **Поиск слов** Поддерживает использование **оффлайн словарей** ( MDICT, Shougakukan, Lingoes Dictionary, EDICT/EDICT2 ) и **онлайн словарей** ( Youdao, weblio, Goo, Moji, jisho, JapanDict ) для поиска слов
- **Anki** Поддерживает добавление слов в Anki одним нажатием кнопки

View File

@ -1,39 +0,0 @@
from ocrengines.baseocrclass import baseocr
from ctypes import CDLL, c_char_p, c_size_t, c_void_p, CFUNCTYPE, sizeof, c_wchar_p
import json, os
youdaosig = CDLL(
os.path.join(os.path.dirname(__file__), f"ydocr{sizeof(c_void_p)*8}.dll")
)
ydocr = youdaosig.ydocr
ydocr.argtypes = c_void_p, c_size_t, c_wchar_p, c_wchar_p, c_void_p
def doocr(image, src, tgt):
ret = []
fp = CFUNCTYPE(None, c_char_p)(ret.append)
ydocr(image, len(image), src, tgt, fp)
boxs = []
texts = []
transs = []
for line in ret:
line = json.loads(line.decode("utf8"))
boxs.append(line[:4])
texts.append(line[4])
transs.append(line[5])
return boxs, transs, texts
class OCR(baseocr):
def langmap(self):
return {"zh": "zh-CHS", "cht": "zh-CHT"}
def ocr(self, imagebinary):
boxs, transs, texts = doocr(imagebinary, self.srclang, self.tgtlang)
if self.config["Translate"]:
return {"box": boxs, "text": transs, "isocrtranslate": True}
else:
return {"box": boxs, "text": texts}