
"""simple docstring"""





import os
import re
from shutil import copyfile
from typing import List, Optional, Tuple

from ...tokenization_utils import PreTrainedTokenizer
from ...utils import logging


__magic_name__       =			logging.get_logger(__name__)

__magic_name__       =			{
    "vocab_file": "vocab.txt",
    "merges_file": "bpe.codes",
}

__magic_name__       =			{
    "vocab_file": {
        "vinai/phobert-base": "https://huggingface.co/vinai/phobert-base/resolve/main/vocab.txt",
        "vinai/phobert-large": "https://huggingface.co/vinai/phobert-large/resolve/main/vocab.txt",
    },
    "merges_file": {
        "vinai/phobert-base": "https://huggingface.co/vinai/phobert-base/resolve/main/bpe.codes",
        "vinai/phobert-large": "https://huggingface.co/vinai/phobert-large/resolve/main/bpe.codes",
    },
}

__magic_name__       =			{
    "vinai/phobert-base": 256,
    "vinai/phobert-large": 256,
}



def 						_lowerCAmelCase				(				UpperCamelCase_				):
		__SCREAMING_SNAKE_CASE            = set()
		__SCREAMING_SNAKE_CASE            = word[0]
		for char in word[1:]:
				pairs.add((prev_char, char)				)
				__SCREAMING_SNAKE_CASE            = char

		__SCREAMING_SNAKE_CASE            = set(UpperCamelCase_				)
		return pairs
class 						SCREAMING_SNAKE_CASE_ (						__a ):




		"""simple docstring"""





		__lowercase							:  Optional[Any]						   =		VOCAB_FILES_NAMES
		__lowercase							:  Dict						   =		PRETRAINED_VOCAB_FILES_MAP
		__lowercase							:  Any						   =		PRETRAINED_POSITIONAL_EMBEDDINGS_SIZES




		def __init__(     self							,  lowerCAmelCase__							,  lowerCAmelCase__							,  lowerCAmelCase__="<s>"							,  lowerCAmelCase__="</s>"							,  lowerCAmelCase__="</s>"							,  lowerCAmelCase__="<s>"							,  lowerCAmelCase__="<unk>"							,  lowerCAmelCase__="<pad>"							,  lowerCAmelCase__="<mask>"							,  **lowerCAmelCase__							,  ):
				super().__init__(
				    bos_token=lowerCAmelCase__							,  eos_token=lowerCAmelCase__							,  unk_token=lowerCAmelCase__							,  sep_token=lowerCAmelCase__							,  cls_token=lowerCAmelCase__							,  pad_token=lowerCAmelCase__							,  mask_token=lowerCAmelCase__							,  **lowerCAmelCase__							,  )

				__SCREAMING_SNAKE_CASE            = vocab_file
				__SCREAMING_SNAKE_CASE            = merges_file

				__SCREAMING_SNAKE_CASE            = {}
				__SCREAMING_SNAKE_CASE            = 0
				__SCREAMING_SNAKE_CASE            = 1
				__SCREAMING_SNAKE_CASE            = 2
				__SCREAMING_SNAKE_CASE            = 3

				self.add_from_file(lowerCAmelCase__)

				__SCREAMING_SNAKE_CASE            = {v: k for k, v in self.encoder.items()}

				with open(lowerCAmelCase__							,  encoding="""utf-8""") as merges_handle:
						__SCREAMING_SNAKE_CASE            = merges_handle.read().split("""\n""")[:-1]
				__SCREAMING_SNAKE_CASE            = [tuple(merge.split()[:-1]) for merge in merges]
				__SCREAMING_SNAKE_CASE            = dict(zip(lowerCAmelCase__							,  range(len(lowerCAmelCase__))))
				__SCREAMING_SNAKE_CASE            = {}




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__ = None):

				if token_ids_a is None:
						return [self.cls_token_id] + token_ids_a + [self.sep_token_id]
				__SCREAMING_SNAKE_CASE            = [self.cls_token_id]
				__SCREAMING_SNAKE_CASE            = [self.sep_token_id]
				return cls + token_ids_a + sep + sep + token_ids_a + sep




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__ = None							,  lowerCAmelCase__ = False):

				if already_has_special_tokens:
						return super().get_special_tokens_mask(
						    token_ids_a=lowerCAmelCase__							,  token_ids_a=lowerCAmelCase__							,  already_has_special_tokens=lowerCAmelCase__)

				if token_ids_a is None:
						return [1] + ([0] * len(lowerCAmelCase__)) + [1]
				return [1] + ([0] * len(lowerCAmelCase__)) + [1, 1] + ([0] * len(lowerCAmelCase__)) + [1]




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__ = None):
				__SCREAMING_SNAKE_CASE            = [self.sep_token_id]
				__SCREAMING_SNAKE_CASE            = [self.cls_token_id]

				if token_ids_a is None:
						return len(cls + token_ids_a + sep) * [0]
				return len(cls + token_ids_a + sep + sep + token_ids_a + sep) * [0]




		@property
		def 	snake_case_     (     self):
				return len(self.encoder)




		def 	snake_case_     (     self):
				return dict(self.encoder							,  **self.added_tokens_encoder)




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				if token in self.cache:
						return self.cache[token]
				__SCREAMING_SNAKE_CASE            = tuple(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = tuple(list(word[:-1]) + [word[-1] + """</w>"""])
				__SCREAMING_SNAKE_CASE            = get_pairs(lowerCAmelCase__)

				if not pairs:
						return token

				while True:
						__SCREAMING_SNAKE_CASE            = min(lowerCAmelCase__							,  key=lambda lowerCAmelCase__: self.bpe_ranks.get(lowerCAmelCase__							,  float("""inf""")))
						if bigram not in self.bpe_ranks:
								break
						__SCREAMING_SNAKE_CASE       ,__SCREAMING_SNAKE_CASE            = bigram
						__SCREAMING_SNAKE_CASE            = []
						__SCREAMING_SNAKE_CASE            = 0
						while i < len(lowerCAmelCase__):
								try:
										__SCREAMING_SNAKE_CASE            = word.index(lowerCAmelCase__							,  lowerCAmelCase__)
								except ValueError:
										new_word.extend(word[i:])
										break
								else:
										new_word.extend(word[i:j])
										__SCREAMING_SNAKE_CASE            = j

								if word[i] == first and i < len(lowerCAmelCase__) - 1 and word[i + 1] == second:
										new_word.append(first + second)
										i += 2
								else:
										new_word.append(word[i])
										i += 1
						__SCREAMING_SNAKE_CASE            = tuple(lowerCAmelCase__)
						__SCREAMING_SNAKE_CASE            = new_word
						if len(lowerCAmelCase__) == 1:
								break
						else:
								__SCREAMING_SNAKE_CASE            = get_pairs(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = """@@ """.join(lowerCAmelCase__)
				__SCREAMING_SNAKE_CASE            = word[:-4]
				__SCREAMING_SNAKE_CASE            = word
				return word




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = []

				__SCREAMING_SNAKE_CASE            = re.findall(R"""\S+\n?"""							,  lowerCAmelCase__)

				for token in words:
						split_tokens.extend(list(self.bpe(lowerCAmelCase__).split(""" """)))
				return split_tokens




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				return self.encoder.get(lowerCAmelCase__							,  self.encoder.get(self.unk_token))




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				return self.decoder.get(lowerCAmelCase__							,  self.unk_token)




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				__SCREAMING_SNAKE_CASE            = """ """.join(lowerCAmelCase__).replace("""@@ """							,  """""").strip()
				return out_string




		def 	snake_case_     (     self							,  lowerCAmelCase__							,  lowerCAmelCase__ = None):
				if not os.path.isdir(lowerCAmelCase__):
						logger.error(f"Vocabulary path ({save_directory}) should be a directory")
						return
				__SCREAMING_SNAKE_CASE            = os.path.join(
				    lowerCAmelCase__							,  (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""vocab_file"""])
				__SCREAMING_SNAKE_CASE            = os.path.join(
				    lowerCAmelCase__							,  (filename_prefix + """-""" if filename_prefix else """""") + VOCAB_FILES_NAMES["""merges_file"""])

				if os.path.abspath(self.vocab_file) != os.path.abspath(lowerCAmelCase__):
						copyfile(self.vocab_file							,  lowerCAmelCase__)

				if os.path.abspath(self.merges_file) != os.path.abspath(lowerCAmelCase__):
						copyfile(self.merges_file							,  lowerCAmelCase__)

				return out_vocab_file, out_merge_file




		def 	snake_case_     (     self							,  lowerCAmelCase__):
				if isinstance(lowerCAmelCase__							,  lowerCAmelCase__):
						try:
								with open(lowerCAmelCase__							,  """r"""							,  encoding="""utf-8""") as fd:
										self.add_from_file(lowerCAmelCase__)
						except FileNotFoundError as fnfe:
								raise fnfe
						except UnicodeError:
								raise Exception(f"Incorrect encoding detected in {f}, please rebuild the dataset")
						return

				__SCREAMING_SNAKE_CASE            = f.readlines()
				for lineTmp in lines:
						__SCREAMING_SNAKE_CASE            = lineTmp.strip()
						__SCREAMING_SNAKE_CASE            = line.rfind(""" """)
						if idx == -1:
								raise ValueError("""Incorrect dictionary format, expected '<token> <cnt>'""")
						__SCREAMING_SNAKE_CASE            = line[:idx]
						__SCREAMING_SNAKE_CASE            = len(self.encoder)






"""simple docstring"""





import requests
from bsa import BeautifulSoup



def 						_lowerCAmelCase				(				UpperCamelCase_ = "AAPL"				):
		__SCREAMING_SNAKE_CASE            = f"https://in.finance.yahoo.com/quote/{symbol}?s={symbol}"
		__SCREAMING_SNAKE_CASE            = BeautifulSoup(requests.get(UpperCamelCase_				).text  ,				"""html.parser"""				)
		__SCREAMING_SNAKE_CASE            = """My(6px) Pos(r) smartphone_Mt(6px)"""
		return soup.find("""div"""  ,				class_=class_				).find("""span"""				).text


if __name__ == "__main__":
							for symbol in "AAPL AMZN IBM GOOG MSFT ORCL".split():
														print(F"""Current {symbol:<4} stock price is {stock_price(symbol):>8}""")




