§
    'ê[ff  ã                   ó   — d dl mZ d„ ZdS )é    )Údefaultdictc                 ór  ‡ ‡‡‡	‡
‡— d„ |                      ¦   «         D ¦   «         }d„ |                      ¦   «         D ¦   «         }g d¢Š
t          |¦  «                             t          |¦  «        ¦  «        Š	t          |¦  «                             t          |¦  «        ¦  «        Št	          t          ¦  «        Š‰	D ];\  }}‰d                              |¦  «         ‰d                              |¦  «         Œ<ˆˆ	ˆ
ˆ ˆˆfd„}ˆˆ	ˆ ˆˆfd„} |¦   «           ||¦  «          ||¦  «         t          ‰	¦  «        S )u"  
    This module symmetrisatizes the source-to-target and target-to-source
    word alignment output and produces, aka. GDFA algorithm (Koehn, 2005).

    Step 1: Find the intersection of the bidirectional alignment.

    Step 2: Search for additional neighbor alignment points to be added, given
            these criteria: (i) neighbor alignments points are not in the
            intersection and (ii) neighbor alignments are in the union.

    Step 3: Add all other alignment points that are not in the intersection, not in
            the neighboring alignments that met the criteria but in the original
            forward/backward alignment outputs.

        >>> forw = ('0-0 2-1 9-2 21-3 10-4 7-5 11-6 9-7 12-8 1-9 3-10 '
        ...         '4-11 17-12 17-13 25-14 13-15 24-16 11-17 28-18')
        >>> back = ('0-0 1-9 2-9 3-10 4-11 5-12 6-6 7-5 8-6 9-7 10-4 '
        ...         '11-6 12-8 13-12 15-12 17-13 18-13 19-12 20-13 '
        ...         '21-3 22-12 23-14 24-17 25-15 26-17 27-18 28-18')
        >>> srctext = ("ã�“ã�® ã‚ˆã�† ã�ª ãƒ�ãƒ­ãƒ¼ ç™½è‰² ã‚�ã�„ æ˜Ÿ ã�® ï¼¬ é–¢æ•° "
        ...            "ã�¯ ï¼¬ ã�¨ å…± ã�« ä¸�é€£ç¶š ã�« å¢—åŠ  ã�™ã‚‹ ã�“ã�¨ ã�Œ "
        ...            "æœŸå¾… ã�• ã‚Œã‚‹ ã�“ã�¨ ã‚’ ç¤ºã�— ã�Ÿ ã€‚")
        >>> trgtext = ("Therefore , we expect that the luminosity function "
        ...            "of such halo white dwarfs increases discontinuously "
        ...            "with the luminosity .")
        >>> srclen = len(srctext.split())
        >>> trglen = len(trgtext.split())
        >>>
        >>> gdfa = grow_diag_final_and(srclen, trglen, forw, back)
        >>> gdfa == sorted(set([(28, 18), (6, 6), (24, 17), (2, 1), (15, 12), (13, 12),
        ...         (2, 9), (3, 10), (26, 17), (25, 15), (8, 6), (9, 7), (20,
        ...         13), (18, 13), (0, 0), (10, 4), (13, 15), (23, 14), (7, 5),
        ...         (25, 14), (1, 9), (17, 13), (4, 11), (11, 17), (9, 2), (22,
        ...         12), (27, 18), (24, 16), (21, 3), (19, 12), (17, 12), (5,
        ...         12), (11, 6), (12, 8)]))
        True

    References:
    Koehn, P., A. Axelrod, A. Birch, C. Callison, M. Osborne, and D. Talbot.
    2005. Edinburgh System Description for the 2005 IWSLT Speech
    Translation Evaluation. In MT Eval Workshop.

    :type srclen: int
    :param srclen: the number of tokens in the source language
    :type trglen: int
    :param trglen: the number of tokens in the target language
    :type e2f: str
    :param e2f: the forward word alignment outputs from source-to-target
                language (in pharaoh output format)
    :type f2e: str
    :param f2e: the backward word alignment outputs from target-to-source
                language (in pharaoh output format)
    :rtype: set(tuple(int))
    :return: the symmetrized alignment points from the GDFA algorithm
    c           
      óx   — g | ]7}t          t          t          |                     d ¦  «        ¦  «        ¦  «        ‘Œ8S ©Ú-©ÚtupleÚmapÚintÚsplit©Ú.0Úas     úG/var/www/piapp/venv/lib/python3.11/site-packages/nltk/translate/gdfa.pyú
<listcomp>z'grow_diag_final_and.<locals>.<listcomp>E   ó4   € Ð
>Ð
>Ð
>¨Q�5••S˜!Ÿ'š' #™,œ,Ñ'Ô'Ñ(Ô(Ð
>Ð
>Ð
>ó    c           
      óx   — g | ]7}t          t          t          |                     d ¦  «        ¦  «        ¦  «        ‘Œ8S r   r   r   s     r   r   z'grow_diag_final_and.<locals>.<listcomp>F   r   r   ))éÿÿÿÿr   )r   r   )é   r   )r   r   )r   r   )r   r   )r   r   )r   r   ÚeÚfc            
      óþ  •— t          ‰¦  «        dz
  } | t          ‰¦  «        k     rÖd}t          ‰
¦  «        D ]«}t          ‰¦  «        D ]™}||f‰v r‘‰	D ]Ž}t          d„ t          ||f|¦  «        D ¦   «         ¦  «        }|\  }}|‰vrZ|‰vrV|‰v rR‰                     |¦  «         ‰d                              |¦  «         ‰d                              |¦  «         | dz  } d}Œ�ŒšŒ¬|rdS | t          ‰¦  «        k     °ÔdS dS )zz
        Search for the neighbor points and them to the intersected alignment
        points if criteria are met.
        r   Tc              3   ó&   K  — | ]\  }}||z   V — Œd S )N© )r   ÚiÚjs      r   ú	<genexpr>z9grow_diag_final_and.<locals>.grow_diag.<locals>.<genexpr>c   s*   è è € Ð,UÐ,U±t°q¸!¨Q°©UÐ,UÐ,UÐ,UÐ,UÐ,UÐ,Ur   r   r   FN)ÚlenÚranger	   ÚzipÚadd)Úprev_lenÚno_new_pointsr   r   ÚneighborÚe_newÚf_newÚalignedÚ	alignmentÚ	neighborsÚsrclenÚtrglenÚunions          €€€€€€r   Ú	grow_diagz&grow_diag_final_and.<locals>.grow_diagR   sM  ø€ õ
 �y‘>”> AÑ%ˆà�˜Y™œÒ'Ð'Ø ˆMå˜6‘]”]ð 6ð 6�å˜v™œð 6ð 6�Aà˜1�v Ð*Ð*à(1ð 6ð 6˜HÝ',Ð,UÐ,U½sÀAÀqÀ6È8Ñ?TÔ?TÐ,UÑ,UÔ,UÑ'UÔ'U˜HØ+3™L˜E 5ð !&¨WÐ 4Ð 4¸ÀgÐ9MÐ9MØ"*¨eÐ"3Ð"3Ø )§¢¨hÑ 7Ô 7Ð 7Ø '¨¤× 0Ò 0°Ñ 7Ô 7Ð 7Ø '¨¤× 0Ò 0°Ñ 7Ô 7Ð 7Ø (¨A¡ Ø05 øøð!6ð$ ð Ø�ð1 �˜Y™œÒ'Ð'Ð'Ð'Ð'Ð'r   c                 ó  •— t          ‰¦  «        D ]o}t          ‰¦  «        D ]]}|‰vrW|‰vrS||f‰v rM‰                     ||f¦  «         ‰d                              |¦  «         ‰d                              |¦  «         Œ^ŒpdS )z¢
        Adds remaining points that are not in the intersection, not in the
        neighboring alignments but in the original *e2f* and *f2e* alignments
        r   r   N)r    r"   )r   r&   r'   r(   r)   r+   r,   r-   s      €€€€€r   Ú	final_andz&grow_diag_final_and.<locals>.final_ands   s¬   ø€ õ ˜6‘]”]ð 	,ð 	,ˆEå˜v™œð 
,ð 
,�ð  Ð(Ð(Ø WÐ,Ð,Ø ˜¨%Ð/Ð/à—M’M 5¨% .Ñ1Ô1Ð1Ø˜C”L×$Ò$ UÑ+Ô+Ð+Ø˜C”L×$Ò$ UÑ+Ô+Ð+øð
,ð	,ð 	,r   )r   ÚsetÚintersectionr-   r   r"   Úsorted)r+   r,   Úe2fÚf2er   r   r.   r0   r(   r)   r*   r-   s   ``      @@@@r   Úgrow_diag_final_andr6      sr  øøøøøø€ ðt ?Ð
>°#·)²)±+´+Ð
>Ñ
>Ô
>€CØ
>Ð
>°#·)²)±+´+Ð
>Ñ
>Ô
>€CàVÐVÐV€IÝ�C‘”×%Ò%¥c¨#¡h¤hÑ/Ô/€IÝ�‰HŒH�NŠN�3˜s™8œ8Ñ$Ô$€Eõ �#ÑÔ€GØð ð ‰ˆˆ1Ø�Œ×Ò˜ÑÔÐØ�Œ×Ò˜ÑÔÐÐðð ð ð ð ð ð ð ð ð ðB,ð ,ð ,ð ,ð ,ð ,ð ,ð ,ð ,ð( €I�K„K€KØ€Iˆc�N„N€NØ€Iˆc�N„N€NÝ�)ÑÔÐr   N)Úcollectionsr   r6   r   r   r   ú<module>r8      s7   ðð $Ð #Ð #Ð #Ð #Ð #ðð ð ð ð r   