当前位置: 首页>>代码示例>>C++>>正文


C++ FileParser::getTerms方法代码示例

本文整理汇总了C++中FileParser::getTerms方法的典型用法代码示例。如果您正苦于以下问题:C++ FileParser::getTerms方法的具体用法?C++ FileParser::getTerms怎么用?C++ FileParser::getTerms使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FileParser的用法示例。


在下文中一共展示了FileParser::getTerms方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: search

string Mediator::search(IndexWrapper::indexItem index, string toSearch)
{
    Key* k = NULL;
    string toReturn;
    list<int>* bookIds;
    //string separator;
    //list<string> wordsToFind;
    FileParser* fp;
    map<string, Term*> wordsToFind;
    list<Word*> words;
    list<int>* coincidenceDocs = NULL;
    list<int>* notCoincidenceDocs = NULL;
    list<BookGlobalWeight*>* bookByGlobalWeight = NULL;
    bool doSearch = false;
    int totalBooks;

    switch(index){
        case IndexWrapper::EDITORIAL:
            k = new Key(toSearch);
            bookIds = this->indexWrapper->searchAllIds(k, index);
            break;
        case IndexWrapper::AUTOR:
            k = new Key(toSearch);
            bookIds = this->indexWrapper->searchAllIds(k, index);
            break;
        case IndexWrapper::TITULO:
            k = new Key(toSearch);
            bookIds = this->indexWrapper->searchAllIds(k, index);
            break;
        case IndexWrapper::PALABRAS:
        {
            bookIds = new list<int>();

            //separator = " ";
            //wordsToFind = Utility::split(toSearch, separator);

            fp = new FileParser();
            fp->setWords(toSearch);
            wordsToFind = fp->getTerms();
            delete fp;

            // Se recorre todas las palabras de las busqueda, y se buscan en el hash
            for(map<string, Term*>::iterator it = wordsToFind.begin(); it != wordsToFind.end(); ++it)
            {
                Key* k = new Key((*it).first);
                list<int>* booksWords = this->indexWrapper->searchAllIds(k, index);
                Word* newWord = new Word((*it).first, booksWords);
                words.push_back(newWord);
                if (newWord->getBooks()->size() > 0)
                    doSearch = true;
                delete k;
            }

            if (wordsToFind.size()>0 && doSearch)
            {
                //Obtiene los libros en que se encuentran en todas las palabras
                coincidenceDocs = this->findCoincidences(words);
                if (coincidenceDocs->size() > 0)
                {
                    list<RankingBook>* listRanking;
                    listRanking = findTermProxIdBooks(coincidenceDocs,words);
                    list<RankingBook>::iterator itRanking;

                    cout << "Ids book Encontrados por Terminos Proximos: ";
                    for(itRanking=listRanking->begin();itRanking!=listRanking->end();++itRanking)
                    {
                        int idBook = (*itRanking).getIdBook();
                        cout << idBook << " ";
                        bookIds->push_back(idBook);
                    }
                    cout << endl;
                }

                //Obtiene los libros que se encuentran solo algunas de las palabras
                notCoincidenceDocs = this->findNotCoincidences(words, coincidenceDocs);
                if (notCoincidenceDocs->size() > 0)
                {
                    //Ordena los documentos que no tienen coincidencia total en los terminos segun el peso global
                    totalBooks = coincidenceDocs->size() + notCoincidenceDocs->size();
                    bookByGlobalWeight = this->orderBookByGlobalWeight(notCoincidenceDocs, words, totalBooks);

                    cout << "Ids book Encontrados por Peso Global: ";
                    for(list<BookGlobalWeight*>::iterator itGW = bookByGlobalWeight->begin(); itGW!=bookByGlobalWeight->end(); ++itGW)
                    {
                        int idBook = (*itGW)->getIdBook();
                        cout << idBook << " ";
                        bookIds->push_back(idBook);
                    }
                    cout << endl;
                }
            }

            break;
        }
        default:
            break;
    }

    if(bookIds->size() > 0){
        for (list<int>::iterator it = bookIds->begin(); it != bookIds->end(); ++it)
//.........这里部分代码省略.........
开发者ID:busiris2014,项目名称:7506Condor1C2014,代码行数:101,代码来源:Mediator.cpp


注:本文中的FileParser::getTerms方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。