⚡⚡⚡ add multitone words file name search
This commit is contained in:
parent
a493cd716e
commit
d00118331b
|
@ -184,3 +184,30 @@ QString FileUtils::find(const QString &hanzi)
|
||||||
|
|
||||||
return output;
|
return output;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void stitchMultiToneWordsDFS(const QString& hanzi, const QString& result, QStringList& resultList){
|
||||||
|
if (hanzi.size() == 0){
|
||||||
|
resultList.append(result);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
if (FileUtils::map_chinese2pinyin.contains(hanzi.at(0))){
|
||||||
|
for (auto i : FileUtils::map_chinese2pinyin[hanzi.at(0)]){
|
||||||
|
stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), result + i, resultList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), result + hanzi.at(0), resultList);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
QStringList FileUtils::findMultiToneWords(const QString& hanzi)
|
||||||
|
{
|
||||||
|
// QStringList* output = new QStringList();
|
||||||
|
QStringList output;
|
||||||
|
QString temp;
|
||||||
|
QStringList stringList = hanzi.split("");
|
||||||
|
|
||||||
|
stitchMultiToneWordsDFS(hanzi, temp, output);
|
||||||
|
// qDebug() << output;
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
|
|
@ -26,6 +26,7 @@ public:
|
||||||
|
|
||||||
//chinese character to pinyin
|
//chinese character to pinyin
|
||||||
static QString find(const QString&);
|
static QString find(const QString&);
|
||||||
|
static QStringList findMultiToneWords(const QString&);
|
||||||
static void loadHanziTable(const QString&);
|
static void loadHanziTable(const QString&);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -117,8 +117,18 @@ Document IndexGenerator::GenerateDocument(const QVector<QString> &list)
|
||||||
QString sourcePath = list.at(1);
|
QString sourcePath = list.at(1);
|
||||||
index_text = index_text.replace(".","").replace(""," ");
|
index_text = index_text.replace(".","").replace(""," ");
|
||||||
index_text = index_text.simplified();
|
index_text = index_text.simplified();
|
||||||
QString pinyin_text = FileUtils::find(index_text.replace(".", "")).replace("", " ");
|
//这个应该是写错了
|
||||||
pinyin_text = pinyin_text.simplified();
|
// QString pinyin_text = FileUtils::find(index_text.replace(".", "")).replace("", " ");
|
||||||
|
|
||||||
|
//不带多音字版
|
||||||
|
// QString pinyin_text = FileUtils::find(QString(list.at(0)).replace(".","")).replace("", " ").simplified();
|
||||||
|
|
||||||
|
//多音字版
|
||||||
|
QStringList pintin_text_list = FileUtils::findMultiToneWords(QString(list.at(0)).replace(".",""));
|
||||||
|
for (QString& i : pintin_text_list){
|
||||||
|
i.replace("", " ");
|
||||||
|
}
|
||||||
|
|
||||||
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath));
|
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath));
|
||||||
// QString uniqueterm1 = QString::fromStdString(QCryptographicHash::hash(sourcePath.toUtf8(),QCryptographicHash::Md5).toStdString());
|
// QString uniqueterm1 = QString::fromStdString(QCryptographicHash::hash(sourcePath.toUtf8(),QCryptographicHash::Md5).toStdString());
|
||||||
/*--------------------------------------------------------------------*/
|
/*--------------------------------------------------------------------*/
|
||||||
|
@ -136,7 +146,11 @@ Document IndexGenerator::GenerateDocument(const QVector<QString> &list)
|
||||||
doc.addValue(list.at(2));
|
doc.addValue(list.at(2));
|
||||||
if(list.at(2) == QString("1"))
|
if(list.at(2) == QString("1"))
|
||||||
qDebug()<<"value!!!"<<list.at(2);
|
qDebug()<<"value!!!"<<list.at(2);
|
||||||
doc.setIndexText(QStringList()<<index_text<<pinyin_text);
|
QStringList temp;
|
||||||
|
temp.append(index_text);
|
||||||
|
temp.append(pintin_text_list);
|
||||||
|
doc.setIndexText(temp);
|
||||||
|
// doc.setIndexText(QStringList()<<index_text<<pinyin_text);
|
||||||
// doc.setIndexText(QStringList()<<index_text);
|
// doc.setIndexText(QStringList()<<index_text);
|
||||||
return doc;
|
return doc;
|
||||||
|
|
||||||
|
|
|
@ -18,12 +18,12 @@ void testTraverse(void){
|
||||||
/*-------------Inotify Test End-----------------*/
|
/*-------------Inotify Test End-----------------*/
|
||||||
|
|
||||||
/*-------------PinyinSearch Test Start---------------*/
|
/*-------------PinyinSearch Test Start---------------*/
|
||||||
QTime t1 = QTime::currentTime();
|
// QTime t1 = QTime::currentTime();
|
||||||
QString test("test");
|
// QString test("test");
|
||||||
qDebug() << IndexGenerator::IndexSearch(test);
|
// qDebug() << IndexGenerator::IndexSearch(test);
|
||||||
QTime t2 = QTime::currentTime();
|
// QTime t2 = QTime::currentTime();
|
||||||
qDebug() << t1;
|
// qDebug() << t1;
|
||||||
qDebug() << t2;
|
// qDebug() << t2;
|
||||||
/*-------------PinyinSearch Test End-----------------*/
|
/*-------------PinyinSearch Test End-----------------*/
|
||||||
|
|
||||||
/*-------------InotyifyRefact Test Start---------------*/
|
/*-------------InotyifyRefact Test Start---------------*/
|
||||||
|
|
|
@ -50,17 +50,16 @@ extern void qt_blurImage(QImage &blurImage, qreal radius, bool quality, int tran
|
||||||
MainWindow::MainWindow(QWidget *parent) :
|
MainWindow::MainWindow(QWidget *parent) :
|
||||||
QMainWindow(parent)
|
QMainWindow(parent)
|
||||||
{
|
{
|
||||||
FileTypeFilter* ftf = new FileTypeFilter("/home");
|
// FileUtils::findMultiToneWords("翟康宁test");
|
||||||
ftf->getTargetFileAbsolutePath();
|
/*-------------Inotify Test Start---------------*/
|
||||||
|
QTime t1 = QTime::currentTime();
|
||||||
/*-------------InotyifyRefact Test Start---------------*/
|
InotifyManagerRefact* im = new InotifyManagerRefact("/home");
|
||||||
// QTime t1 = QTime::currentTime();
|
im->Traverse();
|
||||||
// InotifyManagerRefact* imr = new InotifyManagerRefact("/home");
|
QTime t2 = QTime::currentTime();
|
||||||
// imr->start();
|
qDebug() << t1;
|
||||||
// QTime t2 = QTime::currentTime();
|
qDebug() << t2;
|
||||||
// qDebug() << t1;
|
im->start();
|
||||||
// qDebug() << t2;
|
/*-------------Inotify Test End-----------------*/
|
||||||
/*-------------InotyifyRefact Test End-----------------*/
|
|
||||||
|
|
||||||
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);
|
||||||
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
this->setAttribute(Qt::WA_TranslucentBackground, true);
|
||||||
|
|
Loading…
Reference in New Issue