<commit_before>import sys
from freequery.repository.repository import Repository
from freequery.repository.document_index import DocumentIndex
from freequery.index.inverted_index import InvertedIndex

if len(sys.argv) not in (3,4,5):
    print "Usage: %s <repos> <invindex> [start-docid [end-docid]]" % sys.argv[0]
    exit(1)
    
repospath = sys.argv[1]
invindexpath = sys.argv[2]
start_docid = int(sys.argv[3])
end_docid = int(sys.argv[4])

repos = Repository(repospath)
invindex = InvertedIndex(invindexpath)

i = 1
for doc in repos:
    if doc.docid in range(start_docid, end_docid+1):
        doc.make_typed('text/html')
        print "%d. %s" % (i, doc.uri)
        invindex.add((doc,))
        i += 1

invindex.save()
invindex.close()
repos.close()



<commit_msg>break early after desired range of docids is processed<commit_after>import sys
from freequery.repository.repository import Repository
from freequery.repository.document_index import DocumentIndex
from freequery.index.inverted_index import InvertedIndex

if len(sys.argv) not in (3,4,5):
    print "Usage: %s <repos> <invindex> [start-docid [end-docid]]" % sys.argv[0]
    exit(1)
    
repospath = sys.argv[1]
invindexpath = sys.argv[2]
start_docid = int(sys.argv[3])
end_docid = int(sys.argv[4])

repos = Repository(repospath)
invindex = InvertedIndex(invindexpath)

i = 1
for doc in repos:
    if doc.docid in range(start_docid, end_docid+1):
        doc.make_typed('text/html')
        print "%d. %s" % (i, doc.uri)
        invindex.add((doc,))
        i += 1
    elif doc.docid > end_docid:
        break

invindex.save()
invindex.close()
repos.close()




{'fraction_non_alphanumeric': 0.12936848559166156, 'fraction_numerical': 0.014714898835070508, 'mean_word_length': 3.930513595166163, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 8, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7360092', 'n_tokens_mistral': 602, 'n_tokens_neox': 580, 'n_words': 138}