





"""simple docstring"""



import unittest

from transformers import load_tool

from .test_tools_common import ToolTesterMixin


a_					=     """
Hugging Face was founded in 2016 by French entrepreneurs Clément Delangue, Julien Chaumond, and Thomas Wolf originally as a company that developed a chatbot app targeted at teenagers.[2] After open-sourcing the model behind the chatbot, the company pivoted to focus on being a platform for machine learning.

In March 2021, Hugging Face raised $40 million in a Series B funding round.[3]

On April 28, 2021, the company launched the BigScience Research Workshop in collaboration with several other research groups to release an open large language model.[4] In 2022, the workshop concluded with the announcement of BLOOM, a multilingual large language model with 176 billion parameters.[5]
"""






class 						__snake_case   (						unittest.TestCase				,				SCREAMING_SNAKE_CASE__	):





 """simple docstring"""


 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		Any							=	load_tool('''text-question-answering'''    )
     self.tool.setup()
     __A       :		Optional[int]							=	load_tool('''text-question-answering'''   ,		remote=__lowerCamelCase    )

 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		Dict							=	self.tool(__lowerCamelCase   ,		'''What did Hugging Face do in April 2021?'''    )
     self.assertEqual(__lowerCamelCase   ,		'''launched the BigScience Research Workshop'''    )

 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		Union[str, Any]							=	self.remote_tool(__lowerCamelCase   ,		'''What did Hugging Face do in April 2021?'''    )
     self.assertEqual(__lowerCamelCase   ,		'''launched the BigScience Research Workshop'''    )

 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		Tuple							=	self.tool(text=__lowerCamelCase   ,		question='''What did Hugging Face do in April 2021?'''    )
     self.assertEqual(__lowerCamelCase   ,		'''launched the BigScience Research Workshop'''    )







 def    UpperCamelCase__(       self    ):



     '''simple docstring'''




     __A       :		Tuple							=	self.remote_tool(text=__lowerCamelCase   ,		question='''What did Hugging Face do in April 2021?'''    )
     self.assertEqual(__lowerCamelCase   ,		'''launched the BigScience Research Workshop'''    )











"""simple docstring"""



def 						__lowercase	(  snake_case_    :    str							,snake_case_    :    str		)  ->float:



    '''simple docstring'''







    def get_matched_characters(snake_case_    :    str							,snake_case_    :    str		) -> str:
        __A       :		Any							=	[]
        __A       :		Any							=	min(len(_stra		)							,len(_stra		)		) // 2
        for i, l in enumerate(_stra		):
            __A       :		Dict							=	int(max(0							,i - limit		)		)
            __A       :		Tuple							=	int(min(i + limit + 1							,len(_stra		)		)		)
            if l in _stra[left:right]:
                matched.append(snake_case_		)
                __A       :		Any							=	F"""{_stra[0:_stra.index(snake_case_		)]} {_stra[_stra.index(snake_case_		) + 1:]}"""

        return "".join(snake_case_		)

    # matching characters
    __A       :		int							=	get_matched_characters(snake_case_							,snake_case_		)
    __A       :		Tuple							=	get_matched_characters(snake_case_							,snake_case_		)
    __A       :		str							=	len(snake_case_		)

    # transposition
    __A       :		Dict							=	(
        len([(ca, ca) for ca, ca in zip(snake_case_							,snake_case_		) if ca != ca]		) // 2
    )

    if not match_count:
        __A       :		List[str]							=	0.0
    else:
        __A       :		Tuple							=	(
            1
            / 3
            * (
                match_count / len(snake_case_		)
                + match_count / len(snake_case_		)
                + (match_count - transpositions) / match_count
            )
        )

    # common prefix up to 4 characters
    __A       :		Tuple							=	0
    for ca, ca in zip(stra[:4]							,stra[:4]		):
        if ca == ca:
            prefix_len += 1
        else:
            break

    return jaro + 0.1 * prefix_len * (1 - jaro)


if __name__ == "__main__":
       import doctest

       doctest.testmod()
       print(jaro_winkler("""hello""", """world"""))




