Adds support for special symbols in file index and search.

This commit is contained in:
zhangpengfei 2021-01-27 18:22:50 +08:00
parent 510568b9c5
commit 2d6a208dc4
3 changed files with 22 additions and 10 deletions

6
debian/changelog vendored
View File

@ -1,3 +1,9 @@
ukui-search (0.0.1+0127) v101; urgency=medium
* Bugs Fixed.
-- zhangpengfei <zhangpengfei@kylinos.cn> Wed, 27 Jan 2021 14:25:07 +0800
ukui-search (0.0.1+0126) v101; urgency=medium ukui-search (0.0.1+0126) v101; urgency=medium
* Bugs Fixed. * Bugs Fixed.

View File

@ -3,6 +3,7 @@
#include "chinese-segmentation.h" #include "chinese-segmentation.h"
#include <QDebug> #include <QDebug>
#include <QThread> #include <QThread>
#include <QUrl>
//extern QList<Document> *_doc_list_path; //extern QList<Document> *_doc_list_path;
//extern QMutex _mutex_doc_list_path; //extern QMutex _mutex_doc_list_path;
@ -25,11 +26,6 @@ void ConstructDocumentForPath::run()
// qDebug()<<_doc_list_path->size(); // qDebug()<<_doc_list_path->size();
QString index_text = m_list.at(0); QString index_text = m_list.at(0);
QString sourcePath = m_list.at(1); QString sourcePath = m_list.at(1);
index_text = index_text.replace(""," ");
index_text = index_text.simplified();
//不带多音字版
// QString pinyin_text = FileUtils::find(QString(list.at(0)).replace(".","")).replace("", " ").simplified();
//多音字版 //多音字版
//现加入首字母 //现加入首字母
@ -47,10 +43,19 @@ void ConstructDocumentForPath::run()
doc.setUniqueTerm(uniqueterm); doc.setUniqueTerm(uniqueterm);
doc.addTerm(upTerm); doc.addTerm(upTerm);
doc.addValue(m_list.at(2)); doc.addValue(m_list.at(2));
QStringList temp; /* QStringList temp;
temp.append(index_text); // temp.append(index_text);
temp.append(pinyin_text_list); temp.append(pinyin_text_list)*/;
doc.setIndexText(temp); doc.setIndexText(pinyin_text_list);
int postingCount = 0;
while(postingCount < index_text.size())
{
QVector<size_t> p;
p.append(postingCount);
doc.addPosting(QUrl::toPercentEncoding(index_text.at(postingCount)).toStdString(),p);
++postingCount;
}
// QMetaObject::invokeMethod(m_indexGenerator,"appendDocListPath",Q_ARG(Document,doc)); // QMetaObject::invokeMethod(m_indexGenerator,"appendDocListPath",Q_ARG(Document,doc));
_mutex_doc_list_path.lock(); _mutex_doc_list_path.lock();
_doc_list_path->append(doc); _doc_list_path->append(doc);

View File

@ -3,6 +3,7 @@
#include <QtConcurrent> #include <QtConcurrent>
#include <QThread> #include <QThread>
#include <chinese-segmentation.h> #include <chinese-segmentation.h>
#include <QUrl>
#include "file-searcher.h" #include "file-searcher.h"
#include "global-settings.h" #include "global-settings.h"
@ -222,7 +223,7 @@ Xapian::Query FileSearcher::creatQueryForFileSearch(QString keyword, Xapian::Dat
std::vector<Xapian::Query> v; std::vector<Xapian::Query> v;
for(int i=0;i<userInput.size();i++) for(int i=0;i<userInput.size();i++)
{ {
v.push_back(Xapian::Query(QString(userInput.at(i)).toStdString())); v.push_back(Xapian::Query(QUrl::toPercentEncoding(userInput.at(i)).toStdString()));
// qDebug()<<QString::fromStdString(Xapian::Query(QString(userInput.at(i)).toStdString()).get_description()); // qDebug()<<QString::fromStdString(Xapian::Query(QString(userInput.at(i)).toStdString()).get_description());
} }
Xapian::Query queryPhrase =Xapian::Query(Xapian::Query::OP_PHRASE, v.begin(), v.end()); Xapian::Query queryPhrase =Xapian::Query(Xapian::Query::OP_PHRASE, v.begin(), v.end());