<commit_before># -*- coding: utf-8 -*-
"""
Based on https://github.com/baiyubin/pysuffix
by <NAME>
"""
from collections import namedtuple
import itertools
import re

import utilities.suffix_array.tools_karkkainen_sanders as tks


class InvalidCharacterException(Exception):
    pass


MB = namedtuple('MatchBlock',
                field_names=['a', 'b', 'l', 'passage'])


class MatchBlock(MB):
    """
    NamedTuple subclass for representing match blocks
    """

    def __hash__(self):
        return self[0] * self[1] * self[2]

    def __eq__(self, other):
        """
        Equals method that avoids comparing the string potion
        of matches
        """
        if self[0] != other[0]:
            return False
        elif self[1] != other[1]:
            return False
        elif self[2] != other[2]:
            return False
        return True


def acs_all(a, b, separator='$'):
    """
    Find all substrings in both a and b
    :param a: first string
    :param b: second string<commit_msg>add a comment<commit_after># -*- coding: utf-8 -*-
"""
Based on https://github.com/baiyubin/pysuffix
by <NAME>
"""
from collections import namedtuple
import itertools
import re

import utilities.suffix_array.tools_karkkainen_sanders as tks


class InvalidCharacterException(Exception):
    pass


MB = namedtuple('MatchBlock',
                field_names=['a', 'b', 'l', 'passage'])


class MatchBlock(MB):
    """
    NamedTuple subclass for representing match blocks
    """

    def __hash__(self):
        return self[0] * self[1] * self[2]

    def __eq__(self, other):
        """
        Equals method that avoids comparing the string potion
        of matches
        """
        if self[0] != other[0]:
            return False
        elif self[1] != other[1]:
            return False
        elif self[2] != other[2]:
            return False
        return True


# This is very slow, and as such is inaccessible
# should add option for using it or something similar later
def acs_all(a, b, separator='$'):
    """
    Find all substrings in both a and b
    :param a: first string
    :param b: second string
{'fraction_non_alphanumeric': 0.11194379391100702, 'fraction_numerical': 0.00936768149882904, 'mean_word_length': 2.4901960784313726, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 2, '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': '3083988', 'n_tokens_mistral': 651, 'n_tokens_neox': 616, 'n_words': 206}