//! [2] void MainWindow::on_queryBox_currentIndexChanged() { QFile queryFile(":/queries/" + queryBox->currentText()); queryFile.open(QIODevice::ReadOnly); queryEdit->setPlainText(QString::fromLatin1(queryFile.readAll())); evaluateResult(); }
int main() { clock_t start,finish; time_t tStart,tFinish; double totaltime; tStart = time(&tStart); start = clock(); //将训练集下的文本分词后,保存为myDic.txt(DF词典)和myTFDic(TF词典) //myParagraphProcess("E:\\finalData\\1_train",myDicPath,myTFDicPath); //卡方检验特征选择 //chiFeatureSelect(myDicPath); //期望交叉熵特征选择——从词频词典中选取 //expectedCrossEntrophyFeatureSelect(myTFDicPath); /*myParagraphProcessToVSM(textTrainDataPath,VSMDesPath); myParagraphProcessToVSM(textTestDataPath,VSMtestDesPath);*/ //基于CHI特征向量将训练和测试文本向量化——记得 去掉 宏定义_CROSS //myParagraphProcessToVSM(textTrainDataPath,textOfTrainVSMOnCHI); //myParagraphProcessToVSM(textTestDataPath,textOfTestVSMOnCHI); //基于ECE特征向量将训练和测试文本向量化——记得 加上 宏定义_CROSS //myParagraphProcessToVSM(textTrainDataPath,textOfTrainVSMOnCross); //myParagraphProcessToVSM(textTestDataPath,textOfTestVSMOnCross); //基于CHI特征向量将训练和测试文本向量化(Bayes)——记得 去掉 宏定义_CROSS //myTextToVSMforNaiveBayes(textTestDataPath,naiveBayesOfTestVSMOnCHI); //基于ECE特征向量将训练和测试文本向量化(Bayes)——记得 加上 宏定义_CROSS //myTextToVSMforNaiveBayes(textTestDataPath,naiveBayesOfTestVSMOnCross); //基于CHI特征向量的KNN分类——记得 去掉 宏定义_CROSS //KNN(textOfTrainVSMOnCHI,textOfTestVSMOnCHI); //基于ECE特征向量的KNN分类——记得 加上 宏定义_CROSS //KNN(textOfTrainVSMOnCross,textOfTestVSMOnCross); //基于CHI特征向量的NB分类——记得 去掉 宏定义_CROSS //naiveBayes(naiveBayesOfTestVSMOnCHI); //基于ECE特征向量的NB分类——记得 加上 宏定义_CROSS naiveBayes(naiveBayesOfTestVSMOnCross); evaluateResult(artNum,P,8); finish = clock(); tFinish = time(&tFinish); totaltime = (finish - start) / CLOCKS_PER_SEC; cout<<totaltime-(totaltime/60)*60<<"秒 "<<"运行时间:"<<tFinish - tStart<<endl; return 0; }
void MainWindow::loadDirectory(const QString &directory) { Q_ASSERT(QDir(directory).exists()); m_fileNode = m_fileTree.nodeFor(directory); QXmlQuery query(m_namePool); query.bindVariable("fileTree", m_fileNode); query.setQuery(QUrl("qrc:/queries/wholeTree.xq")); QByteArray output; QBuffer buffer(&output); buffer.open(QIODevice::WriteOnly); QXmlFormatter formatter(query, &buffer); query.evaluateTo(&formatter); treeInfo->setText((QString(tr("%1 rendered as XML.")).arg(directory))); fileTree->setText(QString::fromLatin1(output.constData())); evaluateResult(); }