2021-06-03 02:20:42 +00:00
|
|
|
#pragma once
|
|
|
|
|
2022-09-28 13:29:29 +00:00
|
|
|
#include "config.h"
|
2021-07-30 13:30:30 +00:00
|
|
|
|
|
|
|
#if USE_NLP
|
|
|
|
|
2021-10-02 07:13:14 +00:00
|
|
|
#include <base/types.h>
|
2021-06-03 02:20:42 +00:00
|
|
|
#include <Poco/Util/Application.h>
|
|
|
|
|
|
|
|
#include <memory>
|
|
|
|
#include <mutex>
|
|
|
|
#include <string_view>
|
|
|
|
#include <vector>
|
|
|
|
#include <unordered_map>
|
|
|
|
|
|
|
|
namespace DB
|
|
|
|
{
|
|
|
|
|
|
|
|
class ISynonymsExtension
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
using Synset = std::vector<String>;
|
2021-06-19 18:52:09 +00:00
|
|
|
|
2021-07-30 13:30:30 +00:00
|
|
|
virtual const Synset * getSynonyms(std::string_view token) const = 0;
|
2021-06-03 02:20:42 +00:00
|
|
|
|
|
|
|
virtual ~ISynonymsExtension() = default;
|
|
|
|
};
|
|
|
|
|
|
|
|
class SynonymsExtensions
|
|
|
|
{
|
2021-06-19 18:52:09 +00:00
|
|
|
public:
|
2021-06-03 02:20:42 +00:00
|
|
|
using ExtPtr = std::shared_ptr<ISynonymsExtension>;
|
2021-06-19 18:52:09 +00:00
|
|
|
|
2021-06-20 12:31:07 +00:00
|
|
|
explicit SynonymsExtensions(const Poco::Util::AbstractConfiguration & config);
|
2021-06-03 02:20:42 +00:00
|
|
|
|
|
|
|
ExtPtr getExtension(const String & name);
|
|
|
|
|
|
|
|
private:
|
|
|
|
struct Info
|
|
|
|
{
|
|
|
|
String path;
|
|
|
|
String type;
|
|
|
|
};
|
2021-06-19 18:52:09 +00:00
|
|
|
|
2021-06-03 02:20:42 +00:00
|
|
|
using ExtContainer = std::unordered_map<String, ExtPtr>;
|
|
|
|
using InfoContainer = std::unordered_map<String, Info>;
|
|
|
|
|
|
|
|
std::mutex mutex;
|
2021-06-19 18:52:09 +00:00
|
|
|
ExtContainer extensions;
|
2021-06-03 02:20:42 +00:00
|
|
|
InfoContainer info;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
2021-07-30 13:30:30 +00:00
|
|
|
|
|
|
|
#endif
|