

"""simple docstring"""




import enum
import shutil
import sys


SCREAMING_SNAKE_CASE_  ,  SCREAMING_SNAKE_CASE_     :			List[Any]	  =			shutil.get_terminal_size()

SCREAMING_SNAKE_CASE_     :			List[Any]	  =			{'''UP''': '''A''', '''DOWN''': '''B''', '''RIGHT''': '''C''', '''LEFT''': '''D'''}


class 		_A       (			enum.Enum					):
						__a								=	0
						__a								=	1






def 	UpperCAmelCase__   (				A__	,    A__=""   )      ->      Dict:




			"""simple docstring"""
			sys.stdout.write(str(_lowercase   ) + end   )
			sys.stdout.flush()



def 	UpperCAmelCase__   (				A__	,    A__	,    A__=""   )      ->      Tuple:




			"""simple docstring"""
			forceWrite(f'\u001b[{color}m{content}\u001b[0m'	,    _lowercase   )



def 	UpperCAmelCase__   (				)      ->      Optional[int]:




			"""simple docstring"""
			forceWrite("\r"   )



def 	UpperCAmelCase__   (				A__	,    A__   )      ->      int:




			"""simple docstring"""
			forceWrite(f'\033[{num_lines}{CURSOR_TO_CHAR[direction.upper()]}'   )



def 	UpperCAmelCase__   (				)      ->      Dict:




			"""simple docstring"""
			forceWrite(" " * TERMINAL_WIDTH   )
			reset_cursor()



def 	UpperCAmelCase__   (				)      ->      Dict:




			"""simple docstring"""
			reset_cursor()
			forceWrite("-" * TERMINAL_WIDTH   )







"""simple docstring"""




import os
import unittest

from transformers.models.phobert.tokenization_phobert import VOCAB_FILES_NAMES, PhobertTokenizer

from ...test_tokenization_common import TokenizerTesterMixin


class 		_A       (			__a				,       unittest.TestCase					):
      __a								=	PhobertTokenizer
      __a								=	False





      def 					_lowerCamelCase  (  self		)   ->					Any:
         super().setUp()

         # Adapted from Sennrich et al. 2015 and https://github.com/rsennrich/subword-nmt
         lowerCamelCase__						=			["T@@", "i", "I", "R@@", "r", "e@@"]
         lowerCamelCase__						=			dict(zip(SCREAMING_SNAKE_CASE__    ,						range(len(SCREAMING_SNAKE_CASE__		)		)		)		)
         lowerCamelCase__						=			["#version: 0.2", "l à</w>"]
         lowerCamelCase__						=			{"unk_token": "<unk>"}

         lowerCamelCase__						=			os.path.join(self.tmpdirname    ,						VOCAB_FILES_NAMES["vocab_file"]		)
         lowerCamelCase__						=			os.path.join(self.tmpdirname    ,						VOCAB_FILES_NAMES["merges_file"]		)

         with open(self.vocab_file    ,						"w"    ,						encoding="utf-8"		) as fp:
            for token in vocab_tokens:
               fp.write(f'{token} {vocab_tokens[token]}\n'		)
         with open(self.merges_file    ,						"w"    ,						encoding="utf-8"		) as fp:
            fp.write("\n".join(SCREAMING_SNAKE_CASE__		)		)





      def 					_lowerCamelCase  (  self    ,						**SCREAMING_SNAKE_CASE__		)   ->					Tuple:
         kwargs.update(self.special_tokens_map		)
         return PhobertTokenizer.from_pretrained(self.tmpdirname    ,						**SCREAMING_SNAKE_CASE__		)





      def 					_lowerCamelCase  (  self    ,						SCREAMING_SNAKE_CASE__		)   ->					Tuple:
         lowerCamelCase__						=			"Tôi là VinAI Research"
         lowerCamelCase__						=			"T<unk> i <unk> <unk> <unk> <unk> <unk> <unk> I Re<unk> e<unk> <unk> <unk> <unk>"
         return input_text, output_text





      def 					_lowerCamelCase  (  self		)   ->					Tuple:
         lowerCamelCase__						=			PhobertTokenizer(self.vocab_file    ,						self.merges_file    ,						**self.special_tokens_map		)
         lowerCamelCase__						=			"Tôi là VinAI Research"
         lowerCamelCase__						=			"T@@ ô@@ i l@@ à V@@ i@@ n@@ A@@ I R@@ e@@ s@@ e@@ a@@ r@@ c@@ h".split()
         lowerCamelCase__						=			tokenizer.tokenize(SCREAMING_SNAKE_CASE__		)
         print(SCREAMING_SNAKE_CASE__		)
         self.assertListEqual(SCREAMING_SNAKE_CASE__    ,						SCREAMING_SNAKE_CASE__		)

         lowerCamelCase__						=			tokens + [tokenizer.unk_token]

         lowerCamelCase__						=			[4, 3, 5, 3, 3, 3, 3, 3, 3, 6, 7, 9, 3, 9, 3, 3, 3, 3, 3]
         self.assertListEqual(tokenizer.convert_tokens_to_ids(SCREAMING_SNAKE_CASE__		)    ,						SCREAMING_SNAKE_CASE__		)




