+
    ÖÇÜhT*  ã                   ó€   € ^ RI t ^ RIHt  ! R R4      t ! R R]4      tR tR tR	 t]! R
RR.4      t	 ! R R4      t
R# )é    N)Ú
namedtuplec                   óŠ   a € ] tR t^t o RtRR lt]R 4       t]R 4       tR t	R t
]! ]	]
4      tR tR	 tR
 tR tR tRtV tR# )ÚAlignedSenta»  
Return an aligned sentence object, which encapsulates two sentences
along with an ``Alignment`` between them.

Typically used in machine translation to represent a sentence and
its translation.

    >>> from nltk.translate import AlignedSent, Alignment
    >>> algnsent = AlignedSent(['klein', 'ist', 'das', 'Haus'],
    ...     ['the', 'house', 'is', 'small'], Alignment.fromstring('0-3 1-2 2-0 3-1'))
    >>> algnsent.words
    ['klein', 'ist', 'das', 'Haus']
    >>> algnsent.mots
    ['the', 'house', 'is', 'small']
    >>> algnsent.alignment
    Alignment([(0, 3), (1, 2), (2, 0), (3, 1)])
    >>> from nltk.corpus import comtrans
    >>> print(comtrans.aligned_sents()[54])
    <AlignedSent: 'Weshalb also sollten...' -> 'So why should EU arm...'>
    >>> print(comtrans.aligned_sents()[54].alignment)
    0-0 0-1 1-0 2-2 3-4 3-5 4-7 5-8 6-3 7-9 8-9 9-10 9-11 10-12 11-6 12-6 13-13

:param words: Words in the target language sentence
:type words: list(str)
:param mots: Words in the source language sentence
:type mots: list(str)
:param alignment: Word-level alignments between ``words`` and ``mots``.
    Each alignment is represented as a 2-tuple (words_index, mots_index).
:type alignment: Alignment
Nc                ó€   € Wn         W n        Vf   \        . 4      V n        R # \	        V4      \        J g   Q hW0n        R # ©N)Ú_wordsÚ_motsÚ	AlignmentÚ	alignmentÚtype)ÚselfÚwordsÚmotsr   s   &&&&Ú4/usr/lib/python3/dist-packages/nltk/translate/api.pyÚ__init__ÚAlignedSent.__init__/   s4   € ØŒØŒ
ØÒÜ& r›]ˆDŽNä˜	“?¤iÓ/Ð/Ð/Ø&ŽNó    c                ó   € V P                   # r   )r   ©r   s   &r   r   ÚAlignedSent.words8   s   € à�{‰{Ðr   c                ó   € V P                   # r   )r	   r   s   &r   r   ÚAlignedSent.mots<   s   € à�z‰zÐr   c                ó   € V P                   # r   )Ú
_alignmentr   s   &r   Ú_get_alignmentÚAlignedSent._get_alignment@   s   € Ø�‰Ðr   c                óx   € \        \        V P                  4      \        V P                  4      V4       Wn        R # r   )Ú_check_alignmentÚlenr   r   r   )r   r   s   &&r   Ú_set_alignmentÚAlignedSent._set_alignmentC   s#   € Üœ˜TŸZ™Z›¬#¨d¯i©i«.¸)ÔDØ#Žr   c                óÔ   € RRP                  R V P                   4       4      ,          pRRP                  R V P                   4       4      ,          pRV RV RV P                  : R2# )zG
Return a string representation for this ``AlignedSent``.

:rtype: str
z[%s]z, c              3   ó4   "  € T F  pR V,          x € K  	  R# 5i©z'%s'N© ©Ú.0Úws   & r   Ú	<genexpr>Ú'AlignedSent.__repr__.<locals>.<genexpr>O   s   é € Ð#D¹°1 F¨Q§J¢J»ùó   ‚c              3   ó4   "  € T F  pR V,          x € K  	  R# 5ir$   r%   r&   s   & r   r)   r*   P   s   é € Ð"B±z°! 6¨A§:¢:³zùr+   zAlignedSent(Ú))Újoinr   r	   r   )r   r   r   s   &  r   Ú__repr__ÚAlignedSent.__repr__I   s^   € ð ˜$Ÿ)™)Ñ#D¸¿ºÓ#DÓDÕEˆØ˜Ÿ™Ñ"B°t·z²zÓ"BÓBÕCˆà˜e˜W B t f¨B¨t¯©Ñ.AÀÐCÐCr   c                óh  € RpVR,          pTRP                  V P                   Uu. uF  pRV RV R2NK  	  up4      ,          pTRP                  V P                   Uu. uF  pRV RV R2NK  	  up4      ,          pTRP                  V P                   UUu. uF0  w  r4RV P                  V,           RV P                  V,           R	2NK2  	  upp4      ,          p\	        \        V P                  4      ^,
          4       FE  pVR
P                  V P                  V,          V P                  V^,           ,          4      ,          pKG  	  \	        \        V P                  4      ^,
          4       FE  pVRP                  V P                  V,          V P                  V^,           ,          4      ,          pKG  	  VRRP                  R V P                   4       4      ,          ,          pVRRP                  R V P                   4       4      ,          ,          pVR,          pV# u upi u upi u uppi )z,
Dot representation of the aligned sentence
zgraph align {
znode[shape=plaintext]
Ú Ú"z_source" [label="z"] 
z_target" [label="z_source" -- "z
_target" 
z)"{}_source" -- "{}_source" [style=invis]
z)"{}_target" -- "{}_target" [style=invis]
z{rank = same; %s}
Ú c              3   ó4   "  € T F  pR V,          x € K  	  R# 5i)z"%s_source"Nr%   r&   s   & r   r)   Ú&AlignedSent._to_dot.<locals>.<genexpr>v   s   é € Ð.VÉ+ÀQ¨}¸q×/@Ò/@Ë+ùr+   c              3   ó4   "  € T F  pR V,          x € K  	  R# 5i)z"%s_target"Nr%   r&   s   & r   r)   r6   w   s   é € Ð.UÉ*ÀQ¨}¸q×/@Ò/@Ë*ùr+   Ú})r.   r   r	   r   Úranger   Úformat)r   Úsr(   ÚuÚvÚis   &     r   Ú_to_dotÚAlignedSent._to_dotT   sã  € ð ˆØ	Ð&Õ&ˆð 	
ˆR�W‰WÀÇÂÓLÁ¸1˜˜!˜Ð-¨a¨S°Ó6ÁÑLÓMÕMˆØ	ˆR�W‰WÀÇ
Â
ÓKÁ
¸1˜˜!˜Ð-¨a¨S°Ó6Á
ÑKÓLÕLˆð 	
ˆR�W‰Wð !ŸOšOôá+‘D�Að �D—K‘K •NÐ# =°·±¸Aµ°¸{ÓKÙ+òó
õ 	
ˆô ”s˜4Ÿ;™;Ó'¨!Õ+Ö,ˆAØÐ=×DÑDØ—‘˜A•Ø—‘˜A �EÕ"óõ ŠAñ -ô ”s˜4Ÿ:™:“¨Õ*Ö+ˆAØÐ=×DÑDØ—
‘
˜1•Ø—
‘
˜1˜q�5Õ!óõ ŠAñ ,ð 	
Ð" c§h¡hÑ.VÈ$Ï+Ê+Ó.VÓ&VÕWÕWˆØ	Ð" c§h¡hÑ.UÈ$Ï*Ê*Ó.UÓ&UÕVÕVˆà	ˆS�ˆàˆùò? MùÚKùós   ¦H$
ÁH)
Â6H.c                óf  € V P                  4       P                  R4      pRp \        P                  ! RRV,          .\        P                  \        P                  \        P                  R7      pTP                  T4      w  rVTP                  R4      #   \
         d   p\        R4      ThRp?ii ; i)zB
Ipython magic : show SVG representation of this ``AlignedSent``.
Úutf8ÚsvgÚdotz-T%s)ÚstdinÚstdoutÚstderrz0Cannot find the dot binary from Graphviz packageN)	r?   ÚencodeÚ
subprocessÚPopenÚPIPEÚOSErrorÚ	ExceptionÚcommunicateÚdecode)r   Ú
dot_stringÚoutput_formatÚprocessÚeÚoutÚerrs   &      r   Ú
_repr_svg_ÚAlignedSent._repr_svg_}   s�   € ð —\‘\“^×*Ñ*¨6Ó2ˆ
Øˆð	WÜ ×&Ò&Ø˜ Õ.Ð/Ü —o‘oÜ!—‘Ü!—‘ô	ˆGð ×&Ñ& zÓ2‰ˆà�z‰z˜&Ó!Ð!øô	 ô 	WÜÐNÓOÐUVÐVûð	Wús   £AB ÂB0ÂB+Â+B0c                ó¸   € RP                  V P                  4      R,          R,           pRP                  V P                  4      R,          R,           pRV RV R2# )zV
Return a human-readable string representation for this ``AlignedSent``.

:rtype: str
r4   :Né   Nz...z<AlignedSent: 'z' -> 'z'>)r.   r   r	   )r   ÚsourceÚtargets   &  r   Ú__str__ÚAlignedSent.__str__�   sQ   € ð —‘˜$Ÿ+™+Ó& sÕ+¨eÕ3ˆØ—‘˜$Ÿ*™*Ó% cÕ*¨UÕ2ˆØ   ¨¨v¨h°bÐ9Ð9r   c                ót   € \        V P                  V P                  V P                  P	                  4       4      # )zU
Return the aligned sentence pair, reversing the directionality

:rtype: AlignedSent
)r   r	   r   r   Úinvertr   s   &r   r_   ÚAlignedSent.invertš   s(   € ô ˜4Ÿ:™: t§{¡{°D·O±O×4JÑ4JÓ4LÓMÐMr   )r   r	   r   r   r   )Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Úpropertyr   r   r   r    r   r/   r?   rV   r\   r_   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r      sq   ø‡ € ñô>'ð ñó ðð ñó ðòò$ñ ˜¨Ó8€Iò	Dò'òR"ò&:÷Nð Nr   r   c                   ób   a € ] tR t^£t o RtR t]R 4       tR tR t	RR lt
R tR	 tR
 tRtV tR# )r
   a  
A storage class for representing alignment between two sequences, s1, s2.
In general, an alignment is a set of tuples of the form (i, j, ...)
representing an alignment between the i-th element of s1 and the
j-th element of s2.  Tuples are extensible (they might contain
additional data, such as a boolean to indicate sure vs possible alignments).

    >>> from nltk.translate import Alignment
    >>> a = Alignment([(0, 0), (0, 1), (1, 2), (2, 2)])
    >>> a.invert()
    Alignment([(0, 0), (1, 0), (2, 1), (2, 2)])
    >>> print(a.invert())
    0-0 1-0 2-1 2-2
    >>> a[0]
    [(0, 1), (0, 0)]
    >>> a.invert()[2]
    [(2, 1), (2, 2)]
    >>> b = Alignment([(0, 0), (0, 1)])
    >>> b.issubset(a)
    True
    >>> c = Alignment.fromstring('0-0 0-1')
    >>> b == c
    True
c                ó�   € \         P                  W4      pV\        . 4      8w  d   \        R  V 4       4      M^ Vn        RVn        V# )c              3   ó2   "  € T F  q^ ,          x € K  	  R# 5i©r   Nr%   ©r'   Úps   & r   r)   Ú$Alignment.__new__.<locals>.<genexpr>¿   s   é € Ð+¡d ˜!Ÿš£dùs   ‚N)Ú	frozensetÚ__new__ÚmaxÚ_lenÚ_index)ÚclsÚpairsr   s   && r   rs   ÚAlignment.__new__½   s=   € Ü× Ñ  Ó,ˆØ/3´yÀ³}Ô/D”CÑ+¡dÓ+Ô+È!ˆŒ	ØˆŒØˆr   c                óp   € \        VP                  4        Uu. uF  p\        V4      NK  	  up4      # u upi )a]  
Read a giza-formatted string and return an Alignment object.

    >>> Alignment.fromstring('0-0 2-1 9-2 21-3 10-4 7-5')
    Alignment([(0, 0), (2, 1), (7, 5), (9, 2), (10, 4), (21, 3)])

:type s: str
:param s: the positional alignments in giza format
:rtype: Alignment
:return: An Alignment object corresponding to the string representation ``s``.
)r
   ÚsplitÚ
_giza2pair)rw   r;   Úas   && r   Ú
fromstringÚAlignment.fromstringÃ   s+   € ô °·±´Ó;±¨Aœ* Qž-±Ñ;Ó<Ð<ùÒ;s   ˜3c                ó|   € V P                   '       g   V P                  4        V P                   P                  V4      # )z>
Look up the alignments that map from a given index or slice.
)rv   Ú_build_indexÚ__getitem__)r   Úkeys   &&r   r‚   ÚAlignment.__getitem__Ó   s.   € ð �{�{ˆ{Ø×ÑÔØ�{‰{×&Ñ& sÓ+Ð+r   c                ó&   € \        R V  4       4      # )z9
Return an Alignment object, being the inverted mapping.
c              3   ó`   "  € T F$  q^,          V^ ,          3VR,          ,           x € K&  	  R# 5i)é   :é   NNNr%   ro   s   & r   r)   Ú#Alignment.invert.<locals>.<genexpr>ß   s&   é € Ð>¹°A˜Q�4  1¥˜,¨¨2­×.Ò.»ùs   ‚,.)r
   r   s   &r   r_   ÚAlignment.invertÛ   s   € ô Ñ>¹Ó>Ó>Ð>r   Nc                ó2  € \        4       pV P                  '       g   V P                  4        V'       g(   \        \	        \        V P                  4      4      4      pV F,  pVP                  R V P                  V,           4       4       K.  	  \        V4      # )z…
Work out the range of the mapping from the given positions.
If no positions are specified, compute the range of the entire mapping.
c              3   ó*   "  € T F	  w  rVx € K  	  R # 5ir   r%   )r'   Ú_Úfs   &  r   r)   Ú"Alignment.range.<locals>.<genexpr>ì   s   é € Ð6¡~™t˜q�£~ùs   ‚)Úsetrv   r�   Úlistr9   r   ÚupdateÚsorted)r   Ú	positionsÚimagerp   s   &&  r   r9   ÚAlignment.rangeá   si   € ô
 “ˆØ�{�{ˆ{Ø×ÑÔßÜœU¤3 t§{¡{Ó#3Ó4Ó5ˆIÛˆAØ�L‰LÑ6 t§{¡{°1¦~Ó6Ö6ñ ä�e‹}Ðr   c                ó&   € R\        V 4      ,          # )ú=
Produce a Giza-formatted string representing the alignment.
zAlignment(%r))r“   r   s   &r   r/   ÚAlignment.__repr__ï   s   € ð ¤¨£Õ-Ð-r   c                óD   € RP                  R \        V 4       4       4      # )r˜   r4   c              3   óB   "  € T F  pR VR,          ,          x € K  	  R# 5i)z%d-%d:Nrˆ   NNr%   ro   s   & r   r)   Ú$Alignment.__str__.<locals>.<genexpr>ù   s   é € Ð>±¨A˜ ! B¥%Ÿš³ùs   ‚)r.   r“   r   s   &r   r\   ÚAlignment.__str__õ   s   € ð �x‰xÑ>´¸´Ó>Ó>Ð>r   c                óÖ   € \        V P                  ^,           4       Uu. uF  p. NK  	  upV n        V  F,  pV P                  V^ ,          ,          P                  V4       K.  	  R# u upi )zh
Build a list self._index such that self._index[i] is a list
of the alignments originating from word i.
N)r9   ru   rv   Úappend)r   r�   rp   s   &  r   r�   ÚAlignment._build_indexû   sS   € ô
 $)¨¯©°Q­Ô#7Ó8Ñ#7˜a“rÑ#7Ñ8ˆŒÛˆAØ�K‰K˜˜!�Õ×$Ñ$ QÖ'ó ùò 9s   ŸA&)rv   ru   r   )ra   rb   rc   rd   re   rs   Úclassmethodr~   r‚   r_   r9   r/   r\   r�   rg   rh   ri   s   @r   r
   r
   £   sF   ø‡ € ñò2ð ñ=ó ð=ò,ò?ôò.ò?÷(ð (r   r
   c                 óT   € V P                  R 4      w  r\        V4      \        V4      3# ©Ú-©r{   Úint)Úpair_stringr>   Újs   &  r   r|   r|     s&   € Ø×Ñ˜SÓ!�D€AÜˆq‹6”3�q“6ˆ>Ðr   c                 óV   € V P                  R 4      w  rp\        V4      \        V4      3# r£   r¥   )r§   r>   r¨   rp   s   &   r   Ú_naacl2pairrª   
  s(   € Ø×Ñ Ó$�G€Aˆ!Üˆq‹6”3�q“6ˆ>Ðr   c                ó`  a a€ \        V4      \        J g   Q h\        ;QJ d    V 3R lV 4       F  '       d   K   RM	  RM! V 3R lV 4       4      '       g   \        R4      h\        ;QJ d    V3R lV 4       F  '       d   K   RM	  RM! V3R lV 4       4      '       g   \        R4      hR# )a>  
Check whether the alignments are legal.

:param num_words: the number of source language words
:type num_words: int
:param num_mots: the number of target language words
:type num_mots: int
:param alignment: alignment to be checked
:type alignment: Alignment
:raise IndexError: if alignment falls outside the sentence
c              3   ó^   <"  € T F"  p^ V^ ,          u;8*  ;'       d    S8  Mu x € K$  	  R# 5irn   r%   )r'   ÚpairÚ	num_wordss   & €r   r)   Ú#_check_alignment.<locals>.<genexpr>  s%   øé € Ð>±I¨Dˆq�D˜•G×'Ô'˜i×'Ñ'³Iùs   ƒ-�-FTz&Alignment is outside boundary of wordsc              3   ó‚   <"  € T F4  q^,          RJ ;'       g    ^ V^,          u;8*  ;'       d    S8  Mu x € K6  	  R# 5i)r‡   Nr%   )r'   r­   Únum_motss   & €r   r)   r¯      s3   øé € ÐPÁi¸d�A�w˜$ˆ×9Ð9 ! t¨A¥w×"9Ô"9°Ô"9Ô9Ãiùs   ƒ?™?¯?z%Alignment is outside boundary of motsN)r   r
   ÚallÚ
IndexError)r®   r±   r   s   ff&r   r   r     sw   ù€ ô �	‹?œiÓ'Ð'Ð'ç‹3Ô>±IÓ>�3�3Š3Ô>±IÓ>×>Ò>ÜÐAÓBÐBß‹3ÔPÁiÓP�3�3Š3ÔPÁiÓP×PÒPÜÐ@ÓAÐAñ Qr   ÚPhraseTableEntryÚ
trg_phraseÚlog_probc                   ó<   a € ] tR tRt o RtR tR tR tR tRt	V t
R# )	ÚPhraseTablei'  zg
In-memory store of translations for a given phrase, and the log
probability of the those translations
c                ó$   € \        4       V n        R # r   )ÚdictÚsrc_phrasesr   s   &r   r   ÚPhraseTable.__init__-  s   € Ü›6ˆÖr   c                ó(   € V P                   V,          # )a}  
Get the translations for a source language phrase

:param src_phrase: Source language phrase of interest
:type src_phrase: tuple(str)

:return: A list of target language phrases that are translations
    of ``src_phrase``, ordered in decreasing order of
    likelihood. Each list element is a tuple of the target
    phrase and its log probability.
:rtype: list(PhraseTableEntry)
©r»   ©r   Ú
src_phrases   &&r   Útranslations_forÚPhraseTable.translations_for0  s   € ð ×Ñ 
Õ+Ð+r   c                óê   € \        W#R7      pWP                  9  d   . V P                  V&   V P                  V,          P                  V4       V P                  V,          P                  R RR7       R# )z´
:type src_phrase: tuple(str)
:type trg_phrase: tuple(str)

:param log_prob: Log probability that given ``src_phrase``,
    ``trg_phrase`` is its translation
:type log_prob: float
)rµ   r¶   c                 ó   € V P                   # r   )r¶   )rS   s   &r   Ú<lambda>Ú!PhraseTable.add.<locals>.<lambda>L  s   € ¸¿
º
r   T)rƒ   ÚreverseN)r´   r»   rŸ   Úsort)r   rÀ   rµ   r¶   Úentrys   &&&& r   ÚaddÚPhraseTable.add?  sb   € ô !¨JÔJˆØ×-Ñ-Ô-Ø+-ˆD×Ñ˜ZÑ(Ø×Ñ˜Õ$×+Ñ+¨EÔ2Ø×Ñ˜Õ$×)Ñ)Ñ.BÈDÐ)ÖQr   c                ó   € WP                   9   # r   r¾   r¿   s   &&r   Ú__contains__ÚPhraseTable.__contains__N  s   € Ø×-Ñ-Ñ-Ð-r   r¾   N)ra   rb   rc   rd   re   r   rÁ   rÊ   rÍ   rg   rh   ri   s   @r   r¸   r¸   '  s$   ø‡ € ñò
"ò,òR÷.ð .r   r¸   )rI   Úcollectionsr   r   rr   r
   r|   rª   r   r´   r¸   r%   r   r   Ú<module>rÐ      sZ   ðó Ý "÷QNñ QNôh_(�	ô _(òDò
ò
Bñ* Ð0°<ÀÐ2LÓMÐ ÷(.ó (.r   