Пример #1
0
def test5():
    documents = {
        1:
        'to be or not to be that is the question',
        2:
        'to be a programmer means you do not eat or sleep, not leave your desk or beep or peep or bleep, you can only weep or sweep or use a heap'
    }
    inverted_index = InvertedIndex(documents).get_inverted_index()
    query_terms = ['to', 'be', 'or', 'not', 'to', 'be']
    top_k = 1
    topk_result, full_evaluation_count = WAND_Algo(query_terms, top_k,
                                                   inverted_index)
    print('Top-k result = ', topk_result)  # [(10, 1)]
    print('Evaluation Count = ', full_evaluation_count)  #2
Пример #2
0
    15:
    'Xbox power cable fire fear Microsoft has said it will replace more than 14 million power cables for its Xbox consoles due to safety concerns The company said the move was a preventative step after rep',
    16:
    'Global blogger action day called The global web blog community is being called into action to lend support to two imprisoned Iranian bloggers The month old Committee to Protect Bloggers is asking thos',
    17:
    'Finding new homes for old phones Re using old mobile phones is not just good for the environment it has social benefits too Research has found that in some developing nations old mobile phones can hel',
    18:
    'PlayStation 3 chip to be unveiled Details of the chip designed to power Sony s PlayStation 3 console will be released in San Francisco on Monday Sony IBM and Toshiba who have been working on the Cell ',
    19:
    'Intel unveils laser breakthrough Intel has unveiled research that could mean data is soon being moved around chips at the speed of light Scientists at Intel have overcome a fundamental problem that be',
    20:
    'Security scares spark browser fix Microsoft is working on a new version of its Internet Explorer web browser The revamp has been prompted by Microsoft s growing concern with security as well as increa'
}

## 1. Construct and get inverted_index
inverted_index = InvertedIndex(documents).get_inverted_index()


def test1(inverted_index):
    ## Test cases
    query_terms = ["the", "Ink"]
    top_k = 3

    ## 2. WAND algorithm...
    topk_result, full_evaluation_count = WAND_Algo(query_terms, top_k,
                                                   inverted_index)

    print('Top-k result = ', topk_result)  #[(8,1), (4,2), (4,3)]
    print('Evaluation Count = ', full_evaluation_count)  #4