Пример #1
0
def multi_string_matching_naive(texto, patrones):
    texto = encode_string(texto)
    resultado = []
    for patron in patrones:
        patron = encode_string(patron)
        resultado.append(naive_matching(patron, texto))
    return resultado
Пример #2
0
def string_matching_dc3(text, pattern):
    text = encode_string(text)
    text.append(0)
    pattern = encode_string(pattern)
    suffix_array = dcm(text)
    result = binary_search_pattern(pattern, suffix_array, text)

    return result
Пример #3
0
def string_matching_naive(texto, patron):
    """Devuelve una lista con las posiciones en texto
    donde aparece patron completo utilizando el algoritmo naive."""

    texto = encode_string(texto)
    patron = encode_string(patron)

    return naive_matching(patron, texto)
Пример #4
0
def multiple_string_matching_dc3(text, patterns):
    text = encode_string(text)
    text.append(0)

    suffix_array = dcm(text, max(text))

    result = []

    for pattern in patterns:
        pattern = encode_string(pattern)
        result.append(binary_search_pattern(pattern, suffix_array, text))

    return result
Пример #5
0
def karpRabinUnitario(texto, patron, base, mod):
    matches = []
    patron = encode_string(patron)
    texto = encode_string(texto)
    hash_patron = kr_rolling_hash(patron, 0, len(patron), 0, base, mod)
    hash_tent = 0

    for x in range(len(texto) - (len(patron) - 1)):
        hash_tent = kr_rolling_hash(texto, x, x + len(patron), hash_tent, base,
                                    mod)
        if (hash_tent == hash_patron):
            if (cmpSubLista(patron, texto, x)):
                matches.append(x)

    return matches
Пример #6
0
def karpRabinMultiple(texto, patrones, base, mod):
    matches = [[] for x in range(len(patrones))]
    patrones = [encode_string(patron) for patron in patrones]
    texto = encode_string(texto)
    hash_patrones = [
        kr_rolling_hash(patron, 0, len(patron), 0, base, 1000)
        for patron in patrones
    ]
    hash_tent = [0 for x in range(len(patrones))]

    min_len = len(min(patrones, key=len))

    for x in range(len(texto) - (min_len - 1)):
        hash_tent = [
            kr_rolling_hash(texto, x, x + len(patrones[i]), hash_tent[i], base,
                            mod) for i in range(len(patrones))
        ]
        for y in range(len(hash_tent)):
            if hash_tent[y] == hash_patrones[y]:
                if cmpSubLista(patrones[y], texto, x):
                    matches[y].append(x)

    return matches
Пример #7
0
def do_nothing(text, pattern):
    text = encode_string(text)
    pattern = encode_string(pattern)
    return None
Пример #8
0
 def export_lte(self, output_filename: Union[str, Path]) -> None:
     with open(output_filename, 'wb') as f:
         for player in self.players:
             name = f'{player.first_name} {player.last_name}'
             player_desc = f'{name: <36}{player.rating: <6.2f}{player.team: <25}'
             f.write(encode_string(player_desc))
Пример #9
0
 def export_nag(self, output_filename: Union[str, Path]) -> None:
     with open(output_filename, 'wb') as f:
         f.write(encode_string(self.name))
def do_nothing(text, patterns):
    text = encode_string(text)
    for pattern in patterns:
        pattern = encode_string(pattern)
    return None