From 5c29d2b66efc482ba2964737fa2006656db7b1a9 Mon Sep 17 00:00:00 2001 From: Wang Yu Date: Tue, 14 Jan 2025 11:00:33 +0800 Subject: [PATCH 1/3] chore: add dbus adaptor classes for grand search Add dbus adaptor classes to handle communication between different components. Log: add dbus adaptor classes for grand search --- src/configs/dbus/GrandSearchAdaptor.cpp | 43 +++++++ src/configs/dbus/GrandSearchAdaptor.h | 51 +++++++++ src/configs/dbus/GrandSearchDaemonAdaptor.cpp | 107 ++++++++++++++++++ src/configs/dbus/GrandSearchDaemonAdaptor.h | 98 ++++++++++++++++ src/configs/dbus/QueryLangAdaptor.cpp | 45 ++++++++ src/configs/dbus/QueryLangAdaptor.h | 48 ++++++++ src/configs/dbus/SearchPluginAdaptor.cpp | 53 +++++++++ src/configs/dbus/SearchPluginAdaptor.h | 54 +++++++++ src/configs/dbus/VectorIndexAdaptor.cpp | 83 ++++++++++++++ src/configs/dbus/VectorIndexAdaptor.h | 88 ++++++++++++++ 10 files changed, 670 insertions(+) create mode 100644 src/configs/dbus/GrandSearchAdaptor.cpp create mode 100644 src/configs/dbus/GrandSearchAdaptor.h create mode 100644 src/configs/dbus/GrandSearchDaemonAdaptor.cpp create mode 100644 src/configs/dbus/GrandSearchDaemonAdaptor.h create mode 100644 src/configs/dbus/QueryLangAdaptor.cpp create mode 100644 src/configs/dbus/QueryLangAdaptor.h create mode 100644 src/configs/dbus/SearchPluginAdaptor.cpp create mode 100644 src/configs/dbus/SearchPluginAdaptor.h create mode 100644 src/configs/dbus/VectorIndexAdaptor.cpp create mode 100644 src/configs/dbus/VectorIndexAdaptor.h diff --git a/src/configs/dbus/GrandSearchAdaptor.cpp b/src/configs/dbus/GrandSearchAdaptor.cpp new file mode 100644 index 0000000..58c0cd2 --- /dev/null +++ b/src/configs/dbus/GrandSearchAdaptor.cpp @@ -0,0 +1,43 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "GrandSearchAdaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class GrandSearchAdaptor + */ + +GrandSearchAdaptor::GrandSearchAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +GrandSearchAdaptor::~GrandSearchAdaptor() +{ + // destructor +} + +bool GrandSearchAdaptor::IsVisible() +{ + // handle method call com.deepin.dde.GrandSearch.IsVisible + bool out0; + QMetaObject::invokeMethod(parent(), "IsVisible", Q_RETURN_ARG(bool, out0)); + return out0; +} + +void GrandSearchAdaptor::SetVisible(bool visible) +{ + // handle method call com.deepin.dde.GrandSearch.SetVisible + QMetaObject::invokeMethod(parent(), "SetVisible", Q_ARG(bool, visible)); +} + diff --git a/src/configs/dbus/GrandSearchAdaptor.h b/src/configs/dbus/GrandSearchAdaptor.h new file mode 100644 index 0000000..06afe0d --- /dev/null +++ b/src/configs/dbus/GrandSearchAdaptor.h @@ -0,0 +1,51 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef GRANDSEARCHADAPTOR_H +#define GRANDSEARCHADAPTOR_H + +#include +#include +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface com.deepin.dde.GrandSearch + */ +class GrandSearchAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.deepin.dde.GrandSearch") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + GrandSearchAdaptor(QObject *parent); + virtual ~GrandSearchAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + bool IsVisible(); + void SetVisible(bool visible); +Q_SIGNALS: // SIGNALS + void VisibleChanged(bool vidible); +}; + +#endif diff --git a/src/configs/dbus/GrandSearchDaemonAdaptor.cpp b/src/configs/dbus/GrandSearchDaemonAdaptor.cpp new file mode 100644 index 0000000..c70434f --- /dev/null +++ b/src/configs/dbus/GrandSearchDaemonAdaptor.cpp @@ -0,0 +1,107 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "GrandSearchDaemonAdaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class GrandSearchDaemonAdaptor + */ + +GrandSearchDaemonAdaptor::GrandSearchDaemonAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +GrandSearchDaemonAdaptor::~GrandSearchDaemonAdaptor() +{ + // destructor +} + +QVariantMap GrandSearchDaemonAdaptor::Configuration() +{ + // handle method call org.deepin.dde.GrandSearchDaemon.Configuration + QVariantMap out0; + QMetaObject::invokeMethod(parent(), "Configuration", Q_RETURN_ARG(QVariantMap, out0)); + return out0; +} + +bool GrandSearchDaemonAdaptor::Configure(const QVariantMap &in0) +{ + // handle method call org.deepin.dde.GrandSearchDaemon.Configure + bool out0; + QMetaObject::invokeMethod(parent(), "Configure", Q_RETURN_ARG(bool, out0), Q_ARG(QVariantMap, in0)); + return out0; +} + +QVariantMap GrandSearchDaemonAdaptor::FeedBackStrategy() +{ + // handle method call org.deepin.dde.GrandSearchDaemon.FeedBackStrategy + QVariantMap out0; + QMetaObject::invokeMethod(parent(), "FeedBackStrategy", Q_RETURN_ARG(QVariantMap, out0)); + return out0; +} + +bool GrandSearchDaemonAdaptor::KeepAlive(const QString &session) +{ + // handle method call org.deepin.dde.GrandSearchDaemon.KeepAlive + bool out0; + QMetaObject::invokeMethod(parent(), "KeepAlive", Q_RETURN_ARG(bool, out0), Q_ARG(QString, session)); + return out0; +} + +QByteArray GrandSearchDaemonAdaptor::MatchedBuffer(const QString &session) +{ + // handle method call org.deepin.dde.GrandSearchDaemon.MatchedBuffer + QByteArray out0; + QMetaObject::invokeMethod(parent(), "MatchedBuffer", Q_RETURN_ARG(QByteArray, out0), Q_ARG(QString, session)); + return out0; +} + +QByteArray GrandSearchDaemonAdaptor::MatchedResults(const QString &session) +{ + // handle method call org.deepin.dde.GrandSearchDaemon.MatchedResults + QByteArray out0; + QMetaObject::invokeMethod(parent(), "MatchedResults", Q_RETURN_ARG(QByteArray, out0), Q_ARG(QString, session)); + return out0; +} + +bool GrandSearchDaemonAdaptor::OpenWithPlugin(const QString &searcher, const QString &item) +{ + // handle method call org.deepin.dde.GrandSearchDaemon.OpenWithPlugin + bool out0; + QMetaObject::invokeMethod(parent(), "OpenWithPlugin", Q_RETURN_ARG(bool, out0), Q_ARG(QString, searcher), Q_ARG(QString, item)); + return out0; +} + +bool GrandSearchDaemonAdaptor::Search(const QString &session, const QString &key) +{ + // handle method call org.deepin.dde.GrandSearchDaemon.Search + bool out0; + QMetaObject::invokeMethod(parent(), "Search", Q_RETURN_ARG(bool, out0), Q_ARG(QString, session), Q_ARG(QString, key)); + return out0; +} + +bool GrandSearchDaemonAdaptor::SetFeedBackStrategy(const QVariantMap &in0) +{ + // handle method call org.deepin.dde.GrandSearchDaemon.SetFeedBackStrategy + bool out0; + QMetaObject::invokeMethod(parent(), "SetFeedBackStrategy", Q_RETURN_ARG(bool, out0), Q_ARG(QVariantMap, in0)); + return out0; +} + +void GrandSearchDaemonAdaptor::Terminate() +{ + // handle method call org.deepin.dde.GrandSearchDaemon.Terminate + QMetaObject::invokeMethod(parent(), "Terminate"); +} + diff --git a/src/configs/dbus/GrandSearchDaemonAdaptor.h b/src/configs/dbus/GrandSearchDaemonAdaptor.h new file mode 100644 index 0000000..2d4a544 --- /dev/null +++ b/src/configs/dbus/GrandSearchDaemonAdaptor.h @@ -0,0 +1,98 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef GRANDSEARCHDAEMONADAPTOR_H +#define GRANDSEARCHDAEMONADAPTOR_H + +#include +#include +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface org.deepin.dde.GrandSearchDaemon + */ +class GrandSearchDaemonAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.deepin.dde.GrandSearchDaemon") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + GrandSearchDaemonAdaptor(QObject *parent); + virtual ~GrandSearchDaemonAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + QVariantMap Configuration(); + bool Configure(const QVariantMap &in0); + QVariantMap FeedBackStrategy(); + bool KeepAlive(const QString &session); + QByteArray MatchedBuffer(const QString &session); + QByteArray MatchedResults(const QString &session); + bool OpenWithPlugin(const QString &searcher, const QString &item); + bool Search(const QString &session, const QString &key); + bool SetFeedBackStrategy(const QVariantMap &in0); + void Terminate(); +Q_SIGNALS: // SIGNALS + void Matched(const QString &session); + void SearchCompleted(const QString &session); +}; + +#endif diff --git a/src/configs/dbus/QueryLangAdaptor.cpp b/src/configs/dbus/QueryLangAdaptor.cpp new file mode 100644 index 0000000..8c366ad --- /dev/null +++ b/src/configs/dbus/QueryLangAdaptor.cpp @@ -0,0 +1,45 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "QueryLangAdaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class QueryLangAdaptor + */ + +QueryLangAdaptor::QueryLangAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +QueryLangAdaptor::~QueryLangAdaptor() +{ + // destructor +} + +bool QueryLangAdaptor::Enable() +{ + // handle method call org.deepin.ai.daemon.QueryLang.Enable + bool out0; + QMetaObject::invokeMethod(parent(), "Enable", Q_RETURN_ARG(bool, out0)); + return out0; +} + +QString QueryLangAdaptor::Query(const QString &content) +{ + // handle method call org.deepin.ai.daemon.QueryLang.Query + QString out0; + QMetaObject::invokeMethod(parent(), "Query", Q_RETURN_ARG(QString, out0), Q_ARG(QString, content)); + return out0; +} + diff --git a/src/configs/dbus/QueryLangAdaptor.h b/src/configs/dbus/QueryLangAdaptor.h new file mode 100644 index 0000000..9f00696 --- /dev/null +++ b/src/configs/dbus/QueryLangAdaptor.h @@ -0,0 +1,48 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef QUERYLANGADAPTOR_H +#define QUERYLANGADAPTOR_H + +#include +#include +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface org.deepin.ai.daemon.QueryLang + */ +class QueryLangAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.deepin.ai.daemon.QueryLang") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + QueryLangAdaptor(QObject *parent); + virtual ~QueryLangAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + bool Enable(); + QString Query(const QString &content); +Q_SIGNALS: // SIGNALS +}; + +#endif diff --git a/src/configs/dbus/SearchPluginAdaptor.cpp b/src/configs/dbus/SearchPluginAdaptor.cpp new file mode 100644 index 0000000..fb06b3e --- /dev/null +++ b/src/configs/dbus/SearchPluginAdaptor.cpp @@ -0,0 +1,53 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "SearchPluginAdaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class SearchPluginAdaptor + */ + +SearchPluginAdaptor::SearchPluginAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +SearchPluginAdaptor::~SearchPluginAdaptor() +{ + // destructor +} + +bool SearchPluginAdaptor::Action(const QString &json) +{ + // handle method call com.deepin.dde.GrandSearch.SearchPlugin.Action + bool out0; + QMetaObject::invokeMethod(parent(), "Action", Q_RETURN_ARG(bool, out0), Q_ARG(QString, json)); + return out0; +} + +QString SearchPluginAdaptor::Search(const QString &json) +{ + // handle method call com.deepin.dde.GrandSearch.SearchPlugin.Search + QString out0; + QMetaObject::invokeMethod(parent(), "Search", Q_RETURN_ARG(QString, out0), Q_ARG(QString, json)); + return out0; +} + +bool SearchPluginAdaptor::Stop(const QString &json) +{ + // handle method call com.deepin.dde.GrandSearch.SearchPlugin.Stop + bool out0; + QMetaObject::invokeMethod(parent(), "Stop", Q_RETURN_ARG(bool, out0), Q_ARG(QString, json)); + return out0; +} + diff --git a/src/configs/dbus/SearchPluginAdaptor.h b/src/configs/dbus/SearchPluginAdaptor.h new file mode 100644 index 0000000..707b264 --- /dev/null +++ b/src/configs/dbus/SearchPluginAdaptor.h @@ -0,0 +1,54 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef SEARCHPLUGINADAPTOR_H +#define SEARCHPLUGINADAPTOR_H + +#include +#include +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface com.deepin.dde.GrandSearch.SearchPlugin + */ +class SearchPluginAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "com.deepin.dde.GrandSearch.SearchPlugin") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + SearchPluginAdaptor(QObject *parent); + virtual ~SearchPluginAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + bool Action(const QString &json); + QString Search(const QString &json); + bool Stop(const QString &json); +Q_SIGNALS: // SIGNALS +}; + +#endif diff --git a/src/configs/dbus/VectorIndexAdaptor.cpp b/src/configs/dbus/VectorIndexAdaptor.cpp new file mode 100644 index 0000000..4bc5271 --- /dev/null +++ b/src/configs/dbus/VectorIndexAdaptor.cpp @@ -0,0 +1,83 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#include "VectorIndexAdaptor.h" +#include +#include +#include +#include +#include +#include +#include + +/* + * Implementation of adaptor class VectorIndexAdaptor + */ + +VectorIndexAdaptor::VectorIndexAdaptor(QObject *parent) + : QDBusAbstractAdaptor(parent) +{ + // constructor + setAutoRelaySignals(true); +} + +VectorIndexAdaptor::~VectorIndexAdaptor() +{ + // destructor +} + +bool VectorIndexAdaptor::Create(const QString &appID, const QStringList &files) +{ + // handle method call org.deepin.ai.daemon.VectorIndex.Create + bool out0; + QMetaObject::invokeMethod(parent(), "Create", Q_RETURN_ARG(bool, out0), Q_ARG(QString, appID), Q_ARG(QStringList, files)); + return out0; +} + +bool VectorIndexAdaptor::Delete(const QString &appID, const QStringList &files) +{ + // handle method call org.deepin.ai.daemon.VectorIndex.Delete + bool out0; + QMetaObject::invokeMethod(parent(), "Delete", Q_RETURN_ARG(bool, out0), Q_ARG(QString, appID), Q_ARG(QStringList, files)); + return out0; +} + +QStringList VectorIndexAdaptor::DocFiles(const QString &appID) +{ + // handle method call org.deepin.ai.daemon.VectorIndex.DocFiles + QStringList out0; + QMetaObject::invokeMethod(parent(), "DocFiles", Q_RETURN_ARG(QStringList, out0), Q_ARG(QString, appID)); + return out0; +} + +bool VectorIndexAdaptor::Enable() +{ + // handle method call org.deepin.ai.daemon.VectorIndex.Enable + bool out0; + QMetaObject::invokeMethod(parent(), "Enable", Q_RETURN_ARG(bool, out0)); + return out0; +} + +QString VectorIndexAdaptor::Search(const QString &appID, const QString &query, int topK) +{ + // handle method call org.deepin.ai.daemon.VectorIndex.Search + QString out0; + QMetaObject::invokeMethod(parent(), "Search", Q_RETURN_ARG(QString, out0), Q_ARG(QString, appID), Q_ARG(QString, query), Q_ARG(int, topK)); + return out0; +} + +QString VectorIndexAdaptor::getAutoIndexStatus(const QString &appID) +{ + // handle method call org.deepin.ai.daemon.VectorIndex.getAutoIndexStatus + QString out0; + QMetaObject::invokeMethod(parent(), "getAutoIndexStatus", Q_RETURN_ARG(QString, out0), Q_ARG(QString, appID)); + return out0; +} + +void VectorIndexAdaptor::setAutoIndex(const QString &appID, bool on) +{ + // handle method call org.deepin.ai.daemon.VectorIndex.setAutoIndex + QMetaObject::invokeMethod(parent(), "setAutoIndex", Q_ARG(QString, appID), Q_ARG(bool, on)); +} + diff --git a/src/configs/dbus/VectorIndexAdaptor.h b/src/configs/dbus/VectorIndexAdaptor.h new file mode 100644 index 0000000..82f0d4c --- /dev/null +++ b/src/configs/dbus/VectorIndexAdaptor.h @@ -0,0 +1,88 @@ +// SPDX-FileCopyrightText: 2024 - 2025 UnionTech Software Technology Co., Ltd. +// +// SPDX-License-Identifier: GPL-3.0-or-later + +#ifndef VECTORINDEXADAPTOR_H +#define VECTORINDEXADAPTOR_H + +#include +#include +QT_BEGIN_NAMESPACE +class QByteArray; +template class QList; +template class QMap; +class QString; +class QStringList; +class QVariant; +QT_END_NAMESPACE + +/* + * Adaptor class for interface org.deepin.ai.daemon.VectorIndex + */ +class VectorIndexAdaptor: public QDBusAbstractAdaptor +{ + Q_OBJECT + Q_CLASSINFO("D-Bus Interface", "org.deepin.ai.daemon.VectorIndex") + Q_CLASSINFO("D-Bus Introspection", "" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" +" \n" + "") +public: + VectorIndexAdaptor(QObject *parent); + virtual ~VectorIndexAdaptor(); + +public: // PROPERTIES +public Q_SLOTS: // METHODS + bool Create(const QString &appID, const QStringList &files); + bool Delete(const QString &appID, const QStringList &files); + QStringList DocFiles(const QString &appID); + bool Enable(); + QString Search(const QString &appID, const QString &query, int topK); + QString getAutoIndexStatus(const QString &appID); + void setAutoIndex(const QString &appID, bool on); +Q_SIGNALS: // SIGNALS + void IndexDeleted(const QString &appID, const QStringList &files); + void IndexStatus(const QString &appID, const QStringList &files, int status); +}; + +#endif From 79823942872b9901770f0cf20e0891a67973f640 Mon Sep 17 00:00:00 2001 From: Zhang Yu Date: Tue, 14 Jan 2025 13:28:25 +0800 Subject: [PATCH 2/3] fix: update text Using ULLM toreplace UOS AI Large Model. Log: Bug: bug#300257 --- .../exhibition/matchresult/groupwidget.cpp | 6 +- .../intelligentretrievalwidget.cpp | 4 +- .../gui/searchconfig/llmwidget/llmwidget.cpp | 2 +- src/tools/semanticparser/semanticparser.h | 1 - translations/dde-grand-search.ts | 345 +++++++++++++++--- translations/dde-grand-search_zh_CN.ts | 30 +- 6 files changed, 320 insertions(+), 68 deletions(-) diff --git a/src/grand-search/gui/exhibition/matchresult/groupwidget.cpp b/src/grand-search/gui/exhibition/matchresult/groupwidget.cpp index 50bc67f..2539a32 100644 --- a/src/grand-search/gui/exhibition/matchresult/groupwidget.cpp +++ b/src/grand-search/gui/exhibition/matchresult/groupwidget.cpp @@ -250,8 +250,8 @@ void GroupWidget::showLabel(bool bShow) const QColor &color = DApplicationHelper::instance()->palette(m_resultLabel).color(DPalette::Normal, DPalette::Highlight); if (!hasIdx && !isUpdateIdx && !hasModel) { - // 请先前往搜索配置安装UOS AI大模型,并开启自动更新索引 Please go to Search configration to install the UOS AI large model, and turn on Automatic index update. - m_resultLabel->setText(tr("Please go to %1 to install the UOS AI large model, and %2 Automatic index update.") + // 请先前往搜索配置安装UOS AI大模型,并开启自动更新索引 Please go to Search configration to install the ULLM, and turn on Automatic index update. + m_resultLabel->setText(tr("Please go to %1 to install the ULLM, and %2 Automatic index update.") .arg(QString("%2").arg(color.name()).arg(tr("Search configration"))) .arg(QString("%2").arg(color.name()).arg(tr("turn on")))); } else if (!hasIdx && !isUpdateIdx) { @@ -260,7 +260,7 @@ void GroupWidget::showLabel(bool bShow) .arg(QString("%2").arg(color.name()).arg(tr("turn on")))); } else if (!hasModel) { // 请先前往搜索配置安装UOS AI大模型 Please go to Search configration to install the UOS AI large model. - m_resultLabel->setText(tr("Please go to %1 to install the UOS AI large model.") + m_resultLabel->setText(tr("Please go to %1 to install the ULLM.") .arg(QString("%2").arg(color.name()).arg(tr("Search configration")))); } else { m_resultLabel->setText(tr("No search results")); diff --git a/src/grand-search/gui/searchconfig/intelligentretrieval/intelligentretrievalwidget.cpp b/src/grand-search/gui/searchconfig/intelligentretrieval/intelligentretrievalwidget.cpp index bc49b01..01e5332 100644 --- a/src/grand-search/gui/searchconfig/intelligentretrieval/intelligentretrievalwidget.cpp +++ b/src/grand-search/gui/searchconfig/intelligentretrieval/intelligentretrievalwidget.cpp @@ -163,7 +163,7 @@ IntelligentRetrievalWidget::IntelligentRetrievalWidget(QWidget *parent) bkg->setLayout(vl); vl->setContentsMargins(0, 2, 0, 5); m_llmWidget = new LLMWidget(bkg); - m_llmWidget->setText(tr("UOS AI LLM"),tr("After installing the UOS AI large model, you can use the AI intelligent search function without an internet connection.")); + m_llmWidget->setText(tr("ULLM"),tr("After installing the ULLM, you can use the AI intelligent search function without an internet connection.")); m_llmWidget->checkInstallStatus(); vl->addWidget(m_llmWidget); m_indexLayout->addSpacing(10); @@ -326,7 +326,7 @@ void IntelligentRetrievalWidget::checkChanged() warningDlg.setWindowFlags((warningDlg.windowFlags() | Qt::WindowType::WindowStaysOnTopHint)); warningDlg.setFixedWidth(380); warningDlg.setIcon(QIcon(":icons/dde-grand-search-setting.svg")); - warningDlg.setMessage(QString(tr("To use AI Smart Search, you need to install the Embedding Plugins and UOS AI LLM first."))); + warningDlg.setMessage(QString(tr("To use AI Smart Search, you need to install the Embedding Plugins and ULLM first."))); warningDlg.addButton(tr("OK"), true, DDialog::ButtonNormal); warningDlg.moveToCenter(); warningDlg.exec(); diff --git a/src/grand-search/gui/searchconfig/llmwidget/llmwidget.cpp b/src/grand-search/gui/searchconfig/llmwidget/llmwidget.cpp index 9e57a8b..7b15fdb 100644 --- a/src/grand-search/gui/searchconfig/llmwidget/llmwidget.cpp +++ b/src/grand-search/gui/searchconfig/llmwidget/llmwidget.cpp @@ -335,7 +335,7 @@ bool LLMWidget::onCloseEvent() DDialog dlg(this); dlg.setIcon(QIcon(":icons/dde-grand-search-setting.svg")); dlg.setMaximumWidth(380); - dlg.setTitle(tr("Installing the UOS AI Large Language Model")); + dlg.setTitle(tr("Installing the ULLM")); dlg.setMessage(tr("Exiting will cause the installation to fail, do you still want to exit?")); dlg.addButton(tr("Exit", "button"), false, DDialog::ButtonNormal); dlg.addButton(tr("Continue", "button"), true, DDialog::ButtonRecommend); diff --git a/src/tools/semanticparser/semanticparser.h b/src/tools/semanticparser/semanticparser.h index 4b5f55a..ae94e1d 100644 --- a/src/tools/semanticparser/semanticparser.h +++ b/src/tools/semanticparser/semanticparser.h @@ -18,7 +18,6 @@ class SemanticParser : public QObject ~SemanticParser(); bool connectToVector(const QString &service); bool connectToQueryLang(const QString &service); - QString analyze(const QString &text); QString vectorSearch(const QString &prompt); QString query(const QString &text); bool isVectorSupported(); diff --git a/translations/dde-grand-search.ts b/translations/dde-grand-search.ts index 6ac399c..2523e78 100644 --- a/translations/dde-grand-search.ts +++ b/translations/dde-grand-search.ts @@ -1,6 +1,86 @@ + + GrandSearch::AiToolBar + + + Unable to use %1, please go to the App Store to update the UOS AI version first. + + + + + Cancel + Cancel + + + + Open App Stroe + + + + + GrandSearch::AiToolBarInner + + + + Summary + + + + + + Translation + + + + + + Extension + + + + + + Add to knowledge base + + + + + Summarize document content with UOS AI + + + + + Translate document content with UOS AI + + + + + Extend document content with UOS AI + + + + + Add document to UOS AI knowledge base + + + + + DDE Grand Search + + + + + Unable to use %1, please go to the App Store to update the UOS AI version first. + + + + + Open App Stroe + + + GrandSearch::BestMatchWidget @@ -12,12 +92,12 @@ GrandSearch::BlackListWidget - + Excluded path Excluded path - + Add paths to the exclusion list to prevent searching in them. Add paths to the exclusion list to prevent searching in them. @@ -33,13 +113,13 @@ GrandSearch::DdeGrandSearchDockPlugin - - + + Grand Search Grand Search - + Search settings Search settings @@ -64,15 +144,34 @@ Confirm + + GrandSearch::EmbeddingPluginWidget + + + Installed + + + + + + Not Installed + + + + + Install + + + GrandSearch::EntranceWidget - + Search Search - + What would you like to search for? What would you like to search for? @@ -129,12 +228,40 @@ GrandSearch::GroupWidget - + + Please go to %1 to install the ULLM, and %2 Automatic index update. + + + + + + Search configration + + + + + + turn on + + + + + Please %1 Automatic index update. + + + + + Please go to %1 to install the ULLM. + + + + More More - + + No search results No search results @@ -150,65 +277,191 @@ GrandSearch::IntelligentRetrievalWidget - - Smart Search + + When turned on, you can try to search for local documents using natural language descriptions, such as "last week's documents". - - Enable AI Smart Search + + Intelligent full text search - - Intelligent semantic search + + Automatic index update - - When turned on, you can try to search for local documents using natural language descriptions, such as "last week's documents". + + AI Smart Search - - Intelligent full text search + + Full Text Search - - Automatic index update + + When turned on, full text search can be used in the file manager and grand search. - + + Embedding Plugins + + + + + After installing the model, you can use services such as AI Search and UOS AI Assistant.. + + + + + ULLM + + + + + After installing the ULLM, you can use the AI intelligent search function without an internet connection. + + + + When enabled, you can search the text of articles using disjointed and incomplete keywords. - + Please install %0 in <a href="%0">the app store</a> before turning on this configuration. - + + Intelligent search indexing is being updated, which may take up more resources, please keep the power access. - + + Smart Search indexing update is complete. Last update time: %0 - + Indexing error! + + + To use AI Smart Search, you need to install the Embedding Plugins and ULLM first. + + + + + OK + + + + + GrandSearch::LLMWidget + + + + Not Installed + + + + + + Install Model + + + + + Update model + + + + + Uninstall model + + + + + Installing + + + + + Are you sure you want to delete this model? + + + + + After uninstallation, functions such as AI Search and UOS AI Assistant will not work properly. + + + + + Cancel + button + Cancel + + + + Confirm + button + Confirm + + + + Installing + + + + + Installing the ULLM + + + + + Exiting will cause the installation to fail, do you still want to exit? + + + + + Exit + button + + + + + Continue + button + + + + + UnInstall Model + + + + + Installed + + + + + Please install the "Embedding Plugins" first before installing this model. + + GrandSearch::MainWindow - + No search results No search results @@ -270,67 +523,67 @@ GrandSearch::SearchEngineWidget - + Default search engine Default search engine - + Search for keywords by the default search engine. Search for keywords by the default search engine. - + Default search engine is Default search engine is - + Google Google - + Baidu Baidu - + Bing Bing - + Yahoo Yahoo - + 360 360 - + 360 AI Search - + Sogou Sogou - + Custom - + You need to use "%0" to replace the keyword in the URL - + Invalid URL @@ -338,7 +591,7 @@ GrandSearch::StaticTextWorker - + Search for "%1" Search for "%1" @@ -346,22 +599,22 @@ GrandSearch::TailerWidget - + Tailer settings Tailer settings - + It is displayed at the end of search results for better identification and distinction of items with duplicate names. It is displayed at the end of search results for better identification and distinction of items with duplicate names. - + Parent directory Parent directory - + Time modified Time modified @@ -515,7 +768,7 @@ Time modified: - + modified modified diff --git a/translations/dde-grand-search_zh_CN.ts b/translations/dde-grand-search_zh_CN.ts index 7a9aabb..f1cc663 100644 --- a/translations/dde-grand-search_zh_CN.ts +++ b/translations/dde-grand-search_zh_CN.ts @@ -66,17 +66,17 @@ 将文档添加到UOS AI知识库 - + DDE Grand Search 全局搜索 - + Unable to use %1, please go to the App Store to update the UOS AI version first. 无法使用%1,请先到应用商店更新UOS AI版本 - + Open App Stroe 打开商店 @@ -229,8 +229,8 @@ GrandSearch::GroupWidget - Please go to %1 to install the UOS AI large model, and %2 Automatic index update. - 请先前往%1安装UOS AI大模型,并%2自动更新索引 + Please go to %1 to install the ULLM, and %2 Automatic index update. + 请先前往%1安装统信有容大模型,并%2自动更新索引 @@ -251,8 +251,8 @@ - Please go to %1 to install the UOS AI large model. - 请先前往%1安装UOS AI大模型 + Please go to %1 to install the ULLM. + 请先前往%1安装统信有容大模型 @@ -298,13 +298,13 @@ - UOS AI LLM - UOS AI大模型 + ULLM + 统信有容大模型 - After installing the UOS AI large model, you can use the AI intelligent search function without an internet connection. - 安装UOS AI大模型后,无需联网即可使用AI智能搜索功能 + After installing the ULLM, you can use the AI intelligent search function without an internet connection. + 安装统信有容大模型后,无需联网即可使用AI智能搜索功能 @@ -355,7 +355,7 @@ - To use AI Smart Search, you need to install the Embedding Plugins and UOS AI LLM first. + To use AI Smart Search, you need to install the Embedding Plugins and ULLM first. 使用AI智能搜索需要先安装“向量化模型插件”和“统信有容大模型”。 @@ -390,7 +390,7 @@ Are you sure you want to delete this model? - 确定卸载UOS AI大模型? + 确定卸载模型? @@ -416,8 +416,8 @@ - Installing the UOS AI Large Language Model - 正在安装UOS AI大模型 + Installing the ULLM + 正在安装统信有容大模型 From 4308ca3b64a3aba01f7164c5e5fdde227b068328 Mon Sep 17 00:00:00 2001 From: lichaofan Date: Mon, 30 Dec 2024 16:51:38 +0800 Subject: [PATCH 3/3] feat: DSL search improvement Description: Log: --- .../searcher/semantic/dslparser/dslparser.cpp | 603 ++---------------- .../searcher/semantic/dslparser/dslparser.h | 135 +--- .../searcher/semantic/semanticworker.cpp | 6 +- 3 files changed, 71 insertions(+), 673 deletions(-) diff --git a/src/dde-grand-search-daemon/searcher/semantic/dslparser/dslparser.cpp b/src/dde-grand-search-daemon/searcher/semantic/dslparser/dslparser.cpp index 7f653ef..2a0160b 100644 --- a/src/dde-grand-search-daemon/searcher/semantic/dslparser/dslparser.cpp +++ b/src/dde-grand-search-daemon/searcher/semantic/dslparser/dslparser.cpp @@ -13,11 +13,8 @@ using namespace antlr4; bool BaseCond::kIsNeedAdjustBase = false; -BaseCond::BaseCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : QObject(parent) { +BaseCond::BaseCond(const QString &text, QObject *parent) : QObject(parent) { setCond(text); - m_querys = querys; - m_worker = worker; } BaseCond::~BaseCond() { @@ -42,40 +39,6 @@ void BaseCond::addOrCond(BaseCond *cond) { cond->setParent(this); } -bool BaseCond::isMatch(const QString &text) { - bool ret = true; - qDebug() << QString("BaseCond type(%1) isMatch(%2) m_cond(%3)").arg(m_condType).arg(text).arg(m_cond); - if (m_andCondList.empty() && m_orCondList.empty()) { - ret = false; - goto _EXIT; - } - - if (!m_andCondList.empty()) { - for (BaseCond *cond : m_andCondList) { - if (!cond->isMatch(text)) { - ret = false; - goto _EXIT; - } - } - - ret = true; - goto _EXIT; - } - - for (BaseCond *cond : m_orCondList) { - if (cond->isMatch(text)) { - ret = true; - goto _EXIT; - } - } - - ret = false; - -_EXIT: - qInfo() << QString("BaseCond type(%1) isMatch(%2) ret(%3) m_cond(%4)").arg(m_condType).arg(text).arg(ret).arg(m_cond); - return ret; -} - void BaseCond::adjust() { // 消除冗余的Binary层级 this->mergeBinary(); @@ -88,7 +51,6 @@ void BaseCond::adjust() { this->merge4Engine(); this->adjust4OrCond(); - //this->loadCond(); } void BaseCond::mergeBinary() { @@ -104,7 +66,7 @@ void BaseCond::mergeBinary() { } if (isAllDate) { - DateInfoCond *allCond = new DateInfoCond("", this->m_querys, this->m_worker); + DateInfoCond *allCond = new DateInfoCond(""); allCond->m_compType = "=="; for (int i = m_andCondList.size() - 1; i >= 0; i--) { DateInfoCond *cond = dynamic_cast(m_andCondList[i]); @@ -174,7 +136,7 @@ void BaseCond::mergeBase() { } if (isAllDate) { - DateInfoCond *allCond = new DateInfoCond("", this->m_querys, this->m_worker); + DateInfoCond *allCond = new DateInfoCond(""); allCond->m_compType = "=="; for (int i = m_andCondList.size() - 1; i >= 0; i--) { DateInfoCond *cond = dynamic_cast(m_andCondList[i]); @@ -242,44 +204,12 @@ void BaseCond::merge4Engine() { return; } - bool hasFeature = false, hasFulltext = false; - for (int i = 0; i < m_andCondList.size(); i++) { - if (m_andCondList[i]->getCondType() == querylangParser::RuleMetaSearch - || m_andCondList[i]->getCondType() == querylangParser::RuleDurationSearch) { - hasFeature = true; - break; - } - - if (m_andCondList[i]->getCondType() == querylangParser::RuleContentSearch) { - hasFulltext = true; - break; - } - } - - if (hasFeature) { - FeatureCond *cond = new FeatureCond(&m_andCondList, m_querys, m_worker); - if (cond->isValid()) { - m_andCondList.append(cond); - cond->setParent(this); - } else { - delete cond; - } - } else if (hasFulltext) { - FulltextCond *cond = new FulltextCond(&m_andCondList, m_querys, m_worker); - if (cond->isValid()) { - m_andCondList.append(cond); - cond->setParent(this); - } else { - delete cond; - } + EngineCond *cond = new EngineCond(&m_andCondList); + if (cond->isValid()) { + m_andCondList.append(cond); + cond->setParent(this); } else { - AnythingCond *cond = new AnythingCond(&m_andCondList, m_querys, m_worker); - if (cond->isValid()) { - m_andCondList.append(cond); - cond->setParent(this); - } else { - delete cond; - } + delete cond; } } } @@ -287,34 +217,7 @@ void BaseCond::merge4Engine() { void BaseCond::adjust4OrCond() { if (m_andCondList.size() == 2 && m_andCondList[0]->getCondType() == querylangParser::RulePrimary && !m_andCondList[0]->m_orCondList.isEmpty() - && m_andCondList[1]->getCondType() == BinaryCond::RuleAnything) { - bool isAllSimpleCond = true; - for (int i = 0; i < m_andCondList[0]->m_orCondList.size(); i++) { - BaseCond *cond = m_andCondList[0]->m_orCondList[i]; - if (cond->getCondType() != querylangParser::RuleTypeSearch) { - isAllSimpleCond = false; - break; - } - } - - if (isAllSimpleCond) { - for (int i = 0; i < m_andCondList[0]->m_orCondList.size(); i++) { - BaseCond *cond = m_andCondList[0]->m_orCondList[i]; - AnythingCond *anyCond = dynamic_cast(m_andCondList[1]); - if (!anyCond->copyCondOut(cond)) { - return; - } - } - - delete m_andCondList[1]; - m_andCondList.removeAt(1); - return; - } - } - - if (m_andCondList.size() == 2 && m_andCondList[0]->getCondType() == querylangParser::RulePrimary - && !m_andCondList[0]->m_orCondList.isEmpty() - && m_andCondList[1]->getCondType() == BinaryCond::RuleFeature) { + && m_andCondList[1]->getCondType() == BinaryCond::RuleEngine) { bool isAllSimpleCond = true; for (int i = 0; i < m_andCondList[0]->m_orCondList.size(); i++) { BaseCond *cond = m_andCondList[0]->m_orCondList[i]; @@ -325,37 +228,11 @@ void BaseCond::adjust4OrCond() { } if (isAllSimpleCond) { + // 吸收 Type 类型条件 for (int i = 0; i < m_andCondList[0]->m_orCondList.size(); i++) { BaseCond *cond = m_andCondList[0]->m_orCondList[i]; - FeatureCond *anyCond = dynamic_cast(m_andCondList[1]); - if (!anyCond->copyCondOut(cond)) { - return; - } - } - - delete m_andCondList[1]; - m_andCondList.removeAt(1); - return; - } - } - - if (m_andCondList.size() == 2 && m_andCondList[0]->getCondType() == querylangParser::RulePrimary - && !m_andCondList[0]->m_orCondList.isEmpty() - && m_andCondList[1]->getCondType() == BinaryCond::RuleFulltext) { - bool isAllSimpleCond = true; - for (int i = 0; i < m_andCondList[0]->m_orCondList.size(); i++) { - BaseCond *cond = m_andCondList[0]->m_orCondList[i]; - if (cond->getCondType() != querylangParser::RuleTypeSearch) { - isAllSimpleCond = false; - break; - } - } - - if (isAllSimpleCond) { - for (int i = 0; i < m_andCondList[0]->m_orCondList.size(); i++) { - BaseCond *cond = m_andCondList[0]->m_orCondList[i]; - FulltextCond *anyCond = dynamic_cast(m_andCondList[1]); - if (!anyCond->copyCondOut(cond)) { + EngineCond *engineCond = dynamic_cast(m_andCondList[1]); + if (!engineCond->absorbCond(cond)) { return; } } @@ -371,18 +248,6 @@ void BaseCond::adjust4OrCond() { } } -void BaseCond::loadCond() { - if (!m_andCondList.isEmpty()) { - for (int i = 0; i < m_andCondList.size(); i++) { - m_andCondList[i]->loadCond(); - } - } else { - for (int i = 0; i < m_orCondList.size(); i++) { - m_orCondList[i]->loadCond(); - } - } -} - QList BaseCond::entityList() { QList list; if (m_condType == querylangParser::RulePrimary || m_condType == querylangParser::RuleBinaryExpression) { @@ -401,60 +266,6 @@ QList BaseCond::entityList() { return list; } -void BaseCond::addMatchedItems(const MatchedItems &items) { - m_matchedItems.append(items); -} - -const MatchedItems &BaseCond::getMatchedItems() { - if (m_condType != querylangParser::RulePrimary && m_condType != querylangParser::RuleBinaryExpression) { - return m_matchedItems; - } - - if (!m_andCondList.isEmpty()) { - int quantity = -1; - bool isGetItems = false; - for (int i = 0; i < m_andCondList.size(); i++) { - if (m_andCondList[i]->getCondType() == querylangParser::RuleQuantityCondition) { - quantity = dynamic_cast(m_andCondList[i])->getQuantity(); - continue; - } - - if (!isGetItems) { - m_matchedItems = m_andCondList[i]->getMatchedItems(); - isGetItems = true; - continue; - } - - // 存在删除操作,所以采用倒序 - for (int j = m_matchedItems.size() - 1; j >= 0; j--) { - if (m_andCondList[i]->getMatchedItems().contains(m_matchedItems[j])) { - continue; - } - - m_matchedItems.removeAt(j); - } - } - if (quantity > 0 && m_matchedItems.size() > quantity) { - while (m_matchedItems.size() > quantity) { - m_matchedItems.removeLast(); - } - } - return m_matchedItems; - } - - for (int i = 0; i < m_orCondList.size(); i++) { - const MatchedItems &items = m_orCondList[i]->getMatchedItems(); - for (int j = 0; j < items.size(); j++) { - if (m_matchedItems.contains(items[j])) { - continue; - } - - m_matchedItems.append(items[j]); - } - } - return m_matchedItems; -} - QString BaseCond::toString(int spaceCounts) { // 控制缩进 QString space; @@ -475,8 +286,7 @@ QString BaseCond::toString(int spaceCounts) { return str; } -DateInfoCond::DateInfoCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond(text, querys, worker, parent) { +DateInfoCond::DateInfoCond(const QString &text, QObject *parent) : BaseCond(text, parent) { m_condType = querylangParser::RuleDateSearchinfo; const QDateTime curDT = QDateTime::currentDateTime(); @@ -541,14 +351,7 @@ DateInfoCond::DateInfoCond(const QString &text, QListappend(func); -} - -PathCond::PathCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond(text, querys, worker, parent) { +PathCond::PathCond(const QString &text, QObject *parent) : BaseCond(text, parent) { m_condType = querylangParser::RulePathSearch; if (m_cond.contains("IS NOT")) { m_isTruePath = false; @@ -571,14 +374,7 @@ PathCond::PathCond(const QString &text, QListappend(func); -} - -NameCond::NameCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond(text, querys, worker, parent) { +NameCond::NameCond(const QString &text, QObject *parent) : BaseCond(text, parent) { m_condType = querylangParser::RuleNameSearch; int pos = m_cond.indexOf("\"") + 1; m_name = m_cond.mid(pos, m_cond.length() - pos - 1); @@ -587,14 +383,7 @@ NameCond::NameCond(const QString &text, QListappend(func); -} - -SizeCond::SizeCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond(text, querys, worker, parent) { +SizeCond::SizeCond(const QString &text, QObject *parent) : BaseCond(text, parent) { m_condType = querylangParser::RuleSizeSearch; int pos = m_cond.indexOf("\"") + 1; QString temp = m_cond.mid(pos, m_cond.length() - pos - 1); @@ -628,14 +417,7 @@ SizeCond::SizeCond(const QString &text, QListappend(func); -} - -TypeCond::TypeCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond(text, querys, worker, parent) { +TypeCond::TypeCond(const QString &text, QObject *parent) : BaseCond(text, parent) { m_condType = querylangParser::RuleTypeSearch; if (m_cond.contains("IS NOT")) { m_isTrueType = false; @@ -671,14 +453,7 @@ TypeCond::TypeCond(const QString &text, QListappend(func); -} - -DurationCond::DurationCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond(text, querys, worker, parent) { +DurationCond::DurationCond(const QString &text, QObject *parent) : BaseCond(text, parent) { m_condType = querylangParser::RuleDurationSearch; // DURATION>"3 minute" if (m_cond.contains(">")) { @@ -733,14 +508,7 @@ QString DurationCond::formatTime(qint64 msec) { return formattedDuration; } -void DurationCond::loadCond() { - m_feature.setEntity({m_entity}); - SemanticWorkerPrivate::QueryFunction func = {&m_feature, &FeatureQuery::run, this}; - m_querys->append(func); -} - -MetaCond::MetaCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond(text, querys, worker, parent) { +MetaCond::MetaCond(const QString &text, QObject *parent) : BaseCond(text, parent) { m_condType = querylangParser::RuleMetaSearch; // META_TYPEIS"ARTIST"ANDMETA_VALUEIS"xxx" // META_TYPEIS"ALBUM"ANDMETA_VALUEIS"xxx" @@ -787,18 +555,7 @@ MetaCond::MetaCond(const QString &text, QListappend(func); -} - -QuantityCond::QuantityCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond(text, querys, worker, parent) { +QuantityCond::QuantityCond(const QString &text, QObject *parent) : BaseCond(text, parent) { m_condType = querylangParser::RuleQuantityCondition; int pos = m_cond.indexOf("=") + 1; QString temp = m_cond.mid(pos); @@ -806,8 +563,7 @@ QuantityCond::QuantityCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond(text, querys, worker, parent) { +ContentCond::ContentCond(const QString &text, QObject *parent) : BaseCond(text, parent) { m_condType = querylangParser::RuleContentSearch; int pos = m_cond.indexOf("\"") + 1; m_content = m_cond.mid(pos, m_cond.length() - pos - 1); @@ -816,147 +572,17 @@ ContentCond::ContentCond(const QString &text, QListappend(func); -} - -AnythingCond::AnythingCond(QList *andList, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond("", querys, worker, parent) { - const qint64 _NOW = QDateTime::currentSecsSinceEpoch(); - m_condType = BaseCond::RuleAnything; - m_isValid = false; - - // 支持:DateInfo Path Name Size Type - // Date的条件,一般都是成对出现的 - qint64 timestamp1 = 0, timestamp2 = _NOW; - // 使用倒序的原因:含有删除操作 - for (int i = andList->size() - 1; i >= 0; i--) { - if ((*andList)[i]->getCondType() == querylangParser::RuleDateSearchinfo) { - m_isValid = true; - DateInfoCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - if (cond->m_compType == "==") { - timestamp1 = cond->m_timestamp; - timestamp2 = cond->m_timestamp2; - } else if (cond->m_compType.contains(">")) { - timestamp1 = cond->m_timestamp; - } else { - timestamp2 = cond->m_timestamp; - } - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - if ((*andList)[i]->getCondType() == querylangParser::RulePathSearch) { - m_isValid = true; - PathCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - m_entity.isContainPath = cond->m_isTruePath; - m_entity.partPath = cond->m_pathName; - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - if ((*andList)[i]->getCondType() == querylangParser::RuleNameSearch) { - m_isValid = true; - NameCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - m_entity.keys.append(cond->m_name); - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - if ((*andList)[i]->getCondType() == querylangParser::RuleSizeSearch) { - m_isValid = true; - SizeCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - m_entity.fileCompType = cond->m_compType; - m_entity.fileSize = cond->m_fileSize; - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - if ((*andList)[i]->getCondType() == querylangParser::RuleTypeSearch) { - m_isValid = true; - TypeCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - /* - * #define DOCUMENT_GROUP "text" - * #define PICTURE_GROUP "img" - * #define AUDIO_GROUP "msc" - * #define VIDEO_GROUP "vdo" - * #define FILE_GROUP "file" - * #define FOLDER_GROUP "fld" - * #define APPLICATION_GROUP "app" - */ - // 优先匹配为类别,其实是扩展名 - if (cond->m_typeName == "song" || cond->m_typeName == "music") { - m_entity.types.append(AUDIO_GROUP); - } else if (cond->m_typeName == "paper" || cond->m_typeName == "document") { - m_entity.types.append(DOCUMENT_GROUP); - } else if (cond->m_typeName == "picture") { - m_entity.types.append(PICTURE_GROUP); - } else if (cond->m_typeName == "video") { - m_entity.types.append(VIDEO_GROUP); - } else if (cond->m_typeName == "file") { - m_entity.types.clear(); - } else { - m_entity.suffix = cond->m_typeName; - } - m_entity.isContainType = cond->m_isTrueType; - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - (*andList)[i]->merge4Engine(); - } - if (timestamp1 != 0 || timestamp2 != _NOW) { - m_entity.times.append(QPair(timestamp1, timestamp2)); - } -} - -bool AnythingCond::copyCondOut(BaseCond *cond) { - if (cond->getCondType() == querylangParser::RuleTypeSearch) { - cond->m_condType = BaseCond::RuleAnything; - cond->m_cond = m_cond + cond->m_cond; - SemanticEntity entity = m_entity; - entity.types.append(cond->m_entity.types); - entity.suffix = cond->m_entity.suffix; - cond->m_entity = entity; - return true; - } - - return false; -} - -void AnythingCond::loadCond() { - if (!m_isValid) { - return; - } - - m_anything.setEntity({m_entity}); - SemanticWorkerPrivate::QueryFunction func = {&m_anything, &AnythingQuery::run, this}; - m_querys->append(func); -} - -FeatureCond::FeatureCond(QList *andList, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond("", querys, worker, parent) { +EngineCond::EngineCond(QList *andList, QObject *parent) : BaseCond("", parent) { const qint64 _NOW = QDateTime::currentSecsSinceEpoch(); - m_condType = BaseCond::RuleFeature; + m_condType = BaseCond::RuleEngine; m_isValid = false; - // 支持:Meta Duration DateInfo Path Name Size Type + // 支持:DateInfo Path Name Size Type 特殊1(Meta Duration) 特殊2(Content) // Date的条件,一般都是成对出现的 qint64 timestamp1 = 0, timestamp2 = _NOW; // 使用倒序的原因:含有删除操作 for (int i = andList->size() - 1; i >= 0; i--) { + // Meta if ((*andList)[i]->getCondType() == querylangParser::RuleMetaSearch) { m_isValid = true; MetaCond *cond = dynamic_cast((*andList)[i]); @@ -982,6 +608,7 @@ FeatureCond::FeatureCond(QList *andList, QListgetCondType() == querylangParser::RuleDurationSearch) { m_isValid = true; DurationCond *cond = dynamic_cast((*andList)[i]); @@ -993,130 +620,7 @@ FeatureCond::FeatureCond(QList *andList, QListgetCondType() == querylangParser::RuleDateSearchinfo) { - m_isValid = true; - DateInfoCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - if (cond->m_compType == "==") { - timestamp1 = cond->m_timestamp; - timestamp2 = cond->m_timestamp2; - } else if (cond->m_compType.contains(">")) { - timestamp1 = cond->m_timestamp; - } else { - timestamp2 = cond->m_timestamp; - } - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - if ((*andList)[i]->getCondType() == querylangParser::RulePathSearch) { - m_isValid = true; - PathCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - m_entity.isContainPath = cond->m_isTruePath; - m_entity.partPath = cond->m_pathName; - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - if ((*andList)[i]->getCondType() == querylangParser::RuleNameSearch) { - m_isValid = true; - NameCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - m_entity.keys.append(cond->m_name); - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - if ((*andList)[i]->getCondType() == querylangParser::RuleSizeSearch) { - m_isValid = true; - SizeCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - m_entity.fileCompType = cond->m_compType; - m_entity.fileSize = cond->m_fileSize; - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - if ((*andList)[i]->getCondType() == querylangParser::RuleTypeSearch) { - m_isValid = true; - TypeCond *cond = dynamic_cast((*andList)[i]); - m_cond += cond->getCond() + " "; - /* - * #define DOCUMENT_GROUP "text" - * #define PICTURE_GROUP "img" - * #define AUDIO_GROUP "msc" - * #define VIDEO_GROUP "vdo" - * #define FILE_GROUP "file" - * #define FOLDER_GROUP "fld" - * #define APPLICATION_GROUP "app" - */ - // 优先匹配为类别,其实是扩展名 - if (cond->m_typeName == "song" || cond->m_typeName == "music") { - m_entity.types.append(AUDIO_GROUP); - } else if (cond->m_typeName == "paper" || cond->m_typeName == "document") { - m_entity.types.append(DOCUMENT_GROUP); - } else if (cond->m_typeName == "picture") { - m_entity.types.append(PICTURE_GROUP); - } else if (cond->m_typeName == "video") { - m_entity.types.append(VIDEO_GROUP); - } else if (cond->m_typeName == "file") { - m_entity.types.clear(); - } else { - m_entity.suffix = cond->m_typeName; - } - m_entity.isContainType = cond->m_isTrueType; - delete (*andList)[i]; - andList->removeAt(i); - continue; - } - - (*andList)[i]->merge4Engine(); - } - if (timestamp1 != 0 || timestamp2 != _NOW) { - m_entity.times.append(QPair(timestamp1, timestamp2)); - } -} - -bool FeatureCond::copyCondOut(BaseCond *cond) { - if (cond->getCondType() == querylangParser::RuleTypeSearch) { - cond->m_condType = BaseCond::RuleFeature; - cond->m_cond = m_cond + cond->m_cond; - SemanticEntity entity = m_entity; - entity.types.append(cond->m_entity.types); - entity.suffix = cond->m_entity.suffix; - cond->m_entity = entity; - return true; - } - - return false; -} - -void FeatureCond::loadCond() { - if (!m_isValid) { - return; - } - - m_feature.setEntity({m_entity}); - SemanticWorkerPrivate::QueryFunction func = {&m_feature, &FeatureQuery::run, this}; - m_querys->append(func); -} - -FulltextCond::FulltextCond(QList *andList, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent) : BaseCond("", querys, worker, parent) { - const qint64 _NOW = QDateTime::currentSecsSinceEpoch(); - m_condType = BaseCond::RuleFulltext; - m_isValid = false; - - // 支持:Content DateInfo Path Name Size Type - // Date的条件,一般都是成对出现的 - qint64 timestamp1 = 0, timestamp2 = _NOW; - // 使用倒序的原因:含有删除操作 - for (int i = andList->size() - 1; i >= 0; i--) { + // Content if ((*andList)[i]->getCondType() == querylangParser::RuleContentSearch) { m_isValid = true; ContentCond *cond = dynamic_cast((*andList)[i]); @@ -1127,6 +631,7 @@ FulltextCond::FulltextCond(QList *andList, QListgetCondType() == querylangParser::RuleDateSearchinfo) { m_isValid = true; DateInfoCond *cond = dynamic_cast((*andList)[i]); @@ -1144,6 +649,7 @@ FulltextCond::FulltextCond(QList *andList, QListgetCondType() == querylangParser::RulePathSearch) { m_isValid = true; PathCond *cond = dynamic_cast((*andList)[i]); @@ -1155,6 +661,7 @@ FulltextCond::FulltextCond(QList *andList, QListgetCondType() == querylangParser::RuleNameSearch) { m_isValid = true; NameCond *cond = dynamic_cast((*andList)[i]); @@ -1165,6 +672,7 @@ FulltextCond::FulltextCond(QList *andList, QListgetCondType() == querylangParser::RuleSizeSearch) { m_isValid = true; SizeCond *cond = dynamic_cast((*andList)[i]); @@ -1176,6 +684,7 @@ FulltextCond::FulltextCond(QList *andList, QListgetCondType() == querylangParser::RuleTypeSearch) { m_isValid = true; TypeCond *cond = dynamic_cast((*andList)[i]); @@ -1216,9 +725,9 @@ FulltextCond::FulltextCond(QList *andList, QListgetCondType() == querylangParser::RuleTypeSearch) { - cond->m_condType = BaseCond::RuleFulltext; + cond->m_condType = BaseCond::RuleEngine; cond->m_cond = m_cond + cond->m_cond; SemanticEntity entity = m_entity; entity.types.append(cond->m_entity.types); @@ -1230,16 +739,6 @@ bool FulltextCond::copyCondOut(BaseCond *cond) { return false; } -void FulltextCond::loadCond() { - if (!m_isValid) { - return; - } - - m_fulltext.setEntity({m_entity}); - SemanticWorkerPrivate::QueryFunction func = {&m_fulltext, &FullTextQuery::run, this}; - m_querys->append(func); -} - void DslParserListener::enterEveryRule(antlr4::ParserRuleContext *ctx) { QString text = QString().fromStdString(ctx->getText()); switch (ctx->getRuleIndex()) { @@ -1271,12 +770,12 @@ void DslParserListener::enterEveryRule(antlr4::ParserRuleContext *ctx) { bool isAnd = true, isOr = true; switch (ctx->getRuleIndex()) { case querylangParser::RulePrimary: - ptr = new BaseCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new BaseCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RuleBinaryExpression: - ptr = new BinaryCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new BinaryCond(text); isAnd = (m_cond->getCond().contains(QString("AND") + text)); isOr = (m_cond->getCond().contains(QString("OR") + text)); if (isAnd) { @@ -1291,52 +790,52 @@ void DslParserListener::enterEveryRule(antlr4::ParserRuleContext *ctx) { m_tempPtr = ptr; break; case querylangParser::RuleDateSearchinfo: - ptr = new DateInfoCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new DateInfoCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RulePathSearch: - ptr = new PathCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new PathCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RuleNameSearch: - ptr = new NameCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new NameCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RuleSizeSearch: - ptr = new SizeCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new SizeCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RuleTypeSearch: - ptr = new TypeCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new TypeCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RuleDurationSearch: - ptr = new DurationCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new DurationCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RuleMetaSearch: - ptr = new MetaCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new MetaCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RuleQuantityCondition: - ptr = new QuantityCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new QuantityCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RuleContentSearch: - ptr = new ContentCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new ContentCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; case querylangParser::RuleFilename: - ptr = new FileNameCond(text, m_tempPtr->m_querys, m_tempPtr->m_worker); + ptr = new FileNameCond(text); m_tempPtr->addAndCond(ptr); m_tempPtr = ptr; break; @@ -1370,8 +869,7 @@ void DslParserListener::exitEveryRule(antlr4::ParserRuleContext *ctx) { } } -DslParser::DslParser(const QString &text, QList *querys, FileResultsHandler *fileHandler, - SemanticWorkerPrivate *worker, QObject *parent) : QObject(parent), m_cond("", querys, worker) { +DslParser::DslParser(const QString &text, QObject *parent) : QObject(parent), m_cond("") { qDebug() << QString("DslParser DslParser(%1)").arg(text); ANTLRInputStream input(text.toUtf8().toStdString()); querylangLexer lexer(&input); @@ -1385,10 +883,3 @@ DslParser::DslParser(const QString &text, QList #include #include - -#include "../fileresultshandler.h" #include "../semanticworker_p.h" -#include "../database/anythingquery.h" -#include "../database/fulltextquery.h" -#include "../database/featurequery.h" -#include "../database/vectorquery.h" - namespace GrandSearch { -class SemanticWorkerPrivate; // 对应RulePrimary class BaseCond : public QObject { Q_OBJECT public: - explicit BaseCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); + explicit BaseCond(const QString &text, QObject *parent = nullptr); virtual ~BaseCond(); void setCond(const QString &text) { m_cond = text; } QString getCond() { return m_cond; } @@ -36,26 +27,20 @@ class BaseCond : public QObject { BaseCond *getParent() { return m_parent; } void addAndCond(BaseCond *cond); void addOrCond(BaseCond *cond); - // 调试使用 - virtual bool isMatch(const QString &text); // 某些条件没有存在的必要 virtual bool isValid() { return m_isValid; } // 结构优化调整 void adjust(); // 合并Binary层级的条件 virtual void mergeBinary(); - // 合并Base层级的条件 + // 合并Base层级的条件(Binary层级之上) virtual void mergeBase(); - // 合并各引擎的条件 + // 为搜索引擎,合并各条件 virtual void merge4Engine(); // 为OR条件调整条件组合 void adjust4OrCond(); - // 装载检索条件进入检索引擎 - virtual void loadCond(); virtual QList entityList(); - virtual void addMatchedItems(const MatchedItems &items); - virtual const MatchedItems &getMatchedItems(); virtual QString toString(int spaceCounts = 0); public: @@ -63,10 +48,7 @@ class BaseCond : public QObject { static bool kIsNeedAdjustBase; QString m_cond; int m_condType = querylangParser::RulePrimary; - QList *m_querys = nullptr; - SemanticWorkerPrivate *m_worker = nullptr; BaseCond *m_parent = nullptr; - MatchedItems m_matchedItems; QList m_andCondList; QList m_orCondList; bool m_isValid = true; @@ -74,7 +56,8 @@ class BaseCond : public QObject { public: enum { - RuleAnything = 100, + RuleEngine = 100, + RuleAnything, RuleFeature, RuleFulltext, }; @@ -83,8 +66,7 @@ class BaseCond : public QObject { // 对应RuleBinaryExpression class BinaryCond : public BaseCond { public: - explicit BinaryCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr) : BaseCond(text, querys, worker, parent) { + explicit BinaryCond(const QString &text, QObject *parent = nullptr) : BaseCond(text, parent) { m_condType = querylangParser::RuleBinaryExpression; } }; @@ -92,115 +74,79 @@ class BinaryCond : public BaseCond { // 对应RuleDateSearchinfo DATE <= CURRENT - "16 hour" class DateInfoCond : public BaseCond { public: - explicit DateInfoCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - void loadCond() override; + explicit DateInfoCond(const QString &text, QObject *parent = nullptr); public: QString m_compType; qint64 m_timestamp; qint64 m_timestamp2; - -private: - AnythingQuery m_anything; }; // 对应RulePathSearch PATH IS "Downloads" class PathCond : public BaseCond { public: - explicit PathCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - void loadCond() override; + explicit PathCond(const QString &text, QObject *parent = nullptr); public: bool m_isTruePath = true; QString m_pathName; - -private: - AnythingQuery m_anything; }; // 对应RuleNameSearch NAME CONTAINS "名字" class NameCond : public BaseCond { public: - explicit NameCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - void loadCond() override; + explicit NameCond(const QString &text, QObject *parent = nullptr); public: QString m_name; - -private: - AnythingQuery m_anything; }; // 对应RuleSizeSearch SIZE <= "4GB" class SizeCond : public BaseCond { public: - explicit SizeCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - void loadCond() override; + explicit SizeCond(const QString &text, QObject *parent = nullptr); public: QString m_compType; qint64 m_fileSize; - -private: - AnythingQuery m_anything; }; // 对应RuleTypeSearch TYPE IS "txt" class TypeCond : public BaseCond { public: - explicit TypeCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - void loadCond() override; + explicit TypeCond(const QString &text, QObject *parent = nullptr); public: bool m_isTrueType = true; QString m_typeName; - -private: - AnythingQuery m_anything; }; // 对应RuleDurationSearch DURATION > \"3 minute\" class DurationCond : public BaseCond { public: - explicit DurationCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); + explicit DurationCond(const QString &text, QObject *parent = nullptr); static QString formatTime(qint64 msec); - void loadCond() override; public: QString m_compType; QString m_duration; - -private: - FeatureQuery m_feature; }; // 对应RuleMetaSearch META_TYPE IS \"ARTIST\" AND META_VALUE IS \"xxx\" class MetaCond : public BaseCond { public: - explicit MetaCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - void loadCond() override; + explicit MetaCond(const QString &text, QObject *parent = nullptr); public: bool m_isTrue = true; QString m_metaType; QString m_metaValue; - -private: - FeatureQuery m_feature; }; // 对应RuleQuantityCondition QUANTITY = 10 class QuantityCond : public BaseCond { public: - explicit QuantityCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); + explicit QuantityCond(const QString &text, QObject *parent = nullptr); int getQuantity() { return m_quantity; } private: @@ -210,58 +156,24 @@ class QuantityCond : public BaseCond { // 对应RuleContentSearch CONTENT CONTAINS "read" class ContentCond : public BaseCond { public: - explicit ContentCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - void loadCond() override; + explicit ContentCond(const QString &text, QObject *parent = nullptr); public: QString m_content; - -private: - FullTextQuery m_fulltext; }; // 对应RuleFilename class FileNameCond : public BaseCond { public: - explicit FileNameCond(const QString &text, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr) : BaseCond(text, querys, worker, parent) {} -}; - -// 对应合并后的Anything -class AnythingCond : public BaseCond { -public: - explicit AnythingCond(QList *andList, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - bool copyCondOut(BaseCond *cond); - void loadCond() override; - -private: - AnythingQuery m_anything; + explicit FileNameCond(const QString &text, QObject *parent = nullptr) : BaseCond(text, parent) {} }; -// 对应合并后的Feature -class FeatureCond : public BaseCond { +// 对应合并后的Engine +class EngineCond : public BaseCond { public: - explicit FeatureCond(QList *andList, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - bool copyCondOut(BaseCond *cond); - void loadCond() override; - -private: - FeatureQuery m_feature; -}; - -// 对应合并后的Fulltext -class FulltextCond : public BaseCond { -public: - explicit FulltextCond(QList *andList, QList *querys, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); - bool copyCondOut(BaseCond *cond); - void loadCond() override; - -private: - FullTextQuery m_fulltext; + explicit EngineCond(QList *andList, QObject *parent = nullptr); + // 吸收目标条件至自身 + bool absorbCond(BaseCond *cond); }; class DslParserListener : public antlr4::tree::ParseTreeListener { @@ -335,12 +247,9 @@ class DslParserListener : public antlr4::tree::ParseTreeListener { class DslParser : public QObject { Q_OBJECT public: - explicit DslParser(const QString &text, QList *querys, FileResultsHandler *fileHandler, - SemanticWorkerPrivate *worker, QObject *parent = nullptr); + explicit DslParser(const QString &text, QObject *parent = nullptr); ~DslParser() {} - bool isMatch(const QString &text); QList entityList() { return m_cond.entityList(); } - const MatchedItems &getMatchedItems() { return m_cond.getMatchedItems(); } private: BaseCond m_cond; diff --git a/src/dde-grand-search-daemon/searcher/semantic/semanticworker.cpp b/src/dde-grand-search-daemon/searcher/semantic/semanticworker.cpp index 7a3c7c5..def7dd4 100644 --- a/src/dde-grand-search-daemon/searcher/semantic/semanticworker.cpp +++ b/src/dde-grand-search-daemon/searcher/semantic/semanticworker.cpp @@ -174,13 +174,11 @@ bool SemanticWorker::working(void *context) dslStr.replace("'", "\""); dslStr.replace("WITH META_VALUE", "AND META_VALUE"); dslStr.replace("DIRECTORY_NAME IS", "PATH IS"); - qDebug() << QString("query(%1) => dsl(%2), spend(%3 ms)").arg(d->m_context).arg(dslStr).arg(d->m_time.elapsed()); + qInfo() << QString("query(%1) => dsl(%2), spend(%3 ms)").arg(d->m_context).arg(dslStr).arg(d->m_time.elapsed()); //dslStr = "((DATE >= CURRENT -\"5 minute\") AND (DATE <= \"CURRENT\")) AND (TYPE IS \"document\")"; // parse DSL - QList querys; - FileResultsHandler fileHandler; - DslParser parser(dslStr, &querys, &fileHandler, d); + DslParser parser(dslStr); entityList = parser.entityList(); for (int i = 0; i < entityList.size(); i++) { qDebug() << "entityList" << i << entityList[i].toString();