Merge remote-tracking branch 'Blu3train/extension_remove_repeated_leading_sentence'

This commit is contained in:
Chenx221 2024-09-05 12:39:55 +08:00
commit 80bf2f0039
3 changed files with 29 additions and 0 deletions

View File

@ -55,6 +55,7 @@ foreach ($language in @{
"Regex Replacer", "Regex Replacer",
"Regex Replacer Translated Text", "Regex Replacer Translated Text",
"Remove Repeated Characters", "Remove Repeated Characters",
"Remove Repeated Leading Sentence",
"Remove Repeated Phrases", "Remove Repeated Phrases",
"Remove Repeated Phrases 2", "Remove Repeated Phrases 2",
"Remove 30 Repeated Sentences", "Remove 30 Repeated Sentences",

View File

@ -14,6 +14,7 @@ add_library(Regex\ Filter MODULE regexfilter.cpp extensionimpl.cpp)
add_library(Regex\ Replacer MODULE regexreplacer.cpp extensionimpl.cpp) add_library(Regex\ Replacer MODULE regexreplacer.cpp extensionimpl.cpp)
add_library(Regex\ Replacer\ Translated\ Text MODULE regexreplacertranslatedtext.cpp extensionimpl.cpp) add_library(Regex\ Replacer\ Translated\ Text MODULE regexreplacertranslatedtext.cpp extensionimpl.cpp)
add_library(Remove\ Repeated\ Characters MODULE removerepeatchar.cpp extensionimpl.cpp) add_library(Remove\ Repeated\ Characters MODULE removerepeatchar.cpp extensionimpl.cpp)
add_library(Remove\ Repeated\ Leading\ Sentence MODULE removerepeatedleadingsentence.cpp extensionimpl.cpp)
add_library(Remove\ Repeated\ Phrases MODULE removerepeatphrase.cpp extensionimpl.cpp) add_library(Remove\ Repeated\ Phrases MODULE removerepeatphrase.cpp extensionimpl.cpp)
add_library(Remove\ Repeated\ Phrases\ 2 MODULE removerepeatphrase2.cpp extensionimpl.cpp) add_library(Remove\ Repeated\ Phrases\ 2 MODULE removerepeatphrase2.cpp extensionimpl.cpp)
add_library(Remove\ 30\ Repeated\ Sentences MODULE removerepeatsentence.cpp extensionimpl.cpp) add_library(Remove\ 30\ Repeated\ Sentences MODULE removerepeatsentence.cpp extensionimpl.cpp)
@ -37,6 +38,7 @@ target_precompile_headers(Regex\ Filter REUSE_FROM pch)
target_precompile_headers(Regex\ Replacer REUSE_FROM pch) target_precompile_headers(Regex\ Replacer REUSE_FROM pch)
target_precompile_headers(Regex\ Replacer\ Translated\ Text REUSE_FROM pch) target_precompile_headers(Regex\ Replacer\ Translated\ Text REUSE_FROM pch)
target_precompile_headers(Remove\ Repeated\ Characters REUSE_FROM pch) target_precompile_headers(Remove\ Repeated\ Characters REUSE_FROM pch)
target_precompile_headers(Remove\ Repeated\ Leading\ Sentence REUSE_FROM pch)
target_precompile_headers(Remove\ Repeated\ Phrases REUSE_FROM pch) target_precompile_headers(Remove\ Repeated\ Phrases REUSE_FROM pch)
target_precompile_headers(Remove\ Repeated\ Phrases\ 2 REUSE_FROM pch) target_precompile_headers(Remove\ Repeated\ Phrases\ 2 REUSE_FROM pch)
target_precompile_headers(Remove\ 30\ Repeated\ Sentences REUSE_FROM pch) target_precompile_headers(Remove\ 30\ Repeated\ Sentences REUSE_FROM pch)

View File

@ -0,0 +1,26 @@
#include "extension.h"
bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
{
if (!sentenceInfo["current select"] || sentenceInfo["text number"] == 0) return false;
static std::wstring prevSentence;
std::wstring checkSentence = prevSentence;
prevSentence = sentence;
if (sentence.substr(0, checkSentence.size()) == checkSentence)
{
auto Ltrim = [](std::wstring& text)
{
text.erase(text.begin(), std::find_if_not(text.begin(), text.end(), iswspace));
};
sentence = sentence.substr(checkSentence.size());
Ltrim(sentence);
return true;
}
return false;
}