+
    ÖÇÜh&  ã                   ó¬   € ^ RI t ^ RIHt ^ RIHt ^ RIHt  ^ RIt^ RI	H
t
  ! R R]
4      tR tR	 t ! R
 R4      t ! R R4      tR#   ] d     L6i ; i)é    N)Úabstractmethod)Úsqrt)Ústdout)ÚClusterIc                   óv   a € ] tR t^t o RtRR ltRR lt]R 4       tR t	]R 4       t
R tR	 tR
 tR tRtV tR# )ÚVectorSpaceClustererz™
Abstract clusterer which takes tokens and maps them into a vector space.
Optionally performs singular value decomposition to reduce the
dimensionality.
Nc                ó,   € RV n         Wn        W n        R# )zù
:param normalise:       should vectors be normalised to length 1
:type normalise:        boolean
:param svd_dimensions:  number of dimensions to use in reducing vector
                        dimensionsionality with SVD
:type svd_dimensions:   int
N©Ú_TtÚ_should_normaliseÚ_svd_dimensions)ÚselfÚ	normaliseÚsvd_dimensionss   &&&Ú3/usr/lib/python3/dist-packages/nltk/cluster/util.pyÚ__init__ÚVectorSpaceClusterer.__init__   s   € ð ˆŒØ!*ÔØ-Öó    c                ór  € \        V4      ^ 8”  g   Q hV P                  '       d    \        \        V P                  V4      4      pV P
                  '       Ed#   V P
                  \        V^ ,          4      8  Ed   \        P                  P                  \        P                  ! \        P                  ! V4      4      4      w  rEpVRV P
                   \        P                  ! V P
                  \        P                  4      ,          pVRRV P
                  13,          pVRV P
                  1R3,          p	\        P                  ! \        P                  ! Wy4      4      p\        P                  ! V4      V n        V P                  W4       V'       d!   V U
u. uF  q P!                  V
4      NK  	  up
# R# u up
i )r   N:NNN)Úlenr   ÚlistÚmapÚ
_normaliser   ÚnumpyÚlinalgÚsvdÚ	transposeÚarrayÚidentityÚfloat64Údotr   Úcluster_vectorspaceÚclassify)r   ÚvectorsÚassign_clustersÚtraceÚuÚdÚvtÚSÚTÚDtÚvectors   &&&&       r   ÚclusterÚVectorSpaceClusterer.cluster(   sN  € Ü�7‹|˜aÔÐÐð ×!×!Ð!Üœ3˜tŸ™°Ó8Ó9ˆGð ××Ñ D×$8Ñ$8¼3¸wÀq½z»?Õ$JÜŸ™×)Ñ)¬%¯/ª/¼%¿+º+ÀgÓ:NÓ*OÓP‰JˆQ�2ØÐ(�D×(Ñ(Ð)¬E¯NªNØ×$Ñ$¤e§m¡mó-õ ˆAð �!Ð+�t×+Ñ+Ð+Ð+Õ,ˆAØÐ*�d×*Ñ*Ð*¨AÐ-Õ.ˆBÜ—o’o¤e§i¢i°Ó&6Ó7ˆGÜ—’ qÓ)ˆDŒHð 	× Ñ  Ô0÷ Ù8?Ó@¹¨f—M‘M &Ö)¹Ñ@Ð@ñ ùÚ@s   ÆF4c                ó   € R# )z4
Finds the clusters using the given set of vectors.
N© )r   r$   r&   s   &&&r   r"   Ú(VectorSpaceClusterer.cluster_vectorspaceA   ó   ‚ r   c                óê   € V P                   '       d   V P                  V4      pV P                  e"   \        P                  ! V P                  V4      pV P                  V4      pV P                  V4      # ©N)r   r   r   r   r!   Úclassify_vectorspaceÚcluster_name)r   r-   r.   s   && r   r#   ÚVectorSpaceClusterer.classifyG   s[   € Ø×!×!Ð!Ø—_‘_ VÓ,ˆFØ�8‰8ÒÜ—Y’Y˜tŸx™x¨Ó0ˆFØ×+Ñ+¨FÓ3ˆØ× Ñ  Ó)Ð)r   c                ó   € R# )z>
Returns the index of the appropriate cluster for the vector.
Nr1   ©r   r-   s   &&r   r6   Ú)VectorSpaceClusterer.classify_vectorspaceO   r3   r   c                óÈ   € V P                   '       d   V P                  V4      pV P                  e"   \        P                  ! V P                  V4      pV P                  W4      # r5   )r   r   r   r   r!   Úlikelihood_vectorspace)r   r-   Úlabels   &&&r   Ú
likelihoodÚVectorSpaceClusterer.likelihoodU   sK   € Ø×!×!Ð!Ø—_‘_ VÓ,ˆFØ�8‰8ÒÜ—Y’Y˜tŸx™x¨Ó0ˆFØ×*Ñ*¨6Ó9Ð9r   c                ó8   € V P                  V4      pW#8X  d   R# R# )z@
Returns the likelihood of the vector belonging to the cluster.
g      ð?g        )r6   )r   r-   r.   Ú	predicteds   &&& r   r=   Ú+VectorSpaceClusterer.likelihood_vectorspace\   s$   € ð ×-Ñ-¨fÓ5ˆ	ØÔ*ˆsÐ3°Ð3r   c                óª   € V P                   '       d   V P                  V4      pV P                  e"   \        P                  ! V P                  V4      pV# )zE
Returns the vector after normalisation and dimensionality reduction
)r   r   r   r   r!   r:   s   &&r   r-   ÚVectorSpaceClusterer.vectorc   sA   € ð ×!×!Ð!Ø—_‘_ VÓ,ˆFØ�8‰8ÒÜ—Y’Y˜tŸx™x¨Ó0ˆFØˆr   c                óN   € V\        \        P                  ! W4      4      ,          # )z'
Normalises the vector to unit length.
©r   r   r!   r:   s   &&r   r   ÚVectorSpaceClusterer._normalisem   s   € ð œœUŸYšY vÓ6Ó7Õ7Ð7r   r
   )FN)FF)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   r.   r   r"   r#   r6   r?   r=   r-   r   Ú__static_attributes__Ú__classdictcell__©Ú__classdict__s   @r   r   r      s[   ø‡ € ñô
.ôAð2 ñó ðò
*ð ñó ðò
:ò4ò÷8ð 8r   r   c                óP   € W,
          p\        \        P                  ! W"4      4      # )zq
Returns the euclidean distance between vectors u and v. This is equivalent
to the length of the vector (u - v).
rG   )r'   ÚvÚdiffs   && r   Úeuclidean_distancerU   t   s   € ð
 �5€DÜ”—	’	˜$Ó%Ó&Ð&r   c           	     óÌ   € ^\         P                  ! W4      \        \         P                  ! W 4      4      \        \         P                  ! W4      4      ,          ,          ,
          # )zk
Returns 1 minus the cosine of the angle between vectors v and u. This is
equal to ``1 - (u.v / |u||v|)``.
)r   r!   r   )r'   rS   s   &&r   Úcosine_distancerW   }   s;   € ð
 ”—	’	˜!“¤4¬¯	ª	°!«Ó#8¼4ÄÇ	Â	È!ÃÓ;PÕ#PÕQÕRÐRr   c                   ó@   a € ] tR t^…t o RtR tRR ltR tR tRt	V t
R# )	Ú_DendrogramNodezTree node of a dendrogram.c                ó   € Wn         W n        R # r5   )Ú_valueÚ	_children)r   ÚvalueÚchildrens   &&*r   r   Ú_DendrogramNode.__init__ˆ   s   € ØŒØ!Žr   c                óÄ   € V P                   '       d8   . pV P                    F#  pVP                  VP                  V4      4       K%  	  V# V'       d   V P                  .# V .# r5   )r\   ÚextendÚleavesr[   )r   Úvaluesrb   Úchilds   &&  r   rb   Ú_DendrogramNode.leavesŒ   sN   € Ø�>�>ˆ>ØˆFØŸœ�Ø—‘˜eŸl™l¨6Ó2Ö3ñ (àˆMßØ—K‘K�=Ð à�6ˆMr   c                óÜ  € V P                   V 3.p\        V4      V8  d¡   VP                  4       w  r4VP                  '       g   VP	                  W434       MiVP                   FG  pVP                  '       d    VP                  VP                   V34       K4  VP                  ^ V34       KI  	  VP                  4        K°  . pV F$  w  r4VP                  VP                  4       4       K&  	  V# ©r   )r[   r   Úpopr\   ÚpushÚappendÚsortrb   )r   ÚnÚqueueÚpriorityÚnoderd   Úgroupss   &&     r   rp   Ú_DendrogramNode.groups—   sµ   € Ø—+‘+˜tÐ$Ð%ˆä�%‹j˜1ŒnØ"ŸY™Y›[‰NˆHØ—>—>�>Ø—
‘
˜HÐ+Ô,ØØŸœ�Ø—?—?�?Ø—L‘L %§,¡,°Ð!6Ö7à—L‘L ! U Ö,ñ	 (ð �J‰JŽLàˆÛ#‰NˆHØ�M‰M˜$Ÿ+™+›-Ö(ñ $àˆr   c                óH   € \        V P                  VP                  4      ^ 8  # rg   )rW   r[   )r   Ú
comparators   &&r   Ú__lt__Ú_DendrogramNode.__lt__¬   s   € Ü˜tŸ{™{¨J×,=Ñ,=Ó>ÀÑBÐBr   )r\   r[   N)T)rI   rJ   rK   rL   rM   r   rb   rp   rt   rN   rO   rP   s   @r   rY   rY   …   s#   ø‡ € Ù$ò"ô	ò÷*Cð Cr   rY   c                   óN   a € ] tR t^°t o Rt. 3R ltR tR t. 3R ltR t	Rt
V tR# )	Ú
Dendrogramzó
Represents a dendrogram, a tree with a specified branching order.  This
must be initialised with the leaf items, then iteratively call merge for
each branch. This class constructs a tree representing the order of calls
to the merge function.
c                ó¨   € V Uu. uF  p\        V4      NK  	  upV n        \        P                  ! V P                  4      V n        ^V n        R# u upi )z[
:param  items: the items at the leaves of the dendrogram
:type   items: sequence of (any)
N)rY   Ú_itemsÚcopyÚ_original_itemsÚ_merge)r   ÚitemsÚitems   && r   r   ÚDendrogram.__init__¸   sA   € ñ
 :?Ó?¹°” tÖ,¹Ñ?ˆŒÜ#Ÿyšy¨¯©Ó5ˆÔØˆŽùò @s   …Ac                ó  a € \        V4      ^8¼  g   Q h\        S P                  .V 3R lV 4       O5!  pS ;P                  ^,          un        VS P                  V^ ,          &   VR,           F  pS P                  V K  	  R# )a  
Merges nodes at given indices in the dendrogram. The nodes will be
combined which then replaces the first node specified. All other nodes
involved in the merge will be removed.

:param  indices: indices of the items to merge (at least two)
:type   indices: seq of int
c              3   óJ   <"  € T F  pSP                   V,          x € K  	  R # 5ir5   )ry   )Ú.0Úir   s   & €r   Ú	<genexpr>Ú#Dendrogram.merge.<locals>.<genexpr>Ë   s   øé € Ð-NÁgÀ¨d¯k©k¸!¯nªnÃgùs   ƒ #:é   NNN)r   rY   r|   ry   )r   Úindicesro   rƒ   s   f*  r   ÚmergeÚDendrogram.mergeÁ   sk   ø€ ô �7‹|˜qÔ Ð Ð Ü˜tŸ{™{ÐOÔ-NÁgÓ-NÓOˆØ�Š�qÕ�Ø"&ˆ�‰�G˜A•JÑØ˜—�ˆAØ—‘˜A’ó r   c                óÂ   € \        V P                  4      ^8”  d#   \        V P                  .V P                  O5!  pMV P                  ^ ,          pVP	                  V4      # )zr
Finds the n-groups of items (leaves) reachable from a cut at depth n.
:param  n: number of groups
:type   n: int
)r   ry   rY   r|   rp   )r   rl   Úroots   && r   rp   ÚDendrogram.groupsÑ   sG   € ô ˆt�{‰{Ó˜aÔÜ" 4§;¡;Ð=°·±Ó=‰Dà—;‘;˜q•>ˆDØ�{‰{˜1‹~Ðr   c                óž  aaa€ RRRrCp\        V P                  4      ^8”  d#   \        V P                  .V P                  O5!  pMV P                  ^ ,          pV P                  pV'       d   TpM"V Uu. uF  pRVP
                  ,          NK  	  pp\        \        \         V4      4      ^,           oS^,          o\        SS,
          ^,
          4      oRVV3R llp	R p
VP
                  V3.pV Uu. uF
  q‰! R4      NK  	  ppV'       EdŽ   VP                  4       w  rÞ\        \        R VP                  4      4      p\        \        VP                  V4      4      pV'       d   \        V4      p\        V4      p\        \        V4      4       FŽ  pVV,          V9   dL   VX8X  d   V
! V	! VRV4      4       M&VX8X  d   V
! V	! W#R4      4       MV
! V	! W#V4      4       V	! V4      VV&   K\  XTu;8:  d   X8:  d   M MV
! V	! W3V4      4       K  V
! VV,          4       K�  	  V
! R	4       VP                   F4  pVP                  '       g   K  VP                  VP
                  V34       K6  	  VP!                  4        V F  pV
! V4       K  	  V
! R	4       EK–  V
! R
P#                  V3R lV 4       4      4       V
! R	4       R# u upi u upi )z°
Print the dendrogram in ASCII art to standard out.

:param leaf_labels: an optional list of strings to use for labeling the
                    leaves
:type leaf_labels: list
Ú+Ú-Ú|z%sÚ c                 ó0   <€ SV,           V  VS,           2# r5   r1   )ÚcentreÚleftÚrightÚlhalfÚrhalfs   &&&€€r   ÚformatÚDendrogram.show.<locals>.formatû   s   ø€ Ø˜d•l�^ F 8¨E°E­M¨?Ð;Ð;r   c                 ó2   € \         P                  ! V 4       R # r5   )r   Úwrite)Ústrs   &r   ÚdisplayÚ Dendrogram.show.<locals>.displayþ   s   € Ü�LŠL˜Ör   c                 ó2   € V P                  R 4      ^ ,          # )F)rb   )Úcs   &r   Ú<lambda>Ú!Dendrogram.show.<locals>.<lambda>  s   € °·±¸%³ÀÖ1Cr   Ú
Ú c              3   óD   <"  € T F  qP                  S4      x € K  	  R # 5ir5   )Úcenter)r‚   r~   Úwidths   & €r   r„   Ú"Dendrogram.show.<locals>.<genexpr>#  s   øé € Ð@±x¨tŸ™ E×*Ð*³xùs   ƒ N)r‘   r‘   )r   ry   rY   r|   r{   r[   Úmaxr   Úintrh   r   r\   ÚindexÚminÚrangerj   rk   Újoin)r   Úleaf_labelsÚJOINÚHLINKÚVLINKr‹   rb   Úlast_rowÚleafr˜   r�   rm   Ú	verticalsrn   ro   Úchild_left_leafr‡   Úmin_idxÚmax_idxrƒ   rd   Úverticalr–   r—   r§   s   &&                    @@@r   ÚshowÚDendrogram.showÝ   sO  ú€ ð ! # s�Uˆô ˆt�{‰{Ó˜aÔÜ" 4§;¡;Ð=°·±Ó=‰Dà—;‘;˜q•>ˆDØ×%Ñ%ˆçØ"‰Há7=Ó>±v¨t˜˜tŸ{™{×*Ð*±vˆHÐ>ô ”Cœ˜XÓ&Ó'¨!Õ+ˆØ˜•
ˆÜ�E˜E•M AÕ%Ó&ˆ÷	<ð 	<ò	ð —+‘+˜tÐ$Ð%ˆÙ-3Ó4©V T�V˜C–[©Vˆ	Ð4ßˆeØ"ŸY™Y›[‰NˆHÜ"¤3Ñ'CÀTÇ^Á^Ó#TÓUˆOÜœ3˜vŸ|™|¨_Ó=Ó>ˆGßÜ˜g›,�Ü˜g›,�Üœ3˜v›;Ö'�Ø˜!•9 Ô/Ø˜G”|Ù¡ t¨S°%Ó 8Õ9Ø˜gœÙ¡ t°CÓ 8Õ9á¡ t°EÓ :Ô;Ù#)¨%£=�I˜a“LØ Ö, W×,Ù™F 5°Ó7Ö8á˜I a�LÖ)ñ (ñ �DŒMØŸœ�Ø—?—?’?Ø—L‘L %§,¡,°Ð!6Ö7ñ (ð �J‰JŒLã%�Ù˜Ö!ñ &á�D�Mñ 	�—‘Ô@±xÓ@Ó@ÔAÙ�Žùòc ?ùò  5s   Á3KÃ2K
c                óæ   € \        V P                  4      ^8”  d#   \        V P                  .V P                  O5!  pMV P                  ^ ,          pVP	                  R4      pR\        V4      ,          # )r†   Fz<Dendrogram with %d leaves>)r   ry   rY   r|   rb   )r   r‹   rb   s   &  r   Ú__repr__ÚDendrogram.__repr__&  sT   € Üˆt�{‰{Ó˜aÔÜ" 4§;¡;Ð=°·±Ó=‰Dà—;‘;˜q•>ˆDØ—‘˜UÓ#ˆØ,¬s°6«{Õ:Ð:r   )ry   r|   r{   N)rI   rJ   rK   rL   rM   r   rˆ   rp   rº   r½   rN   rO   rP   s   @r   rw   rw   °   s4   ø‡ € ñð  ô òò 
ð  "ô G÷R;ð ;r   rw   )rz   Úabcr   Úmathr   Úsysr   r   ÚImportErrorÚnltk.cluster.apir   r   rU   rW   rY   rw   r1   r   r   Ú<module>rÄ      sh   ðó Ý Ý Ý ð	Ûõ &ô\8˜8ô \8ò~'òS÷(Cñ (C÷V|;ó |;øðC ô 	Ùð	ús   ˜A	 Á	AÁA