Minor fixes

This commit is contained in:
Nikolay Degterinsky 2021-06-20 12:31:07 +00:00
parent 8cb25c5757
commit 00154d3163
7 changed files with 23 additions and 15 deletions

View File

@ -236,5 +236,6 @@ if (NOT EXTERNAL_BOOST_FOUND)
add_library (_boost_graph ${SRCS_GRAPH})
add_library (boost::graph ALIAS _boost_graph)
target_include_directories (_boost_graph PRIVATE ${LIBRARY_DIR})
target_link_libraries(_boost_graph PRIVATE _boost_regex)
endif ()

View File

@ -4,7 +4,7 @@
#include <Functions/FunctionHelpers.h>
#include <Functions/IFunction.h>
#include <Interpreters/Context.h>
#include <Interpreters/Lemmatizers.cpp>
#include <Interpreters/Lemmatizers.h>
namespace DB
{
@ -62,7 +62,7 @@ private:
Lemmatizers & lemmatizers;
public:
FunctionLemmatize(Lemmatizers & lemmatizers_)
explicit FunctionLemmatize(Lemmatizers & lemmatizers_)
: lemmatizers(lemmatizers_) {}
String getName() const override { return name; }

View File

@ -33,7 +33,7 @@ private:
SynonymsExtensions & extensions;
public:
FunctionSynonyms(SynonymsExtensions & extensions_)
explicit FunctionSynonyms(SynonymsExtensions & extensions_)
: extensions(extensions_) {}
String getName() const override { return name; }
@ -92,7 +92,7 @@ public:
{
std::string_view word(reinterpret_cast<const char *>(data.data() + offsets[i - 1]), offsets[i] - offsets[i - 1] - 1);
auto synset = extension->getSynonyms(word);
const auto * synset = extension->getSynonyms(word);
if (synset)
{

View File

@ -15,17 +15,15 @@ namespace ErrorCodes
}
class Lemmatizer
class Lemmatizer : public ILemmatizer
{
private:
RdrLemmatizer lemmatizer;
public:
using TokenPtr = std::shared_ptr<char []>;
explicit Lemmatizer(const String & path) : lemmatizer(path.data()) {}
Lemmatizer(const String & path) : lemmatizer(path.data()) {}
TokenPtr lemmatize(const char * token)
TokenPtr lemmatize(const char * token) override
{
return TokenPtr(lemmatizer.Lemmatize(token));
}

View File

@ -9,12 +9,21 @@
namespace DB
{
class Lemmatizer;
class ILemmatizer
{
public:
using TokenPtr = std::shared_ptr<char []>;
virtual TokenPtr lemmatize(const char * token) = 0;
virtual ~ILemmatizer() = default;
};
class Lemmatizers
{
public:
using LemmPtr = std::shared_ptr<Lemmatizer>;
using LemmPtr = std::shared_ptr<ILemmatizer>;
private:
std::mutex mutex;
@ -22,7 +31,7 @@ private:
std::unordered_map<String, String> paths;
public:
Lemmatizers(const Poco::Util::AbstractConfiguration & config);
explicit Lemmatizers(const Poco::Util::AbstractConfiguration & config);
LemmPtr getLemmatizer(const String & name);
};

View File

@ -27,7 +27,7 @@ private:
LookupTable table;
public:
PlainSynonymsExtension(const String & path)
explicit PlainSynonymsExtension(const String & path)
{
std::ifstream file(path);
if (!file.is_open())
@ -66,7 +66,7 @@ private:
wnb::wordnet wn;
public:
WordnetSynonymsExtension(const String & path) : wn(path) {}
explicit WordnetSynonymsExtension(const String & path) : wn(path) {}
const Synset * getSynonyms(const std::string_view & token) const override
{

View File

@ -27,7 +27,7 @@ class SynonymsExtensions
public:
using ExtPtr = std::shared_ptr<ISynonymsExtension>;
SynonymsExtensions(const Poco::Util::AbstractConfiguration & config);
explicit SynonymsExtensions(const Poco::Util::AbstractConfiguration & config);
ExtPtr getExtension(const String & name);