Artikash / Textractor

Extracts text from video games and visual novels. Highly extensible.
GNU General Public License v3.0
2.01k stars 201 forks source link

Is it possible to ask you to build already ready to work extension for textractor? I'm a complete noob in compiling :( #1119

Open rasbayri opened 12 months ago

rasbayri commented 12 months ago
          Also fixable with this simple extension:
#include "Extension.h"
#include <mutex>

bool ProcessSentence(std::wstring& sentence, SentenceInfo sentenceInfo)
{
if (sentenceInfo["current select"] == 0 || sentenceInfo["text number"] == 0) return false;

static std::mutex m;
static std::wstring previous;

std::wregex reg (L"\\s");
sentence = std::regex_replace(sentence, reg, L""); //Removing all whitespace from the sentence, text does not always match otherwise

m.lock(); //lock mutex before using previous to prevent race conditions
size_t found = sentence.find(previous); //Searches for an exact match in order to avoid unwanted behaviour

if (found != -1) //Case "sentence" matches "previous"
{
sentence.erase(0, previous.length());
previous += sentence;
m.unlock();
return true;
}
else
{
previous = sentence;
m.unlock();
return true; //Returning true in order to keep the removal of the whitespace.
} //Keeps all the sentences consistent, always not needed
}

Originally posted by @Artikash in https://github.com/Artikash/Textractor/issues/324#issuecomment-604948535

shoaibshakeel381 commented 11 months ago

Compiled version Issue 1119.zip