






'''simple docstring'''



from typing import Any
class 				__SCREAMING_SNAKE_CASE							:




      def __init__(	self			, lowerCamelCase   )				->List[Any]:



         '''simple docstring'''
         __a					  =     data
         __a					  =     None






      def __repr__(	self   )				->str:



         '''simple docstring'''
         return F"""Node({self.data})"""







class 				__SCREAMING_SNAKE_CASE							:




      def __init__(	self   )				->Optional[Any]:



         '''simple docstring'''
         __a					  =     None




      def __iter__(	self   )				->Any:



         '''simple docstring'''
         __a					  =     self.head
         while node:
            yield node.data
            __a					  =     node.next




      def __len__(	self   )				->int:



         '''simple docstring'''
         return sum(1 for _ in self   )




      def __repr__(	self   )				->str:



         '''simple docstring'''
         return "->".join([str(lowerCamelCase   ) for item in self]   )




      def __getitem__(	self			, lowerCamelCase   )				->Any:



         '''simple docstring'''
         if not 0 <= index < len(self   ):
            raise ValueError('list index out of range.'   )
         for i, node in enumerate(self   ):
            if i == index:
               return node
         return None




      def __setitem__(	self			, lowerCamelCase			, lowerCamelCase   )				->None:



         '''simple docstring'''
         if not 0 <= index < len(self   ):
            raise ValueError('list index out of range.'   )
         __a					  =     self.head
         for _ in range(lowerCamelCase   ):
            __a					  =     current.next
         __a					  =     data




      def 			__UpperCamelCase				(	self			, lowerCamelCase   )				->None:



         '''simple docstring'''
         self.insert_nth(len(self   )			, lowerCamelCase   )




      def 			__UpperCamelCase				(	self			, lowerCamelCase   )				->None:



         '''simple docstring'''
         self.insert_nth(0			, lowerCamelCase   )




      def 			__UpperCamelCase				(	self			, lowerCamelCase			, lowerCamelCase   )				->None:



         '''simple docstring'''
         if not 0 <= index <= len(self   ):
            raise IndexError('list index out of range'   )
         __a					  =     Node(lowerCamelCase   )
         if self.head is None:
            __a					  =     new_node
         elif index == 0:
            __a					  =     self.head  # link new_node to head
            __a					  =     new_node
         else:
            __a					  =     self.head
            for _ in range(index - 1   ):
               __a					  =     temp.next
            __a					  =     temp.next
            __a					  =     new_node




      def 			__UpperCamelCase				(	self   )				->None:  # print every node data



         '''simple docstring'''
         print(self   )




      def 			__UpperCamelCase				(	self   )				->Any:



         '''simple docstring'''
         return self.delete_nth(0   )




      def 			__UpperCamelCase				(	self   )				->Any:  # delete from tail



         '''simple docstring'''
         return self.delete_nth(len(self   ) - 1   )




      def 			__UpperCamelCase				(	self			, lowerCamelCase = 0   )				->Any:



         '''simple docstring'''
         if not 0 <= index <= len(self   ) - 1:  # test if index is valid
            raise IndexError('List index out of range.'   )
         __a					  =     self.head  # default first node
         if index == 0:
            __a					  =     self.head.next
         else:
            __a					  =     self.head
            for _ in range(index - 1   ):
               __a					  =     temp.next
            __a					  =     temp.next
            __a					  =     temp.next.next
         return delete_node.data




      def 			__UpperCamelCase				(	self   )				->bool:



         '''simple docstring'''
         return self.head is None






      def 			__UpperCamelCase				(	self   )				->None:



         '''simple docstring'''
         __a					  =     None
         __a					  =     self.head

         while current:
            # Store the current node's next node.
            __a					  =     current.next
            # Make the current node's next point backwards
            __a					  =     prev
            # Make the previous node be the current node
            __a					  =     current
            # Make the current node the next node (to progress iteration)
            __a					  =     next_node
         # Return prev in order to put the head at the end
         __a					  =     prev







def  __UpperCAmelCase						(					)	->      None:

   """simple docstring"""
   __a					  =     LinkedList()
   assert linked_list.is_empty() is True
   assert str(SCREAMING_SNAKE_CASE__     ) == ""

   try:
      linked_list.delete_head()
      raise AssertionError  # This should not happen.
   except IndexError:
      assert True  # This should happen.

   try:
      linked_list.delete_tail()
      raise AssertionError  # This should not happen.
   except IndexError:
      assert True  # This should happen.

   for i in range(10     ):
      assert len(SCREAMING_SNAKE_CASE__     ) == i
      linked_list.insert_nth(SCREAMING_SNAKE_CASE__,       i + 1     )
   assert str(SCREAMING_SNAKE_CASE__     ) == "->".join(str(SCREAMING_SNAKE_CASE__     ) for i in range(1,       11     )     )

   linked_list.insert_head(0     )
   linked_list.insert_tail(11     )
   assert str(SCREAMING_SNAKE_CASE__     ) == "->".join(str(SCREAMING_SNAKE_CASE__     ) for i in range(0,       12     )     )

   assert linked_list.delete_head() == 0
   assert linked_list.delete_nth(9     ) == 10
   assert linked_list.delete_tail() == 11
   assert len(SCREAMING_SNAKE_CASE__     ) == 9
   assert str(SCREAMING_SNAKE_CASE__     ) == "->".join(str(SCREAMING_SNAKE_CASE__     ) for i in range(1,       10     )     )

   assert all(linked_list[i] == i + 1 for i in range(0,       9     )     ) is True

   for i in range(0,       9     ):
      __a					  =     -i
   assert all(linked_list[i] == -i for i in range(0,       9     )     ) is True

   linked_list.reverse()
   assert str(SCREAMING_SNAKE_CASE__     ) == "->".join(str(SCREAMING_SNAKE_CASE__     ) for i in range(-8,       1     )     )



def  __UpperCAmelCase						(					)	->      None:

   """simple docstring"""
   __a					  =     [
       -9,
       100,
       Node(77345112     ),
       'dlrow olleH',
       7,
       5555,
       0,
       -1_9_2.5_5_5_5_5,
       'Hello, world!',
       7_7.9,
       Node(10     ),
       None,
       None,
       1_2.2_0,
   ]
   __a					  =     LinkedList()

   for i in test_input:
      linked_list.insert_tail(SCREAMING_SNAKE_CASE__     )

   # Check if it's empty or not
   assert linked_list.is_empty() is False
   assert (
       str(SCREAMING_SNAKE_CASE__     ) == "-9->100->Node(77345112)->dlrow olleH->7->5555->0->"
       "-192.55555->Hello, world!->77.9->Node(10)->None->None->12.2"
   )

   # Delete the head
   __a					  =     linked_list.delete_head()
   assert result == -9
   assert (
       str(SCREAMING_SNAKE_CASE__     ) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
       "Hello, world!->77.9->Node(10)->None->None->12.2"
   )

   # Delete the tail
   __a					  =     linked_list.delete_tail()
   assert result == 1_2.2
   assert (
       str(SCREAMING_SNAKE_CASE__     ) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
       "Hello, world!->77.9->Node(10)->None->None"
   )

   # Delete a node in specific location in linked list
   __a					  =     linked_list.delete_nth(10     )
   assert result is None
   assert (
       str(SCREAMING_SNAKE_CASE__     ) == "100->Node(77345112)->dlrow olleH->7->5555->0->-192.55555->"
       "Hello, world!->77.9->Node(10)->None"
   )

   # Add a Node instance to its head
   linked_list.insert_head(Node('Hello again, world!'     )     )
   assert (
       str(SCREAMING_SNAKE_CASE__     )
       == "Node(Hello again, world!)->100->Node(77345112)->dlrow olleH->"
       "7->5555->0->-192.55555->Hello, world!->77.9->Node(10)->None"
   )

   # Add None to its tail
   linked_list.insert_tail(SCREAMING_SNAKE_CASE__     )
   assert (
       str(SCREAMING_SNAKE_CASE__     )
       == "Node(Hello again, world!)->100->Node(77345112)->dlrow olleH->"
       "7->5555->0->-192.55555->Hello, world!->77.9->Node(10)->None->None"
   )

   # Reverse the linked list
   linked_list.reverse()
   assert (
       str(SCREAMING_SNAKE_CASE__     )
       == "None->None->Node(10)->77.9->Hello, world!->-192.55555->0->5555->"
       "7->dlrow olleH->Node(77345112)->100->Node(Hello again, world!)"
   )



def  __UpperCAmelCase						(					)	->      Union[str, Any]:

   """simple docstring"""
   from doctest import testmod

   testmod()

   __a					  =     LinkedList()
   linked_list.insert_head(input('Inserting 1st at head '     ).strip()     )
   linked_list.insert_head(input('Inserting 2nd at head '     ).strip()     )
   print('\nPrint list:'     )
   linked_list.print_list()
   linked_list.insert_tail(input('\nInserting 1st at tail '     ).strip()     )
   linked_list.insert_tail(input('Inserting 2nd at tail '     ).strip()     )
   print('\nPrint list:'     )
   linked_list.print_list()
   print('\nDelete head'     )
   linked_list.delete_head()
   print('Delete tail'     )
   linked_list.delete_tail()
   print('\nPrint list:'     )
   linked_list.print_list()
   print('\nReverse linked list'     )
   linked_list.reverse()
   print('\nPrint list:'     )
   linked_list.print_list()
   print('\nString representation of linked list:'     )
   print(SCREAMING_SNAKE_CASE__     )
   print('\nReading/changing Node data using indexing:'     )
   print(f"""Element at Position 1: {linked_list[1]}"""     )
   __a					  =     input('Enter New Value: '     ).strip()
   print('New list:'     )
   print(SCREAMING_SNAKE_CASE__     )
   print(f"""length of linked_list is : {len(SCREAMING_SNAKE_CASE__     )}"""     )


if __name__ == "__main__":
 main()







'''simple docstring'''



import sacrebleu as scb
from packaging import version
from sacrebleu import CHRF

import datasets


__UpperCamelCase   :							List[str]         =   """\
@inproceedings{popovic-2015-chrf,
    title = \"chr{F}: character n-gram {F}-score for automatic {MT} evaluation\",
    author = \"Popovi{\'c}, Maja\",
    booktitle = \"Proceedings of the Tenth Workshop on Statistical Machine Translation\",
    month = sep,
    year = \"2015\",
    address = \"Lisbon, Portugal\",
    publisher = \"Association for Computational Linguistics\",
    url = \"https://aclanthology.org/W15-3049\",
    doi = \"10.18653/v1/W15-3049\",
    pages = \"392--395\",
}
@inproceedings{popovic-2017-chrf,
    title = \"chr{F}++: words helping character n-grams\",
    author = \"Popovi{\'c}, Maja\",
    booktitle = \"Proceedings of the Second Conference on Machine Translation\",
    month = sep,
    year = \"2017\",
    address = \"Copenhagen, Denmark\",
    publisher = \"Association for Computational Linguistics\",
    url = \"https://aclanthology.org/W17-4770\",
    doi = \"10.18653/v1/W17-4770\",
    pages = \"612--618\",
}
@inproceedings{post-2018-call,
    title = \"A Call for Clarity in Reporting {BLEU} Scores\",
    author = \"Post, Matt\",
    booktitle = \"Proceedings of the Third Conference on Machine Translation: Research Papers\",
    month = oct,
    year = \"2018\",
    address = \"Belgium, Brussels\",
    publisher = \"Association for Computational Linguistics\",
    url = \"https://www.aclweb.org/anthology/W18-6319\",
    pages = \"186--191\",
}
"""

__UpperCamelCase   :							Union[str, Any]         =   """\
ChrF and ChrF++ are two MT evaluation metrics. They both use the F-score statistic for character n-gram matches,
and ChrF++ adds word n-grams as well which correlates more strongly with direct assessment. We use the implementation
that is already present in sacrebleu.

The implementation here is slightly different from sacrebleu in terms of the required input format. The length of
the references and hypotheses lists need to be the same, so you may need to transpose your references compared to
sacrebleu's required input format. See https://github.com/huggingface/datasets/issues/3154#issuecomment-950746534

See the README.md file at https://github.com/mjpost/sacreBLEU#chrf--chrf for more information.
"""

__UpperCamelCase   :							str         =   """
Produces ChrF(++) scores for hypotheses given reference translations.

Args:
    predictions (list of str): The predicted sentences.
    references (list of list of str): The references. There should be one reference sub-list for each prediction sentence.
    char_order (int): Character n-gram order. Defaults to `6`.
    word_order (int): Word n-gram order. If equals to `2`, the metric is referred to as chrF++. Defaults to `0`.
    beta (int): Determine the importance of recall w.r.t precision. Defaults to `2`.
    lowercase (bool): if `True`, enables case-insensitivity. Defaults to `False`.
    whitespace (bool): If `True`, include whitespaces when extracting character n-grams.
    eps_smoothing (bool): If `True`, applies epsilon smoothing similar
    to reference chrF++.py, NLTK and Moses implementations. If `False`,
    it takes into account effective match order similar to sacreBLEU < 2.0.0. Defaults to `False`.

Returns:
    'score' (float): The chrF (chrF++) score,
    'char_order' (int): The character n-gram order,
    'word_order' (int): The word n-gram order. If equals to 2, the metric is referred to as chrF++,
    'beta' (int): Determine the importance of recall w.r.t precision

Examples:
    Example 1--a simple example of calculating chrF:
        >>> prediction = [\"The relationship between cats and dogs is not exactly friendly.\", \"a good bookshop is just a genteel black hole that knows how to read.\"]
        >>> reference = [[\"The relationship between dogs and cats is not exactly friendly.\"], [\"A good bookshop is just a genteel Black Hole that knows how to read.\"]]
        >>> chrf = datasets.load_metric(\"chrf\")
        >>> results = chrf.compute(predictions=prediction, references=reference)
        >>> print(results)
        {'score': 84.64214891738334, 'char_order': 6, 'word_order': 0, 'beta': 2}

    Example 2--the same example, but with the argument word_order=2, to calculate chrF++ instead of chrF:
        >>> prediction = [\"The relationship between cats and dogs is not exactly friendly.\", \"a good bookshop is just a genteel black hole that knows how to read.\"]
        >>> reference = [[\"The relationship between dogs and cats is not exactly friendly.\"], [\"A good bookshop is just a genteel Black Hole that knows how to read.\"]]
        >>> chrf = datasets.load_metric(\"chrf\")
        >>> results = chrf.compute(predictions=prediction,
        ...                         references=reference,
        ...                         word_order=2)
        >>> print(results)
        {'score': 82.87263732906315, 'char_order': 6, 'word_order': 2, 'beta': 2}

    Example 3--the same chrF++ example as above, but with `lowercase=True` to normalize all case:
        >>> prediction = [\"The relationship between cats and dogs is not exactly friendly.\", \"a good bookshop is just a genteel black hole that knows how to read.\"]
        >>> reference = [[\"The relationship between dogs and cats is not exactly friendly.\"], [\"A good bookshop is just a genteel Black Hole that knows how to read.\"]]
        >>> chrf = datasets.load_metric(\"chrf\")
        >>> results = chrf.compute(predictions=prediction,
        ...                         references=reference,
        ...                         word_order=2,
        ...                         lowercase=True)
        >>> print(results)
        {'score': 92.12853119829202, 'char_order': 6, 'word_order': 2, 'beta': 2}
"""
@datasets.utils.file_utils.add_start_docstrings(_DESCRIPTION   ,   _KWARGS_DESCRIPTION  )
class 				__SCREAMING_SNAKE_CASE							(				datasets.Metric  ):




      def 			__UpperCamelCase				(	self   )				->Union[str, Any]:



         '''simple docstring'''
         if version.parse(scb.__version__   ) < version.parse('1.4.12'   ):
            raise ImportWarning(
                'To use `sacrebleu`, the module `sacrebleu>=1.4.12` is required, and the current version of `sacrebleu` doesn\'t match this condition.\n'
                'You can install it with `pip install "sacrebleu>=1.4.12"`.'   )
         return datasets.MetricInfo(
             description=_DESCRIPTION			, citation=_CITATION			, homepage='https://github.com/mjpost/sacreBLEU#chrf--chrf'			, inputs_description=_KWARGS_DESCRIPTION			, features=datasets.Features(
                 {
                     'predictions': datasets.Value('string'			, id='sequence'   ),
                     'references': datasets.Sequence(datasets.Value('string'			, id='sequence'   )			, id='references'   ),
                 }   )			, codebase_urls=['https://github.com/mjpost/sacreBLEU#chrf--chrf']			, reference_urls=[
                 'https://github.com/m-popovic/chrF',
             ]			, )






      def 			__UpperCamelCase				(	self			, lowerCamelCase			, lowerCamelCase			, lowerCamelCase = CHRF.CHAR_ORDER			, lowerCamelCase = CHRF.WORD_ORDER			, lowerCamelCase = CHRF.BETA			, lowerCamelCase = False			, lowerCamelCase = False			, lowerCamelCase = False			, )				->Union[str, Any]:



         '''simple docstring'''
         __a					  =     len(references[0]   )
         if any(len(lowerCamelCase   ) != references_per_prediction for refs in references   ):
            raise ValueError('Sacrebleu requires the same number of references for each prediction'   )
         __a					  =     [[refs[i] for refs in references] for i in range(lowerCamelCase   )]

         __a					  =     CHRF(lowerCamelCase			, lowerCamelCase			, lowerCamelCase			, lowerCamelCase			, lowerCamelCase			, lowerCamelCase   )
         __a					  =     sb_chrf.corpus_score(lowerCamelCase			, lowerCamelCase   )

         return {
             "score": output.score,
             "char_order": output.char_order,
             "word_order": output.word_order,
             "beta": output.beta,
         }