mirror of
https://github.com/HIllya51/LunaTranslator.git
synced 2025-01-13 23:53:54 +08:00
faster
This commit is contained in:
parent
a6043cf547
commit
c0064dcc84
3
.gitmodules
vendored
3
.gitmodules
vendored
@ -7,3 +7,6 @@
|
||||
[submodule "plugins/libs/miniaudio"]
|
||||
path = plugins/libs/miniaudio
|
||||
url = https://github.com/HIllya51/miniaudio
|
||||
[submodule "plugins/libs/rapidfuzz-cpp"]
|
||||
path = plugins/libs/rapidfuzz-cpp
|
||||
url = https://github.com/rapidfuzz/rapidfuzz-cpp
|
||||
|
@ -10,6 +10,7 @@ include_directories(${CMAKE_CURRENT_LIST_DIR}/Detours-4.0.1/include)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/wil/include)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/miniaudio)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/tinymp3)
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/rapidfuzz-cpp)
|
||||
|
||||
include_directories(${CMAKE_CURRENT_LIST_DIR}/webview2/Microsoft.Web.WebView2.1.0.2535.41/build/native/include)
|
||||
|
||||
|
1
plugins/libs/rapidfuzz-cpp
Submodule
1
plugins/libs/rapidfuzz-cpp
Submodule
@ -0,0 +1 @@
|
||||
Subproject commit 10426d24cd7479df0fe8c78b17877e756e1c3cd5
|
@ -1,5 +1,7 @@
|
||||
#pragma once
|
||||
#define _CRT_SECURE_NO_WARNINGS
|
||||
#define NOMINMAX
|
||||
|
||||
#include <windows.h>
|
||||
#include <Shobjidl.h>
|
||||
#include <malloc.h>
|
||||
@ -14,6 +16,7 @@
|
||||
#include <iostream>
|
||||
#include <string>
|
||||
#include <vector>
|
||||
#include <algorithm>
|
||||
#include <functional>
|
||||
#include <fstream>
|
||||
#include <filesystem>
|
||||
|
@ -554,7 +554,7 @@ int CreateProcessEndExt(NtleaProcess *process, PROCESS_INFORMATION const *proinf
|
||||
OUTPUT_DEBUG_STRING_INFO *dbginfo = (OUTPUT_DEBUG_STRING_INFO *)&dbgevent.u.DebugString;
|
||||
unsigned char *msg = (unsigned char *)dbgstrbuf;
|
||||
// read debug string from debugee process :
|
||||
ReadProcessMemory(proinfo->hProcess, dbginfo->lpDebugStringData, msg, min(1024, dbginfo->nDebugStringLength), NULL);
|
||||
ReadProcessMemory(proinfo->hProcess, dbginfo->lpDebugStringData, msg, std::min(1024, (int)dbginfo->nDebugStringLength), NULL);
|
||||
fprintf(stderr, dbginfo->fUnicode ? "%S\n" : "%s\n", msg);
|
||||
ContinueDebugEvent(dbgevent.dwProcessId, dbgevent.dwThreadId, DBG_CONTINUE);
|
||||
}
|
||||
|
@ -89,10 +89,10 @@ ocrres OCR(void *ptr, size_t size, wchar_t *lang, wchar_t *space, int *num)
|
||||
start = false;
|
||||
xx += word.Text();
|
||||
auto &rect = word.BoundingRect();
|
||||
x1 = min(rect.X, x1);
|
||||
x2 = max(x2, rect.X + rect.Width);
|
||||
y1 = min(rect.Y, y1);
|
||||
y2 = max(y2, rect.Y + rect.Height);
|
||||
x1 = std::min((unsigned int)rect.X, x1);
|
||||
x2 = std::max(x2, (unsigned int)(rect.X + rect.Width));
|
||||
y1 = std::min((unsigned int)rect.Y, y1);
|
||||
y2 = std::max(y2, (unsigned int)(rect.Y + rect.Height));
|
||||
}
|
||||
ys.push_back(y1);
|
||||
xs.push_back(x1);
|
||||
|
@ -157,16 +157,18 @@ size_t lev_u_edit_distance(size_t len1, const wchar_t *string1,
|
||||
free(row);
|
||||
return i;
|
||||
}
|
||||
|
||||
#include <rapidfuzz/distance.hpp>
|
||||
size_t levenshtein_distance(size_t len1, const wchar_t *string1,
|
||||
size_t len2, const wchar_t *string2)
|
||||
{
|
||||
return lev_u_edit_distance(len1, string1, len2, string2, 0);
|
||||
return rapidfuzz::levenshtein_distance(std::wstring_view(string1, len1), std::wstring_view(string2, len2));
|
||||
// return lev_u_edit_distance(len1, string1, len2, string2, 0);
|
||||
}
|
||||
double levenshtein_ratio(size_t len1, const wchar_t *string1,
|
||||
size_t len2, const wchar_t *string2)
|
||||
{
|
||||
auto ldist = lev_u_edit_distance(len1, string1, len2, string2, 1);
|
||||
// auto ldist = lev_u_edit_distance(len1, string1, len2, string2, 1);
|
||||
auto ldist = levenshtein_distance(len1, string1, len2, string2);
|
||||
auto lensum = len1 + len2;
|
||||
if (lensum == 0)
|
||||
return 0;
|
||||
|
Loading…
x
Reference in New Issue
Block a user