forked from openkylin/ukui-search
[Fix] Delete folder won't success.
This commit is contained in:
parent
6465ea2457
commit
3aeaa46b2d
|
@ -23,7 +23,7 @@ void Document::setData(QString data)
|
|||
m_document->set_data(data.toStdString());
|
||||
}
|
||||
|
||||
void Document::addterm(std::string term,QVector<size_t> offset, int weight)
|
||||
void Document::addPosting(std::string term,QVector<size_t> offset, int weight)
|
||||
{
|
||||
if(term == "")
|
||||
return;
|
||||
|
@ -36,6 +36,13 @@ void Document::addterm(std::string term,QVector<size_t> offset, int weight)
|
|||
}
|
||||
}
|
||||
|
||||
void Document::addTerm(QString term)
|
||||
{
|
||||
if(term.isEmpty())
|
||||
return;
|
||||
m_document->add_term(term.toStdString());
|
||||
}
|
||||
|
||||
void Document::addValue(QString value)
|
||||
{
|
||||
m_document->add_value(1,value.toStdString());
|
||||
|
@ -49,7 +56,6 @@ void Document::setUniqueTerm(QString term)
|
|||
|
||||
m_unique_term = new QString(term);
|
||||
}
|
||||
|
||||
std::string Document::getUniqueTerm()
|
||||
{
|
||||
// qDebug()<<"m_unique_term!"<<*m_unique_term;
|
||||
|
|
|
@ -12,7 +12,8 @@ public:
|
|||
Document();
|
||||
~Document();
|
||||
void setData(QString data);
|
||||
void addterm(std::string term, QVector<size_t> offset, int weight =1);
|
||||
void addPosting(std::string term, QVector<size_t> offset, int weight =1);
|
||||
void addTerm(QString term);
|
||||
void addValue(QString value);
|
||||
void setUniqueTerm(QString term);
|
||||
std::string getUniqueTerm();
|
||||
|
|
|
@ -216,6 +216,7 @@ Document IndexGenerator::GenerateDocument(const QVector<QString> &list)
|
|||
}
|
||||
|
||||
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath));
|
||||
QString upTerm = QString::fromStdString(FileUtils::makeDocUterm(sourcePath.section("/",0,-2,QString::SectionIncludeLeadingSep)));
|
||||
// QString uniqueterm1 = QString::fromStdString(QCryptographicHash::hash(sourcePath.toUtf8(),QCryptographicHash::Md5).toStdString());
|
||||
/*--------------------------------------------------------------------*/
|
||||
//QByteArray 和 QString 之间会进行隐式转换,造成字符串被截断等意想不到的后果!!!!!!! zpf
|
||||
|
@ -229,6 +230,7 @@ Document IndexGenerator::GenerateDocument(const QVector<QString> &list)
|
|||
Document doc;
|
||||
doc.setData(sourcePath);
|
||||
doc.setUniqueTerm(uniqueterm);
|
||||
doc.addTerm(upTerm);
|
||||
doc.addValue(list.at(2));
|
||||
QStringList temp;
|
||||
temp.append(index_text);
|
||||
|
@ -244,14 +246,17 @@ Document IndexGenerator::GenerateContentDocument(const QString &path)
|
|||
QString content;
|
||||
FileReader::getTextContent(path,content);
|
||||
QString uniqueterm = QString::fromStdString(FileUtils::makeDocUterm(path));
|
||||
QString upTerm = QString::fromStdString(FileUtils::makeDocUterm(path.section("/",0,-2,QString::SectionIncludeLeadingSep)));
|
||||
|
||||
QVector<SKeyWord> term = ChineseSegmentation::getInstance()->callSegement(&content);
|
||||
Document doc;
|
||||
doc.setData(content);
|
||||
doc.setUniqueTerm(uniqueterm);
|
||||
doc.addTerm(upTerm);
|
||||
doc.addValue(path);
|
||||
for(int i = 0;i<term.size();++i)
|
||||
{
|
||||
doc.addterm(term.at(i).word,term.at(i).offsets,static_cast<int>(term.at(i).weight));
|
||||
doc.addPosting(term.at(i).word,term.at(i).offsets,static_cast<int>(term.at(i).weight));
|
||||
|
||||
}
|
||||
return doc;
|
||||
|
|
Loading…
Reference in New Issue