<commit_before>import sys
import os
import time
import requests
import gzip
import json
import conf


if __name__ == '__main__':
    total = 0
    count = 0
    t0 = time.time()
    for fname in os.listdir(sys.argv[1]):
        if fname.endswith('.gz'):
            with gzip.open(os.path.join(sys.argv[1], fname)) as f:
                response = requests.post(conf.ES_URL + '/test/_percolate', 
                    data=json.dumps({'doc': {'text': f.read()}}))
                assert response.status_code == 200
                total += response.json()['total']
                count += 1

                print fname, response.json()['total']

#                 query_ids = [x['_id'] for x in response.json()['matches']]
#                 query_ids.sort()
#                 print '\n'.join(query_ids)
    
    t1 = time.time()
    print 'matched {0} queries for {1} documents in {2:.2f}s ({3:.2f} docs/s)'.format(
        total, count, t1-t0, count / (t1-t0))

<commit_msg>fixed<commit_after>import sys
import os
import time
import requests
import gzip
import json
import conf


if __name__ == '__main__':
    total = 0
    count = 0
    t0 = time.time()
    for fname in os.listdir(sys.argv[1]):
        if fname.endswith('.gz'):
            with gzip.open(os.path.join(sys.argv[1], fname)) as f:
                response = requests.post(conf.ES_URL + '%s/doc/_percolate' % conf.ES_DB,
                    data=json.dumps({'doc': {'text': f.read()}}))
                assert response.status_code == 200
                total += response.json()['total']
                count += 1

                print fname, response.json()['total']


#                 query_ids = [x['_id'] for x in response.json()['matches']]
#                 query_ids.sort()
#                 print '\n'.join(query_ids)
    
    t1 = time.time()
    print 'matched {0} queries for {1} documents in {2:.2f}s ({3:.2f} docs/s)'.format(
        total, count, t1-t0, count / (t1-t0))


{'fraction_non_alphanumeric': 0.15270684371807966, 'fraction_numerical': 0.020429009193054137, 'mean_word_length': 1.9238805970149253, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, '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': '4655025', 'n_tokens_mistral': 672, 'n_tokens_neox': 630, 'n_words': 155}