Ejemplo n.º 1
0
    doc_id = document['id']
    tokens = []
    tokens = tokenize(document['title'])
    body = tokenize(document['body'])
    tokens.extend(body)


    # Metadata
    global max_doc
    max_doc += 1
    doc_length[document['id']] = len(document['title']) + len(document['body'])


    for token in tokens
        add_token_to_index(token, doc_id)

def create_index()
    for document in read_documents()

        add_to_index(document)
    print (Created index with size {}.format(len(inverted_index)))

creat_synonyms_list()
create_index()

if __name__ == '__main__'
    all_queries = [query for query in read_queries() if query['query number'] != 0]
    for query in all_queries
        documents = search_query(query)
        print (Query{} and Results{}.format(query, documents))
Ejemplo n.º 2
0
def create_index():
    for document in read_documents():
        add_to_index(document)
    print("Created index with size {}".format(len(inverted_index)))
Ejemplo n.º 3
0
def create_index():
    global doc_count
    for document in read_documents():
        doc_count += 1
        add_to_index(document)
    print("Created index with size {}".format(len(inverted_index)))