<commit_before>from collections import Counter
from bing_search_api import BingSearchAPI
my_key = "<KEY>"
bing = BingSearchAPI(my_key)

def main():
    print(search("Hello", 3))

# category='Web' or category='News'
def search(query_string, num_results, category='Web'):
    query_string = query_string.replace("#", "%23")
    params = {'ImageFilters':'"Face:Face"',
              '$format': 'json',
              '$top': num_results,
              '$skip': 0}
    results = bing.search(category,query_string,params).json() # requests 1.0+ 

    return [result['Url'] for result in results['d']['results'][0][category]]

def group_search(query_list, num_results, category='Web', on_wiki=True, exclude_twitter=True):
    url_counter = Counter()
    for query in query_list:
        if exclude_twitter == True:
            query += " -site:twitter.com"
        if on_wiki == True:
            query += " site:wikipedia.org"
        urls = search(query, num_results)
        for i in range(len(urls)):
            url = urls[i]
            url_counter[url] += float(1)/3**float(i)
        <commit_msg>Fixed a bug in searching news.<commit_after>from collections import Counter
from bing_search_api import BingSearchAPI
my_key = "<KEY>"
bing = BingSearchAPI(my_key)

def main():
    print(search("Hello", 3))

# category='Web' or category='News'
def search(query_string, num_results, category='Web'):
    query_string = query_string.replace("#", "%23")
    params = {'ImageFilters':'"Face:Face"',
              '$format': 'json',
              '$top': num_results,
              '$skip': 0}
    results = bing.search(category,query_string,params).json() # requests 1.0+ 

    return [result['Url'] for result in results['d']['results'][0][category]]

def group_search(query_list, num_results, category='Web', on_wiki=True, exclude_twitter=True):
    url_counter = Counter()
    for query in query_list:
        if exclude_twitter == True:
            query += " -site:twitter.com"
        if on_wiki == True:
            query += " site:wikipedia.org"
        urls = search(query, num_results, category)
        for i in range(len(urls)):
            url = urls[i]
            url_counter[url] += float(1)/3**float(i)

{'fraction_non_alphanumeric': 0.1482150926344329, 'fraction_numerical': 0.008133755083596927, 'mean_word_length': 3.177358490566038, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '7026141', 'n_tokens_mistral': 685, 'n_tokens_neox': 670, 'n_words': 160}