<commit_before># -*- coding: utf-8 -*-
__author__ = "<NAME>"

import numpy as np

from lsh.cMinhash import minhash

class MinHasher(object):
    def __init__(self, seeds, char_ngram=8, random_state=None):
        """The MinHasher creates fingerprints from raw documents.

        The MinHasher facilitates the creation of MinHash document
        fingerprints. It creates overlapping character ngram shingles of length
        `char_ngram` using a sliding window over the document. To preprocessing
        to the documents is done, they are shingled as is.

        Parameters:
        -----------
        seeds: np.ndarray, int
            A Numpy array of 32bit unsigned integers to use as seeds to
            initialise hash functions, or a single integer for the number of
            seeds to create. A minhash is computed for each hash function
            derived from seeds.

        char_ngram: int
            The number of consecutive characters to include in a sliding window
            when creating the document shingles.

        random_state: None, int, np.random.RandomState
            A random state to initialise the random number generator with.
        """
        self._ngram  = char_ngram
        random_state = np.random.RandomState(random_state)
        if isinstance(seeds, np.ndarray):
            self._seeds = seeds
        else:
            np.random.seed(rand_seed)
            self._seeds = np.array(random_state.randint(0, 1e6, num_seeds),
                                   dtype=np.uint32)

        def fingerprint(self, text):
            fingerprint = minhash(text, len(text), self._seeds, self._ngram)
            return fingerprint
<commit_msg>Fixing typos and import errors.<commit_after># -*- coding: utf-8 -*-
__author__ = "<NAME>"

import numpy as np

from .cMinhash import minhash

class MinHasher(object):
    def __init__(self, seeds, char_ngram=8, random_state=None):
        """The MinHasher creates fingerprints from raw documents.

        The MinHasher facilitates the creation of MinHash document
        fingerprints. It creates overlapping character ngram shingles of length
        `char_ngram` using a sliding window over the document. To preprocessing
        to the documents is done, they are shingled as is.

        Parameters:
        -----------
        seeds: np.ndarray, int
            A Numpy array of 32bit unsigned integers to use as seeds to
            initialise hash functions, or a single integer for the number of
            seeds to create. A minhash is computed for each hash function
            derived from seeds.

        char_ngram: int
            The number of consecutive characters to include in a sliding window
            when creating the document shingles.

        random_state: None, int, np.random.RandomState
            A random state to initialise the random number generator with.
        """
        self._ngram  = char_ngram
        random_state = np.random.RandomState(random_state)
        if isinstance(seeds, np.ndarray):
            self._seeds = seeds
        else:
            self._seeds = np.array(random_state.randint(0, 1e6, seeds),
                                   dtype=np.uint32)

    def fingerprint(self, text):
        fingerprint = minhash(text, len(text), self._seeds, self._ngram)
        return fingerprint

{'fraction_non_alphanumeric': 0.06746626686656672, 'fraction_numerical': 0.005397301349325337, 'mean_word_length': 2.1862464183381087, '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': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2303794', 'n_tokens_mistral': 878, 'n_tokens_neox': 849, 'n_words': 329}