



class 				_snake_case			:




				def __init__(						self					:						Union[str, Any]						):
							lowercase__					  =				""
							lowercase__					  =				""
							lowercase__					  =				[]




				def 							A__      (						self					:						Optional[Any],					__lowercase					:						int,					__lowercase					:						int						):
							if m == -1:
										return n + 1
							elif n == -1:
										return m + 1
							elif self.dp[m][n] > -1:
										return self.dp[m][n]
							else:
										if self.worda[m] == self.worda[n]:
													lowercase__					  =				self.__min_dist_top_down_dp(m - 1,					n - 1						)
										else:
													lowercase__					  =				self.__min_dist_top_down_dp(__lowercase,					n - 1						)
													lowercase__					  =				self.__min_dist_top_down_dp(m - 1,					__lowercase						)
													lowercase__					  =				self.__min_dist_top_down_dp(m - 1,					n - 1						)
													lowercase__					  =				1 + min(__lowercase,					__lowercase,					__lowercase						)

										return self.dp[m][n]




				def 							A__      (						self					:						Optional[Any],					__lowercase					:						str,					__lowercase					:						str						):
							lowercase__					  =				worda
							lowercase__					  =				worda
							lowercase__					  =				[[-1 for _ in range(len(__lowercase						)						)] for _ in range(len(__lowercase						)						)]

							return self.__min_dist_top_down_dp(len(__lowercase						) - 1,					len(__lowercase						) - 1						)




				def 							A__      (						self					:						List[str],					__lowercase					:						str,					__lowercase					:						str						):
							lowercase__					  =				worda
							lowercase__					  =				worda
							lowercase__					  =				len(__lowercase						)
							lowercase__					  =				len(__lowercase						)
							lowercase__					  =				[[0 for _ in range(n + 1						)] for _ in range(m + 1						)]

							for i in range(m + 1						):
										for j in range(n + 1						):
													if i == 0:  # first string is empty
																lowercase__					  =				j
													elif j == 0:  # second string is empty
																lowercase__					  =				i
													elif worda[i - 1] == worda[j - 1]:  # last characters are equal
																lowercase__					  =				self.dp[i - 1][j - 1]
													else:
																lowercase__					  =				self.dp[i][j - 1]
																lowercase__					  =				self.dp[i - 1][j]
																lowercase__					  =				self.dp[i - 1][j - 1]
																lowercase__					  =				1 + min(__lowercase,					__lowercase,					__lowercase						)
							return self.dp[m][n]


if __name__ == "__main__":
							lowercase_								=     EditDistance()

							print("""****************** Testing Edit Distance DP Algorithm ******************""")
							print()

							lowercase_								=     input("""Enter the first string: """).strip()
							lowercase_								=     input("""Enter the second string: """).strip()

							print()
							print(F'The minimum edit distance is: {solver.min_dist_top_down(Sa, Sa)}')
							print(F'The minimum edit distance is: {solver.min_dist_bottom_up(Sa, Sa)}')
							print()
							print("""*************** End of Testing Edit Distance DP Algorithm ***************""")









import json
from typing import Iterator, List, Union

from tokenizers import AddedToken, Regex, Tokenizer, decoders, normalizers, pre_tokenizers, trainers
from tokenizers.implementations.base_tokenizer import BaseTokenizer
from tokenizers.models import Unigram
from tokenizers.processors import TemplateProcessing
class 				_snake_case			(					lowercase__):




				def __init__(						self					:						Optional[Any],					__lowercase					:						str = "▁",					__lowercase					:						bool = True,					__lowercase					:						Union[str, AddedToken] = "<unk>",					__lowercase					:						Union[str, AddedToken] = "</s>",					__lowercase					:						Union[str, AddedToken] = "<pad>",					):
							lowercase__					  =				{
							    "pad": {"id": 0, "token": pad_token},
							    "eos": {"id": 1, "token": eos_token},
							    "unk": {"id": 2, "token": unk_token},
							}

							lowercase__					  =				[None] * len(self.special_tokens						)
							for token_dict in self.special_tokens.values():
										lowercase__					  =				token_dict["token"]

							lowercase__					  =				Tokenizer(Unigram()						)

							lowercase__					  =				normalizers.Sequence(
							    [
							        normalizers.Nmt(),
							        normalizers.NFKC(),
							        normalizers.Replace(Regex(" {2,}"						),					" "						),
							        normalizers.Lowercase(),
							    ]						)
							lowercase__					  =				pre_tokenizers.Sequence(
							    [
							        pre_tokenizers.Metaspace(replacement=__lowercase,					add_prefix_space=__lowercase						),
							        pre_tokenizers.Digits(individual_digits=__lowercase						),
							        pre_tokenizers.Punctuation(),
							    ]						)
							lowercase__					  =				decoders.Metaspace(replacement=__lowercase,					add_prefix_space=__lowercase						)

							lowercase__					  =				TemplateProcessing(
							    single=F'''$A {self.special_tokens["eos"]["token"]}''',					special_tokens=[(self.special_tokens["eos"]["token"], self.special_tokens["eos"]["id"])],					)

							lowercase__					  =				{
							    "model": "SentencePieceUnigram",
							    "replacement": replacement,
							    "add_prefix_space": add_prefix_space,
							}

							super().__init__(__lowercase,					__lowercase						)




				def 							A__      (						self					:						Union[str, Any],					__lowercase					:						Union[str, List[str]],					__lowercase					:						int = 8000,					__lowercase					:						bool = True,					):
							lowercase__					  =				trainers.UnigramTrainer(
							    vocab_size=__lowercase,					special_tokens=self.special_tokens_list,					show_progress=__lowercase,					)

							if isinstance(__lowercase,					__lowercase						):
										lowercase__					  =				[files]
							self._tokenizer.train(__lowercase,					trainer=__lowercase						)

							self.add_unk_id()




				def 							A__      (						self					:						List[Any],					__lowercase					:						Union[Iterator[str], Iterator[Iterator[str]]],					__lowercase					:						int = 8000,					__lowercase					:						bool = True,					):
							lowercase__					  =				trainers.UnigramTrainer(
							    vocab_size=__lowercase,					special_tokens=self.special_tokens_list,					show_progress=__lowercase,					)

							self._tokenizer.train_from_iterator(__lowercase,					trainer=__lowercase						)

							self.add_unk_id()




				def 							A__      (						self					:						str						):
							lowercase__					  =				json.loads(self._tokenizer.to_str()						)

							lowercase__					  =				self.special_tokens["unk"]["id"]

							lowercase__					  =				Tokenizer.from_str(json.dumps(__lowercase						)						)




