Ë
    çÍ:ji!  ã                   ó\   — d Z ddlmZmZmZ dZ G d„ d«      Z G d„ d«      Z G d„ d	«      Zy
)zÛ
Unit tests for nltk.tokenize.texttiling.

Marti A. Hearst (1997) "TextTiling: Segmenting Text into Multi-Paragraph
Subtopic Passages", Computational Linguistics, 23(1), pp. 33-64.
https://aclanthology.org/J97-1003.pdf
é    )ÚBLOCK_COMPARISONÚVOCABULARY_INTRODUCTIONÚTextTilingTokenizeraÕ  
The quick brown fox jumped over the lazy dog. The dog was sleeping
in the sun. It was a beautiful day outside in the forest. The fox
continued on its way through the dense woodland. Birds were singing
in the trees and rabbits scurried through the underbrush. The animals
were enjoying the warm afternoon sunshine.

Meanwhile, in the city, the stock market was experiencing significant
changes. Traders were anxious about the new economic policies. The
financial sector was particularly affected by the recent changes in
interest rates. Banks reported lower quarterly earnings. Investors
were pulling their money out of risky assets. The central bank was
considering raising rates again.

In other news, scientists discovered a new species of deep-sea fish.
The fish was found at a depth of three thousand meters below the
surface. Marine biologists were excited about the discovery. The
specimen was brought to the laboratory for further study. Researchers
believe the species has been living in the deep ocean for millions
of years.

The weather forecast predicted rain for the weekend across the region.
Farmers were hoping for the precipitation to help their growing crops.
The drought had lasted several months with no relief in sight. Water
reservoirs were at critically low levels. Irrigation systems were
being strained beyond their capacity.

The quick brown fox jumped over the lazy dog. The dog was sleeping
in the sun. It was a beautiful day outside in the forest. The fox
continued on its way through the dense woodland. Birds were singing
in the trees and rabbits scurried through the underbrush. The animals
were enjoying the warm afternoon sunshine.

Meanwhile, in the city, the stock market was experiencing significant
changes. Traders were anxious about the new economic policies. The
financial sector was particularly affected by the recent changes in
interest rates. Banks reported lower quarterly earnings. Investors
were pulling their money out of risky assets. The central bank was
considering raising rates again.

In other news, scientists discovered a new species of deep-sea fish.
The fish was found at a depth of three thousand meters below the
surface. Marine biologists were excited about the discovery. The
specimen was brought to the laboratory for further study. Researchers
believe the species has been living in the deep ocean for millions
of years.

The weather forecast predicted rain for the weekend across the region.
Farmers were hoping for the precipitation to help their growing crops.
The drought had lasted several months with no relief in sight. Water
reservoirs were at critically low levels. Irrigation systems were
being strained beyond their capacity.

The quick brown fox jumped over the lazy dog. The dog was sleeping
in the sun. It was a beautiful day outside in the forest. The fox
continued on its way through the dense woodland. Birds were singing
in the trees and rabbits scurried through the underbrush. The animals
were enjoying the warm afternoon sunshine.

Meanwhile, in the city, the stock market was experiencing significant
changes. Traders were anxious about the new economic policies. The
financial sector was particularly affected by the recent changes in
interest rates. Banks reported lower quarterly earnings. Investors
were pulling their money out of risky assets. The central bank was
considering raising rates again.

In other news, scientists discovered a new species of deep-sea fish.
The fish was found at a depth of three thousand meters below the
surface. Marine biologists were excited about the discovery. The
specimen was brought to the laboratory for further study. Researchers
believe the species has been living in the deep ocean for millions
of years.

The weather forecast predicted rain for the weekend across the region.
Farmers were hoping for the precipitation to help their growing crops.
The drought had lasted several months with no relief in sight. Water
reservoirs were at critically low levels. Irrigation systems were
being strained beyond their capacity.
c                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚTestTextTilingBlockComparisonzATests for the block comparison method (Hearst 1997, Section 3.2).c                 ó–   — t        ddt        ¬«      }|j                  t        «      }t	        |t
        «      sJ ‚t        |«      dk\  sJ ‚y)z7Block comparison should return a list of text segments.é
   é   ©ÚwÚkÚsimilarity_methodé   N)r   r   ÚtokenizeÚMULTI_TOPIC_TEXTÚ
isinstanceÚlistÚlen©ÚselfÚttÚsegmentss      ús/home/mcse/projects/srt_converter/srt-converter-venv/lib/python3.12/site-packages/nltk/test/unit/test_texttiling.pyÚtest_returns_segmentsz3TestTextTilingBlockComparison.test_returns_segments7   sB   € ä  2¨Ô>NÔOˆØ—;‘;Ô/Ó0ˆÜ˜(¤DÔ)Ð)Ð)Ü�8‹} Ò!Ð!Ñ!ó    c                 ó†   — t        ddt        ¬«      }|j                  t        «      }dj	                  |«      t        k(  sJ ‚y©z;Concatenated segments should reconstruct the original text.r	   r
   r   Ú N)r   r   r   r   Újoinr   s      r   Útest_segments_cover_full_textz;TestTextTilingBlockComparison.test_segments_cover_full_text>   s8   € ä  2¨Ô>NÔOˆØ—;‘;Ô/Ó0ˆØ�w‰w�xÓ Ô$4Ò4Ð4Ñ4r   c                 ó  — t        ddt        d¬«      }|j                  t        «      }t	        |«      dk(  sJ ‚|\  }}}}t	        |«      dkD  sJ ‚t	        |«      dkD  sJ ‚t	        |«      dkD  sJ ‚t	        |«      dkD  sJ ‚y©zDIn demo mode, should return (gap_scores, smooth, depth, boundaries).r	   r
   T©r   r   r   Ú	demo_modeé   r   N)r   r   r   r   r   ©r   r   ÚresultÚ
gap_scoresÚsmooth_scoresÚdepth_scoresÚ
boundariess          r   Útest_demo_mode_returns_scoresz;TestTextTilingBlockComparison.test_demo_mode_returns_scoresD   s‘   € ä Ø�AÔ)9ÀTô
ˆð —‘Ô-Ó.ˆÜ�6‹{˜aÒÐÐØ>DÑ;ˆ
�M <°Ü�:‹ Ò"Ð"Ð"Ü�=Ó! AÒ%Ð%Ð%Ü�<Ó  1Ò$Ð$Ð$Ü�:‹ Ò"Ð"Ñ"r   c                 óœ   — t        ddt        d¬«      }|j                  t        «      \  }}}}|D ]  }d|cxk  rdk  rŒn J d|› d�«       ‚ y	)
zDBlock comparison gap scores should be in [0, 1] (cosine similarity).r	   r
   Tr#   ç        g      ð?úScore z out of [0, 1] rangeN)r   r   r   r   ©r   r   r(   Ú_Úscores        r   Ú$test_gap_scores_between_zero_and_onezBTestTextTilingBlockComparison.test_gap_scores_between_zero_and_oneQ   sc   € ä Ø�AÔ)9ÀTô
ˆð !Ÿk™kÔ*:Ó;Ñˆ
�A�q˜!Øò 	MˆEØ˜%Ô& 3Õ&ÐL¨&°°Ð7KÐ(LÓLÐ&ñ	Mr   c                 óž   — d}dj                  |gdz  «      dz   }t        ddt        ¬«      }|j                  |«      }t	        |«      dk  sJ ‚y)z;Repeating the same paragraph should produce few boundaries.ú1The cat sat on the mat. The dog chased the ball. ú

r	   r
   r   N)r   r   r   r   r   )r   Ú	paragraphÚrepeatedr   r   s        r   Ú$test_homogeneous_text_few_boundarieszBTestTextTilingBlockComparison.test_homogeneous_text_few_boundariesZ   sP   € àGˆ	à—K‘K  ¨bÑ 0Ó1°VÑ;ˆÜ  2¨Ô>NÔOˆØ—;‘;˜xÓ(ˆä�8‹} Ò!Ð!Ñ!r   N)	Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   r    r,   r3   r9   © r   r   r   r   4   s   „ ÙKò"ò5ò#òMó"r   r   c                   ó.   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zd„ Zy)ÚTestTextTilingVocabIntroductionzHTests for the vocabulary introduction method (Hearst 1997, Section 3.2).c                 ó–   — t        ddt        ¬«      }|j                  t        «      }t	        |t
        «      sJ ‚t        |«      dk\  sJ ‚y)z>Vocabulary introduction should return a list of text segments.r	   r
   r   r   N)r   r   r   r   r   r   r   r   s      r   r   z5TestTextTilingVocabIntroduction.test_returns_segmentsh   sB   € ä  2¨Ô>UÔVˆØ—;‘;Ô/Ó0ˆÜ˜(¤DÔ)Ð)Ð)Ü�8‹} Ò!Ð!Ñ!r   c                 ó†   — t        ddt        ¬«      }|j                  t        «      }dj	                  |«      t        k(  sJ ‚yr   )r   r   r   r   r   r   s      r   r    z=TestTextTilingVocabIntroduction.test_segments_cover_full_texto   s8   € ä  2¨Ô>UÔVˆØ—;‘;Ô/Ó0ˆØ�w‰w�xÓ Ô$4Ò4Ð4Ñ4r   c                 ó  — t        ddt        d¬«      }|j                  t        «      }t	        |«      dk(  sJ ‚|\  }}}}t	        |«      dkD  sJ ‚t	        |«      dkD  sJ ‚t	        |«      dkD  sJ ‚t	        |«      dkD  sJ ‚yr"   )r   r   r   r   r   r&   s          r   r,   z=TestTextTilingVocabIntroduction.test_demo_mode_returns_scoresu   s‘   € ä Ø�AÔ)@ÈDô
ˆð —‘Ô-Ó.ˆÜ�6‹{˜aÒÐÐØ>DÑ;ˆ
�M <°Ü�:‹ Ò"Ð"Ð"Ü�=Ó! AÒ%Ð%Ð%Ü�<Ó  1Ò$Ð$Ð$Ü�:‹ Ò"Ð"Ñ"r   c                 óŒ   — t        ddt        d¬«      }|j                  t        «      \  }}}}|D ]  }|dk\  rŒ	J d|› d�«       ‚ y)	z6Vocabulary introduction scores should be non-negative.r	   r
   Tr#   r.   r/   z is negativeN)r   r   r   r   r0   s        r   Útest_gap_scores_non_negativez<TestTextTilingVocabIntroduction.test_gap_scores_non_negative‚   sY   € ä Ø�AÔ)@ÈDô
ˆð !Ÿk™kÔ*:Ó;Ñˆ
�A�q˜!Øò 	>ˆEØ˜C“<Ð= 6¨%¨°Ð!=Ó=�<ñ	>r   c                 ó  — d}dj                  |gdz  «      dz   }t        ddt        d¬«      }|j                  |«      \  }}}}|t	        |«      dz  d }|rt        |«      t	        |«      z  nd	}|d
k  sJ d|› d�«       ‚y)zCRepeating the same paragraph should produce low vocab intro scores.r5   r6   r	   r
   Tr#   é   Nr   g333333Ã?zAverage later score z too high for repeated text)r   r   r   r   r   Úsum)r   r7   r8   r   r(   r1   Úlater_scoresÚ	avg_laters           r   Ú test_homogeneous_text_low_scoresz@TestTextTilingVocabIntroduction.test_homogeneous_text_low_scores‹   s¢   € àGˆ	Ø—K‘K  ¨bÑ 0Ó1°VÑ;ˆÜ Ø�AÔ)@ÈDô
ˆð !Ÿk™k¨(Ó3Ñˆ
�A�q˜!ð "¤# j£/°QÑ"6Ð"8Ð9ˆÙ=I”C˜Ó%¬¨LÓ(9Ò9Èqˆ	à˜Òð	Ià! ) Ð,GÐHó	IÙr   N)	r:   r;   r<   r=   r   r    r,   rE   rK   r>   r   r   r@   r@   e   s   „ ÙRò"ò5ò#ò>óIr   r@   c                   ó(   — e Zd ZdZd„ Zd„ Zd„ Zd„ Zy)ÚTestTextTilingCommonzTests common to both methods.c                 óž   — t         t        fD ]>  }t        dd|¬«      }|j                  t        «      }t        |«      dkD  rŒ5J d|› d�«       ‚ y)zCBoth methods should find at least one boundary in multi-topic text.r	   r
   r   r   zMethod z( found no boundaries in multi-topic textN)r   r   r   r   r   r   )r   Úmethodr   r   s       r   Ú!test_both_methods_find_boundariesz6TestTextTilingCommon.test_both_methods_find_boundariesŸ   s^   € ä'Ô)@ÐAò 	JˆFÜ$ r¨QÀ&ÔIˆBØ—{‘{Ô#3Ó4ˆHä�H“ Ó!ðJà˜˜Ð HÐIóJØ!ñ		Jr   c                 ór   — t        d¬«      }	 |j                  t        «       J d«       ‚# t        $ r Y yw xY w)z2Invalid similarity method should raise ValueError.Úinvalid)r   úExpected ValueErrorN©r   r   r   Ú
ValueError©r   r   s     r   Útest_invalid_similarity_methodz3TestTextTilingCommon.test_invalid_similarity_method¨   s;   € ä °9Ô=ˆð	Ø�K‰KÔ(Ô)Ø/Ð/Ó/�5øÜò 	Ùð	úó   Ž* ª	6µ6c                 ór   — t        d¬«      }	 |j                  t        «       J d«       ‚# t        $ r Y yw xY w)z1Invalid smoothing method should raise ValueError.rR   )Úsmoothing_methodrS   NrT   rV   s     r   Útest_invalid_smoothing_methodz2TestTextTilingCommon.test_invalid_smoothing_method±   s;   € ä °)Ô<ˆð	Ø�K‰KÔ(Ô)Ø/Ð/Ó/�5øÜò 	Ùð	úrX   c                 óú   — t         t        fD ]l  }t        dd|¬«      }|j                  t        «      }t        dd|d¬«      }|j                  t        «      \  }}}}t        |«      }|t        |«      dz
  k\  rŒlJ ‚ y)z:Number of boundaries should be number of segments minus 1.r	   r
   r   Tr#   rG   N)r   r   r   r   r   rH   r   )r   rO   r   r   Útt_demor1   r+   Únum_boundariess           r   Ú$test_boundary_count_matches_segmentsz9TestTextTilingCommon.test_boundary_count_matches_segmentsº   sƒ   € ä'Ô)@ÐAò 		7ˆFÜ$ r¨QÀ&ÔIˆBØ—{‘{Ô#3Ó4ˆHÜ)Ø˜¨V¸tôˆGð #*×"2Ñ"2Ô3CÓ"DÑˆAˆq�!�ZÜ  ›_ˆNà!¤S¨£]°QÑ%6Ó6Ð6Ð6ñ		7r   N)r:   r;   r<   r=   rP   rW   r[   r_   r>   r   r   rM   rM   œ   s   „ Ù'òJòòó7r   rM   N)	r=   Únltk.tokenize.texttilingr   r   r   r   r   r@   rM   r>   r   r   ú<module>ra      sA   ðñ÷ñ ðð ÷@."ñ ."÷b4Iñ 4I÷n)7ò )7r   