示例#1
0
    config = CommandLine()
    if config.exit:
        sys.exit(0)
    #print(config.indexFile)
    index = IndexLoader(config.indexFile).getIndex()
    #config.termWeighting is the query type
    #print(index)
    retrieve = Retrieve(index, config.termWeighting)
    #print(retrieve)
    #print(config.queriesFile)
    queries = Queries(config.queriesFile)
    #print(config.outfile)
    allResults = ResultStore(config.outfile)
    #print(queries.qids())
    #print(retrieve.forQuery(queries.getQuery(1)))

    t = MyTimer()
    t.start('retrieval')

    for qid in queries.qids():
        #print(qid)
        query = queries.getQuery(qid)
        #print(query)
        results = retrieve.forQuery(query)  #Edit this command in the file
        allResults.store(qid, results)
        #if qid == 2:
        #    break
    t.stopPrint('retrieval')
    allResults.output()
示例#2
0
        if len(docids) > 10:
            docids = docids[:10]  #截取前10
        self.results.append((qid, docids))

    def output(self):
        with open(self.outfile, 'w') as out:
            for (qid, docids) in self.results:
                for docid in docids:
                    print(qid, docid, file=out)


#==============================================================================
# MAIN

if __name__ == '__main__':
    starttime = timer()
    config = CommandLine()
    if config.exit:
        sys.exit(0)
    index = IndexLoader(config.indexFile).getIndex()
    retrieve = Retrieve(index, config.termWeighting)
    queries = Queries(config.queriesFile)
    allResults = ResultStore(config.outfile)
    for qid in queries.qids():
        query = queries.getQuery(qid)
        results = retrieve.forQuery(query)
        allResults.store(qid, results)

    allResults.output()
    print('TIME: %.2fs' % (timer() - starttime))
示例#3
0
            docids = docids[:10]
        self.results.append((qid, docids))

    def output(self):
        with open(self.outfile, 'w') as out:
            for (qid, docids) in self.results:
                for docid in docids:
                    print(qid, docid, file=out)


#==============================================================================
# MAIN

if __name__ == '__main__':

    config = CommandLine()
    if config.exit:
        sys.exit(0)
    index = IndexLoader(config.indexFile).getIndex()
    retrieve = Retrieve(index,
                        config.termWeighting)  #interaction with my_retriever
    queries = Queries(config.queriesFile)
    allResults = ResultStore(config.outfile)

    for qid in queries.qids():
        query = queries.getQuery(qid)
        results = retrieve.forQuery(query)  #interaction with my_retriever
        allResults.store(qid, results)

    allResults.output()