forked from Public-Mirror/Textractor
using new api
This commit is contained in:
parent
e826801c87
commit
146afdc926
@ -116,7 +116,7 @@ std::wstring Translate(const std::wstring& text, std::wstring translateFrom, std
|
||||
|
||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
{
|
||||
if (sentenceInfo["hook address"] == -1) return false;
|
||||
if (sentenceInfo["text number"] == 0) return false;
|
||||
|
||||
static RateLimiter rateLimiter(30, 60 * 1000);
|
||||
|
||||
|
@ -18,7 +18,7 @@ struct SentenceInfo
|
||||
throw;
|
||||
}
|
||||
|
||||
inline static InfoForExtension DUMMY[2] = { { "hook address", 0 } };
|
||||
inline static InfoForExtension DUMMY[2] = { { "text number", 1 } };
|
||||
};
|
||||
|
||||
struct SKIP {};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
{
|
||||
if (sentenceInfo["hook address"] == -1) return false;
|
||||
if (sentenceInfo["text number"] == 0) return false;
|
||||
sentence += L"\n";
|
||||
return true;
|
||||
}
|
||||
|
@ -129,7 +129,7 @@ std::wstring GetTranslationUri(const std::wstring& text, unsigned TKK)
|
||||
|
||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
{
|
||||
if (sentenceInfo["hook address"] == -1) return false;
|
||||
if (sentenceInfo["text number"] == 0) return false;
|
||||
|
||||
static std::atomic<HINTERNET> internet = NULL;
|
||||
if (!internet) internet = WinHttpOpen(L"Mozilla/5.0 Textractor", WINHTTP_ACCESS_TYPE_DEFAULT_PROXY, NULL, NULL, 0);
|
||||
|
@ -64,7 +64,7 @@ BOOL WINAPI DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved
|
||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
{
|
||||
std::shared_lock l(m);
|
||||
if (window == nullptr || sentenceInfo["hook address"] == -1) return false;
|
||||
if (window == nullptr || sentenceInfo["text number"] == 0) return false;
|
||||
sentence = std::regex_replace(sentence, regex, L"");
|
||||
return true;
|
||||
}
|
||||
|
@ -45,7 +45,7 @@ remove:
|
||||
|
||||
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
|
||||
{
|
||||
if (sentenceInfo["hook address"] == -1) return false;
|
||||
if (sentenceInfo["text number"] == 0) return false;
|
||||
RemoveRepeatedChars(sentence);
|
||||
RemoveCyclicRepeats(sentence);
|
||||
return true;
|
||||
|
@ -15,9 +15,9 @@ public:
|
||||
void Put(std::wstring original, std::wstring replacement)
|
||||
{
|
||||
Node* current = &root;
|
||||
for (auto c : original)
|
||||
if (Ignore(c));
|
||||
else if (auto& next = current->next[c]) current = next.get();
|
||||
for (auto ch : original)
|
||||
if (Ignore(ch));
|
||||
else if (auto& next = current->next[ch]) current = next.get();
|
||||
else current = (next = std::make_unique<Node>()).get();
|
||||
if (current != &root) current->value = replacement;
|
||||
}
|
||||
@ -26,17 +26,17 @@ public:
|
||||
{
|
||||
int length = 0;
|
||||
Node* current = &root;
|
||||
for (auto c : text)
|
||||
if (Ignore(c)) ++length;
|
||||
else if (auto& next = current->next[c]) ++length, current = next.get();
|
||||
for (auto ch : text)
|
||||
if (Ignore(ch)) ++length;
|
||||
else if (auto& next = current->next[ch]) ++length, current = next.get();
|
||||
else break;
|
||||
return { length, current->value };
|
||||
}
|
||||
|
||||
private:
|
||||
static bool Ignore(wchar_t c)
|
||||
static bool Ignore(wchar_t ch)
|
||||
{
|
||||
return c <= 0x20 || std::iswspace(c);
|
||||
return ch <= 0x20 || std::iswspace(ch);
|
||||
}
|
||||
|
||||
struct Node
|
||||
|
Loading…
x
Reference in New Issue
Block a user