<commit_before>#include <Core/Resources/Resources.hpp>

#include <algorithm>
#include <cpplocate/cpplocate.h>

namespace Ra {
namespace Core {
namespace Resources {
std::string getRadiumResourcesDir() {
    auto libraryPath =
        cpplocate::getLibraryPath( reinterpret_cast<void*>( getRadiumResourcesDir ) );
    std::replace(libraryPath.begin(), libraryPath.end(), '\\', '/');
    auto libraryDir  = libraryPath.substr( 0, libraryPath.find_last_of( '/' ) );
    auto baseDir     = libraryDir.substr( 0, libraryDir.find_last_of( '/' ) + 1 );

    return baseDir + "Resources/";
}

std::string getRadiumPluginsDir() {
    auto libraryPath = cpplocate::getLibraryPath( reinterpret_cast<void*>( getRadiumPluginsDir ) );
    std::replace(libraryPath.begin(), libraryPath.end(), '\\', '/');
    auto libraryDir  = libraryPath.substr( 0, libraryPath.find_last_of( '/' ) );
    auto baseDir     = libraryDir.substr( 0, libraryDir.find_last_of( '/' ) + 1 );

    return baseDir + "Plugins/lib/";
}

std::string getBaseDir() {
    return cpplocate::getModulePath();
}

ResourcesLocator::ResourcesLocator( void* symbol, const std::string& offset ) : m_basePath{""} {
    auto libraryPath = cpplocate::getLibraryPath( symbol );
    std::replace(libraryPath.begin(), libraryPath.end(), '\\', '/');
    auto libraryDir  = libraryPath.substr( 0, libraryPath.find_last_of( '/' ) );
    m_basePath       = libraryDir + offset;
}
const std::string& ResourcesLocator::getBasePath() {
    return m_basePath;
}
} // namespace Resources
} // namespace Core
} // namespace Ra
<commit_msg>Resource locator update to remove duplicated code.<commit_after>#include <Core/Resources/Resources.hpp>

#include <Core/Utils/Log.hpp>
#include <algorithm>
#include <cpplocate/cpplocate.h>

namespace Ra {
namespace Core {
namespace Resources {

std::string searchPath( std::string pattern, std::string offset, void* libSymbol ) {
    std::string baseDir = cpplocate::locatePath( pattern, offset, libSymbol );
    std::replace( baseDir.begin(), baseDir.end(), '\\', '/' );
    int nup = 0;
    while ( baseDir.rfind( "../", baseDir.size() - 1 - 3 * nup ) != std::string::npos )
    {
        ++nup;
    }
    baseDir = baseDir.substr( 0, baseDir.size() - 3 * nup - 1 );
    while ( nup-- )
    {
        baseDir = baseDir.substr( 0, baseDir.find_last_of( '/' ) + 1 );
    }
    return baseDir;
}

std::string getRadiumResourcesDir() {
    const std::string baseDir = searchPath(
        "Resources/Shaders", "../..", reinterpret_cast<void*>( getRadiumResourcesDir ) );
    return baseDir + "Resources/";
}

std::string getRadiumPluginsDir() {
    const std::string baseDir =
        searchPath( "Plugins/lib", "../../..", reinterpret_cast<void*>( getRadiumPluginsDir ) );
    return baseDir + "Plugins/lib/";
}

std::string getBaseDir() {
    return cpplocate::getModulePath();
}

ResourcesLocator::ResourcesLocator( void* symbol, const std::string& offset ) : m_basePath{""} {
    m_basePath = searchPath( "/", "", symbol ) + offset;
}
const std::string& ResourcesLocator::getBasePath() {
    return m_basePath;
}
} // namespace Resources
} // namespace Core
} // namespace Ra

{'fraction_non_alphanumeric': 0.16142357801080395, 'fraction_numerical': 0.004766444232602479, 'mean_word_length': 3.8806201550387596, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7465111', 'n_tokens_mistral': 1018, 'n_tokens_neox': 1003, 'n_words': 208}