diff --git a/file-utils.cpp b/file-utils.cpp index 4d52388..14b8797 100644 --- a/file-utils.cpp +++ b/file-utils.cpp @@ -185,18 +185,19 @@ QString FileUtils::find(const QString &hanzi) return output; } -void stitchMultiToneWordsDFS(const QString& hanzi, const QString& result, QStringList& resultList){ +void stitchMultiToneWordsDFS(const QString& hanzi, const QString& resultAllPinYin, const QString& resultFirst, QStringList& resultList){ if (hanzi.size() == 0){ - resultList.append(result); + resultList.append(resultAllPinYin); + resultList.append(resultFirst); 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); + stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), resultAllPinYin + i, resultFirst + i.at(0), resultList); } } else{ - stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), result + hanzi.at(0), resultList); + stitchMultiToneWordsDFS(hanzi.right(hanzi.size() - 1), resultAllPinYin + hanzi.at(0), resultFirst + hanzi.at(0), resultList); } } @@ -204,10 +205,10 @@ QStringList FileUtils::findMultiToneWords(const QString& hanzi) { // QStringList* output = new QStringList(); QStringList output; - QString temp; + QString tempAllPinYin, tempFirst; QStringList stringList = hanzi.split(""); - stitchMultiToneWordsDFS(hanzi, temp, output); + stitchMultiToneWordsDFS(hanzi, tempAllPinYin, tempFirst, output); // qDebug() << output; return output; } diff --git a/index/index-generator.cpp b/index/index-generator.cpp index e038490..0e29ebc 100644 --- a/index/index-generator.cpp +++ b/index/index-generator.cpp @@ -124,8 +124,9 @@ Document IndexGenerator::GenerateDocument(const QVector &list) // 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){ + //现加入首字母 + QStringList pinyin_text_list = FileUtils::findMultiToneWords(QString(list.at(0)).replace(".","")); + for (QString& i : pinyin_text_list){ i.replace("", " "); } @@ -148,7 +149,7 @@ Document IndexGenerator::GenerateDocument(const QVector &list) qDebug()<<"value!!!"<Traverse(); - QTime t2 = QTime::currentTime(); - qDebug() << t1; - qDebug() << t2; - im->start(); +// QTime t1 = QTime::currentTime(); +// InotifyManagerRefact* im = new InotifyManagerRefact("/home"); +// im->Traverse(); +// QTime t2 = QTime::currentTime(); +// qDebug() << t1; +// qDebug() << t2; +// im->start(); /*-------------Inotify Test End-----------------*/ this->setWindowFlags(Qt::CustomizeWindowHint | Qt::FramelessWindowHint | Qt::X11BypassWindowManagerHint);