diff options
Diffstat (limited to 'kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp')
-rw-r--r-- | kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp | 86 |
1 files changed, 43 insertions, 43 deletions
diff --git a/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp b/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp index 0ca040e8..466b68e5 100644 --- a/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp +++ b/kbabel/kbabeldict/modules/dbsearchengine2/algorithms.cpp @@ -10,20 +10,20 @@ // // #include "algorithms.h" -#include <qstringlist.h> +#include <tqstringlist.h> #include <kdebug.h> //FIXME: remove #define i18n (const char*) -DataBaseInterface::ResultList ExactSearchAlgorithm::exec(const QString& query ) +DataBaseInterface::ResultList ExactSearchAlgorithm::exec(const TQString& query ) { DataBaseInterface::ResultList res; DataBaseInterface::MainEntry e=di->get(query,0); - QStringList trs=e.second.getTranslations(); + TQStringList trs=e.second.getTranslations(); - for(QStringList::iterator it=trs.begin();it!=trs.end();++it) + for(TQStringList::iterator it=trs.begin();it!=trs.end();++it) { emit newResult(QueryResult(*it,e.first.getString(),settings->scoreExact)); @@ -35,19 +35,19 @@ DataBaseInterface::ResultList ExactSearchAlgorithm::exec(const QString& query ) } -DataBaseInterface::ResultList GenericSearchAlgorithm::exec(const QString& query ) +DataBaseInterface::ResultList GenericSearchAlgorithm::exec(const TQString& query ) { DataBaseInterface::ResultList res; // ExactSearchAlgorithm exact(query,settings); uint countResults=0; - for(QValueList<AbstractSearchAlgorithm *>::iterator algoit = algoChain.begin(); algoit!=algoChain.end() && countResults < maxResults; algoit++) + for(TQValueList<AbstractSearchAlgorithm *>::iterator algoit = algoChain.begin(); algoit!=algoChain.end() && countResults < maxResults; algoit++) { - connect(*algoit,SIGNAL(newResult(QueryResult)),this,SIGNAL(newResult(QueryResult))); + connect(*algoit,TQT_SIGNAL(newResult(QueryResult)),this,TQT_SIGNAL(newResult(QueryResult))); kdDebug(0) << "Algo pointer" << (*algoit) << endl; res+=(*algoit)->exec(query); countResults=res.count(); kdDebug(0) << "Count = " << countResults << endl; - disconnect(*algoit,SIGNAL(newResult(QueryResult)),this,SIGNAL(newResult(QueryResult))); + disconnect(*algoit,TQT_SIGNAL(newResult(QueryResult)),this,TQT_SIGNAL(newResult(QueryResult))); } return res; } @@ -57,7 +57,7 @@ void GenericSearchAlgorithm::addAlgorithm( AbstractSearchAlgorithm * algo ) algoChain.append(algo); } -DataBaseInterface::ResultList AlphaSearchAlgorithm::exec( const QString & query ) +DataBaseInterface::ResultList AlphaSearchAlgorithm::exec( const TQString & query ) { DataBaseInterface::ResultList res; DBItemMultiIndex::IndexList il=di->getAlpha(query); @@ -65,8 +65,8 @@ DataBaseInterface::ResultList AlphaSearchAlgorithm::exec( const QString & query for(DBItemMultiIndex::IndexList::iterator it=il.begin();it!=il.end()&&!di->stopNow();++it) { DataBaseInterface::MainEntry e=di->getFromIndex(*it); - QStringList trs=e.second.getTranslations(); - for(QStringList::iterator it=trs.begin();it!=trs.end() && !di->stopNow();++it) + TQStringList trs=e.second.getTranslations(); + for(TQStringList::iterator it=trs.begin();it!=trs.end() && !di->stopNow();++it) { QueryResult r(di->format(di->simple(*it,true),query),e.first.getString(),settings->scoreAlpha); emit newResult(r); @@ -78,17 +78,17 @@ DataBaseInterface::ResultList AlphaSearchAlgorithm::exec( const QString & query return res; } -DataBaseInterface::ResultList SentenceArchiveSearchAlgorithm::exec( const QString & query ) +DataBaseInterface::ResultList SentenceArchiveSearchAlgorithm::exec( const TQString & query ) { DataBaseInterface::ResultList res; DataBaseInterface::MainEntry e = di->getSentence(query); - QStringList trs=e.second.getTranslations(); + TQStringList trs=e.second.getTranslations(); kdDebug(0) << "Count in sentence archive " << trs.count()<< endl; - for(QStringList::iterator it=trs.begin();it!=trs.end();++it) + for(TQStringList::iterator it=trs.begin();it!=trs.end();++it) { QueryResult r(di->format(di->simple(*it,true),query),e.first.getString(),settings->scoreSentence); emit newResult(r); @@ -100,31 +100,31 @@ DataBaseInterface::ResultList SentenceArchiveSearchAlgorithm::exec( const QStrin return res; } -DataBaseInterface::ResultList ChunkByChunkSearchAlgorithm::exec( const QString & query ) +DataBaseInterface::ResultList ChunkByChunkSearchAlgorithm::exec( const TQString & query ) { ResultList res; factory->setQuery(query); - QPtrList<AbstractChunk> chunks=factory->chunks(); + TQPtrList<AbstractChunk> chunks=factory->chunks(); kdDebug(0) << "Number of chunks " << chunks.count() << endl; chunks.setAutoDelete(true); //I should delete the chunks myself - QStringList querySeparators=factory->separators(); + TQStringList querySeparators=factory->separators(); //This prevents recursive loop. if (chunks.count()<=1) return res; - QStringList translations,tmpTranslations; + TQStringList translations,tmpTranslations; translations.push_back(""); //FIXME this is needed to start , but is not good int finalscore=0; int i=0; - QMap<QString,bool> translationUsed; + TQMap<TQString,bool> translationUsed; //Loop on all chunk for(AbstractChunk *it=chunks.first();it && !di->stopNow(); it=chunks.next()) { kdDebug(0) << "Process next chunk" << endl; int chunkscore=0; - QValueList<QueryResult> r=it->translations(); + TQValueList<QueryResult> r=it->translations(); kdDebug(0) << "Number of results for this chunk " << r.count() << endl; if(r.count()<1) { @@ -144,14 +144,14 @@ DataBaseInterface::ResultList ChunkByChunkSearchAlgorithm::exec( const QString & translationUsed.clear(); for(ResultList::iterator it1=r.begin();it1!=r.end() &&!di->stopNow(); ++it1) { - QString chunkTranslation= (*it1).result(); + TQString chunkTranslation= (*it1).result(); if(!translationUsed.contains(chunkTranslation)) { translationUsed[chunkTranslation]=true; kdDebug(0) << "a translation is: " << chunkTranslation << endl; - for(QStringList::iterator it2=translations.begin();it2!=translations.end() && !di->stopNow() ; it2++) + for(TQStringList::iterator it2=translations.begin();it2!=translations.end() && !di->stopNow() ; it2++) { - QString prevTranslation=*it2; + TQString prevTranslation=*it2; tmpTranslations.push_back(prevTranslation+chunkTranslation+querySeparators[i]); kdDebug(0) << "..appending it to " << prevTranslation << endl; } @@ -176,9 +176,9 @@ DataBaseInterface::ResultList ChunkByChunkSearchAlgorithm::exec( const QString & if (finalscore<50) return res; - for(QStringList::iterator it2=translations.begin();it2!=translations.end() && !di->stopNow() ; it2++) + for(TQStringList::iterator it2=translations.begin();it2!=translations.end() && !di->stopNow() ; it2++) { - QString theTranslation=*it2; + TQString theTranslation=*it2; QueryResult qr(di->format(theTranslation,query),i18n("CHUNK BY CHUNK"),finalscore); qr.setRichOriginal(i18n("<h3>Chunk by chunk</h3>CHANGE THIS TEXT!!!!This translation is" "obtained translating the sentences and using a" @@ -211,22 +211,22 @@ FuzzyChunkSearchAlgorithm::FuzzyChunkSearchAlgorithm( DataBaseInterface * dbi, D } -DataBaseInterface::ResultList FuzzyChunkSearchAlgorithm::exec( const QString & query ) +DataBaseInterface::ResultList FuzzyChunkSearchAlgorithm::exec( const TQString & query ) { //FIXME: this code is shit too ResultList res; factory->setQuery(query); - QPtrList<AbstractChunk> querychunks = factory->chunks(); + TQPtrList<AbstractChunk> querychunks = factory->chunks(); querychunks.setAutoDelete(true); - typedef QMap<QString,QValueList<unsigned int> > ResultMap; + typedef TQMap<TQString,TQValueList<unsigned int> > ResultMap; ResultMap rmap; //result of words index query unsigned int notfound=0,frequent=0,nchunks = querychunks.count(); //Get index list for each word for(AbstractChunk *it=querychunks.first(); it &&!di->stopNow() ; it=querychunks.next() ) { - QValueList<uint> locations = (*it).locationReferences(); + TQValueList<uint> locations = (*it).locationReferences(); if(locations.count()>0) { @@ -246,10 +246,10 @@ DataBaseInterface::ResultList FuzzyChunkSearchAlgorithm::exec( const QString & q //Now we have a map (rmap) "word in query->list of occurency" - QValueList<unsigned int>::iterator countpos[nchunks+1]; + TQValueList<unsigned int>::iterator countpos[nchunks+1]; - QValueList<unsigned int> il; + TQValueList<unsigned int> il; for(int i = 0;i<=nchunks&&!di->stopNow();i++) countpos[i]=il.end(); @@ -310,12 +310,12 @@ DataBaseInterface::ResultList FuzzyChunkSearchAlgorithm::exec( const QString & q int bestscore=0; for(unsigned int wf=nchunks;wf>0;wf-- ){ - for(QValueList<unsigned int>::iterator it=countpos[wf];it!=countpos[wf-1] ;++it) + for(TQValueList<unsigned int>::iterator it=countpos[wf];it!=countpos[wf-1] ;++it) { //loop on entries with same number of word found DataBaseInterface::MainEntry e; e=di->getFromIndex(*it); - QStringList trs=e.second.getTranslations(); - for(QStringList::iterator it=trs.begin();it!=trs.end()&&!di->stopNow();++it) + TQStringList trs=e.second.getTranslations(); + for(TQStringList::iterator it=trs.begin();it!=trs.end()&&!di->stopNow();++it) { unsigned int cinr=factory->chunks(*it).count(); //chunk in result //compute a score, lets kbabel sort now, it should be fast... @@ -326,11 +326,11 @@ DataBaseInterface::ResultList FuzzyChunkSearchAlgorithm::exec( const QString & q // kdDebug(0) << "s: "<<score << " wf: "<<wf<<" nwords: "<<nwords<<" winr: "<<winr // <<" 90*wf/nwords: "<<90*wf/nwords << " -:" << 90*(((nwords-winr)>0)?(nwords-winr):(winr-nwords))/(nwords*10)<< endl; // FIXME: format better the richtext - QString ori=e.first.getString(); - QString re=di->format(di->simple(*it,true),query); + TQString ori=e.first.getString(); + TQString re=di->format(di->simple(*it,true),query); QueryResult r(re,ori,score); - for(QPtrListIterator<AbstractChunk> it(querychunks); it.current() && di->stopNow() ; ++it){ - ori=ori.replace(QRegExp((*it)->chunkString(),false),"<font color=#000080><u><b>"+(*it)->chunkString()+"</b></u></font>"); + for(TQPtrListIterator<AbstractChunk> it(querychunks); it.current() && di->stopNow() ; ++it){ + ori=ori.replace(TQRegExp((*it)->chunkString(),false),"<font color=#000080><u><b>"+(*it)->chunkString()+"</b></u></font>"); } r.setRichOriginal(ori); if(!di->stopNow()) @@ -344,16 +344,16 @@ DataBaseInterface::ResultList FuzzyChunkSearchAlgorithm::exec( const QString & q } -DataBaseInterface::ResultList CorrelationSearchAlgorithm::exec( const QString & query ) +DataBaseInterface::ResultList CorrelationSearchAlgorithm::exec( const TQString & query ) { //FIXME, this code is shit. DataBaseInterface::ResultList res; if(di->words(query).count()>1) return res; - QMap<QString,float> corRes = di->correlation(query,0,false); + TQMap<TQString,float> corRes = di->correlation(query,0,false); float max=0,max1=0,max2=0; - QString best,best1,best2; + TQString best,best1,best2; - for(QMap<QString,float>::iterator it = corRes.begin(); it !=corRes.end(); ++it) + for(TQMap<TQString,float>::iterator it = corRes.begin(); it !=corRes.end(); ++it) { if(it.data()>max) { @@ -414,7 +414,7 @@ SingleWordSearchAlgorithm::SingleWordSearchAlgorithm( DataBaseInterface * dbi, D addAlgorithm(&corr); } -DataBaseInterface::ResultList SingleWordSearchAlgorithm::exec( const QString & query ) +DataBaseInterface::ResultList SingleWordSearchAlgorithm::exec( const TQString & query ) { if(di->words(query).count()>1) return ResultList(); |