Ejemplo n.º 1
0
        index = lemmatizer.lemmatize(index)
        if index not in posting_list:
            posting_list[index] = [0, []]
        posting_list[index][0] += 1
        if f not in posting_list[index][1]:
            posting_list[index][1].append(f)
#Constructing bitmap from query
query_string = input("Enter query string:\n")
query_string = query_string.lower()
connect_word = []
query_word = []
for i in query_string.split():
    if i != 'and' and i != 'or' and i != 'not':
        query_word.append(i)
    else:
        connect_word.append(lemmatizer.lematize(i))
bitmap = pandas.DataFrame(columns=corpus_list, index=query_word)
for word in query_word:
    for doc in corpus_list:
        if word not in posting_list:
            bitmap[doc][word] = 0
        elif doc in posting_list[word][1]:
            bitmap[doc][word] = 1
        else:
            bitmap[doc][word] = 0
#Query bitmap
all_query = []
single_query = []
i = 0
bit = 1
while i < len(query_word):