<commit_before># -*- coding: utf-8 -*-


###############################################################################


from operator import add

from repoze.lru import LRUCache
from six import PY2, advance_iterator


###############################################################################


def distinct(iterable):
    distincts = set()
    for item in iterable:
        if item not in distincts:
            distincts.add(item)
            yield item


def partly_distinct(iterable):
    cache = LRUCache(10000)
    for item in iterable:
        if not cache.get(item):
            cache.put(item)
            yield item


def peek(iterable, function):
    for item in iterable:
        function(item)
        yield item


def seed(function, seed_value):
    yield seed_value
    while True:
        seed_value = function(seed_value)
        yield seed_value


if PY2:
    def accumulate(iterable, function=add):
        iterator = iter(iterable)
        total = advance_iterator(iterator)
        yield total
        for item in iterator:
            total = function(total, item)
            yield total
else:
    from itertools import accumulate<commit_msg>Fix Python 3.2 compatibility<commit_after># -*- coding: utf-8 -*-


###############################################################################


from operator import add
from sys import version_info

from repoze.lru import LRUCache
from six import advance_iterator


###############################################################################


def distinct(iterable):
    distincts = set()
    for item in iterable:
        if item not in distincts:
            distincts.add(item)
            yield item


def partly_distinct(iterable):
    cache = LRUCache(10000)
    for item in iterable:
        if not cache.get(item):
            cache.put(item)
            yield item


def peek(iterable, function):
    for item in iterable:
        function(item)
        yield item


def seed(function, seed_value):
    yield seed_value
    while True:
        seed_value = function(seed_value)
        yield seed_value


if version_info < (3, 3):
    def accumulate(iterable, function=add):
        iterator = iter(iterable)
        total = advance_iterator(iterator)
        yield total
        for item in iterator:
            total = function(total, item)
            yield total
else:
    from itertools import accumulate
{'fraction_non_alphanumeric': 0.19309196837286724, 'fraction_numerical': 0.00749063670411985, 'mean_word_length': 2.7503900156006242, 'pattern_counts': {'":': 0, '<': 4, '<?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': '4585720', 'n_tokens_mistral': 650, 'n_tokens_neox': 611, 'n_words': 191}