2020-12-30 14:42:04 +08:00
|
|
|
#ifndef CHINESESEGMENTATION_H
|
|
|
|
#define CHINESESEGMENTATION_H
|
|
|
|
|
|
|
|
#include "libchinese-segmentation_global.h"
|
2020-12-31 21:14:13 +08:00
|
|
|
#include "cppjieba/Jieba.hpp"
|
|
|
|
//#include "Logging.hpp"
|
|
|
|
//#include "LocalVector.hpp"
|
|
|
|
//#include "cppjieba/QuerySegment.hpp"
|
|
|
|
#include "cppjieba/KeywordExtractor.hpp"
|
|
|
|
#include <QVector>
|
|
|
|
#include <QString>
|
|
|
|
#include <QDebug>
|
|
|
|
|
|
|
|
struct SKeyWord{
|
|
|
|
std::string word;
|
|
|
|
QVector<size_t> offsets;
|
|
|
|
double weight;
|
|
|
|
};
|
2020-12-30 14:42:04 +08:00
|
|
|
|
|
|
|
class CHINESESEGMENTATION_EXPORT ChineseSegmentation
|
|
|
|
{
|
|
|
|
public:
|
2021-01-04 14:35:04 +08:00
|
|
|
static ChineseSegmentation *getInstance();
|
|
|
|
QVector<SKeyWord> callSegement(QString *str);
|
|
|
|
void convert(std::vector<cppjieba::KeywordExtractor::Word>& keywordres,QVector<SKeyWord>& kw);
|
2020-12-31 21:14:13 +08:00
|
|
|
private:
|
2021-01-04 14:35:04 +08:00
|
|
|
cppjieba::Jieba *m_jieba;
|
|
|
|
explicit ChineseSegmentation();
|
|
|
|
~ChineseSegmentation();
|
2020-12-30 14:42:04 +08:00
|
|
|
};
|
|
|
|
|
|
|
|
#endif // CHINESESEGMENTATION_H
|