Ce serveur Gitlab sera éteint le 30 juin 2020, pensez à migrer vos projets vers les serveurs gitlab-research.centralesupelec.fr et gitlab-student.centralesupelec.fr !

Commit 05d0381c authored by Dos Santos David's avatar Dos Santos David

improve index commands

parent 859b1c0b
......@@ -2,24 +2,27 @@
def run_index_command(parser, tokenizer, indexer, args):
if args.index_command == 'build':
print('loading the documents...')
print('... loading the documents...')
count_documents = 0
for document in parser.find_documents(limit=10):
for doc_id, document in enumerate(parser.find_documents(limit=None)):
count_documents += 1
tokens = tokenizer.get_tokens(document)
indexer.add_document_tokens(document.document_id, tokens)
indexer.add_document_tokens(doc_id, tokens)
print('{} documents loaded'.format(count_documents))
print('... {} documents loaded'.format(count_documents))
print('index built')
if args.index_command == 'lookup':
doc_ids = indexer.token_lookup(args.token[0])
token = args.token[0]
doc_ids = indexer.token_lookup(token)
if doc_ids:
print("{token} present in documents {doc_ids}".format(
doc_ids=", ".join(map(str, doc_ids))
print('no result :(')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment