예제 #1
0
        indexSource = IndexSource.stored
        break

    print("Invalid option '" + indexOption + "', please choose again.")


# Index
index = Index(indexSource, ParserType.wordprocessing)
print(len(index.getDictionary().getTerms().keys()))
print("Time for creating the index: " + index.getTimer().getElapsedMillisecondsString() + "\n")

# Query
print("Query execution:")
print("You can leave the program by entering 'exit()'.\n")

queryParser = Parser(index.getParserType())
queryExecutor = QueryExecutor(index)

while True:
    query = input("Query: ")

    if query == "exit()":
        break

    # Execution of the query
    parsedQueries = queryParser.parseQuery(query)
    result = queryExecutor.executeQueries(parsedQueries)

    for item in result:
        print("\t " + item.getDocument().getPath() + ": " + str(item.getRank()))