+
    ÖÇÜhš  ã                   óÞ   € R t ^ RIHtHt ^ RIHtHtHt  ! R R]4      t ! R R]4      t	 ! R R]	4      t
 ! R	 R
]4      t ! R R]4      t ! R R]4      t ! R R]4      t ! R R]4      tR# )zLanguage Models)ÚLanguageModelÚ	Smoothing)ÚAbsoluteDiscountingÚ	KneserNeyÚ
WittenBellc                   ó.   a € ] tR t^t o RtRR ltRtV tR# )ÚMLEzZClass for providing MLE ngram model scores.

Inherits initialization from BaseNgramModel.
Nc                óB   € V P                  V4      P                  V4      # )z£Returns the MLE score for a word given a context.

Args:
- word is expected to be a string
- context is expected to be something reasonably convertible to a tuple
)Úcontext_countsÚfreq)ÚselfÚwordÚcontexts   &&&Ú0/usr/lib/python3/dist-packages/nltk/lm/models.pyÚunmasked_scoreÚMLE.unmasked_score   s    € ð ×"Ñ" 7Ó+×0Ñ0°Ó6Ð6ó    © ©N)Ú__name__Ú
__module__Ú__qualname__Ú__firstlineno__Ú__doc__r   Ú__static_attributes__Ú__classdictcell__)Ú__classdict__s   @r   r   r      s   ø‡ € ñ÷
7ò 7r   r   c                   ó@   a a€ ] tR t^t oRtV 3R ltRR ltRtVtV ;t	# )ÚLidstonezŸProvides Lidstone-smoothed scores.

In addition to initialization arguments from BaseNgramModel also requires
a number by which to increase the counts, gamma.
c                ó4   <€ \         SV `  ! V/ VB  Wn        R # r   )ÚsuperÚ__init__Úgamma)r   r"   ÚargsÚkwargsÚ	__class__s   &&*,€r   r!   ÚLidstone.__init__%   ó   ø€ Ü‰Ò˜$Ð) &Ò)ØŽ
r   c                óÜ   € V P                  V4      pW1,          pVP                  4       pW@P                  ,           V\        V P                  4      V P                  ,          ,           ,          # )zdAdd-one smoothing: Lidstone or Laplace.

To see what kind, look at `gamma` attribute on the class.

)r
   ÚNr"   ÚlenÚvocab©r   r   r   ÚcountsÚ
word_countÚ
norm_counts   &&&   r   r   ÚLidstone.unmasked_score)   sN   € ð ×$Ñ$ WÓ-ˆØ•\ˆ
Ø—X‘X“Zˆ
ØŸZ™ZÕ'¨J¼¸T¿Z¹Z»È4Ï:É:Õ9UÕ,UÕVÐVr   )r"   r   ©
r   r   r   r   r   r!   r   r   r   Ú__classcell__©r%   r   s   @@r   r   r      s   ù‡ € ñõ÷	Wô 	Wr   r   c                   ó6   a a€ ] tR t^5t oRtV 3R ltRtVtV ;t# )ÚLaplacezoImplements Laplace (add one) smoothing.

Initialization identical to BaseNgramModel because gamma is always 1.
c                ó0   <€ \         SV `  ! ^.VO5/ VB  R# )é   N)r    r!   )r   r#   r$   r%   s   &*,€r   r!   ÚLaplace.__init__;   s   ø€ Ü‰Ò˜Ð,˜TÒ, VÔ,r   r   ©	r   r   r   r   r   r!   r   r   r2   r3   s   @@r   r5   r5   5   s   ù‡ € ñ÷
-õ -r   r5   c                   óD   a a€ ] tR t^?t oRtRV 3R lltRR ltRtVtV ;t	# )ÚStupidBackoffa$  Provides StupidBackoff scores.

In addition to initialization arguments from BaseNgramModel also requires
a parameter alpha with which we scale the lower order probabilities.
Note that this is not a true probability distribution as scores for ngrams
of the same order do not sum up to unity.
c                ó4   <€ \         SV `  ! V/ VB  Wn        R # r   )r    r!   Úalpha)r   r=   r#   r$   r%   s   &&*,€r   r!   ÚStupidBackoff.__init__H   r'   r   c                ó  € V'       g&   V P                   P                  P                  V4      # V P                  V4      pW1,          pVP	                  4       pV^ 8”  d	   WE,          # V P
                  V P                  WR,          4      ,          # ©é    :r7   NN)r-   Úunigramsr   r
   r)   r=   r   r,   s   &&&   r   r   ÚStupidBackoff.unmasked_scoreL   sp   € ßà—;‘;×'Ñ'×,Ñ,¨TÓ2Ð2Ø×$Ñ$ WÓ-ˆØ•\ˆ
Ø—X‘X“Zˆ
Ø˜Œ>ØÕ*Ð*à—:‘: × 3Ñ 3°DÀ"½+Ó FÕFÐFr   )r=   )gš™™™™™Ù?r   r1   r3   s   @@r   r;   r;   ?   s   ù‡ € ñ÷÷
Gô 
Gr   r;   c                   ó@   a a€ ] tR t^Yt oRtV 3R ltRR ltRtVtV ;t	# )ÚInterpolatedLanguageModelz•Logic common to all interpolated language models.

The idea to abstract this comes from Chen & Goodman 1995.
Do not instantiate this class directly!
c                ó”   <€ VP                  R / 4      p\        SV `  ! V3/ VB  V! V P                  V P                  3/ VB V n        R# )ÚparamsN)Úpopr    r!   r+   r-   Ú	estimator)r   Úsmoothing_clsÚorderr$   rG   r%   s   &&&, €r   r!   Ú"InterpolatedLanguageModel.__init__`   s@   ø€ Ø—‘˜H bÓ)ˆÜ‰Ò˜Ñ) &Ò)Ù& t§z¡z°4·;±;ÑIÀ&ÑIˆŽr   c                ó  € V'       g   V P                   P                  V4      # V P                  V,          '       g   ^ ^rCMV P                   P                  W4      w  r4W4V P	                  WR,          4      ,          ,           # r@   )rI   Úunigram_scorer-   Úalpha_gammar   )r   r   r   r=   r"   s   &&&  r   r   Ú(InterpolatedLanguageModel.unmasked_scoree   se   € ßà—>‘>×/Ñ/°Ó5Ð5Ø�{‰{˜7×#Ô#ð ˜a‘5àŸ>™>×5Ñ5°dÓD‰LˆEØ˜t×2Ñ2°4À½ÓEÕEÕEÐEr   )rI   r   r1   r3   s   @@r   rE   rE   Y   s   ù‡ € ñõJ÷
Fô Fr   rE   c                   ó6   a a€ ] tR t^st oRtV 3R ltRtVtV ;t# )ÚWittenBellInterpolatedz.Interpolated version of Witten-Bell smoothing.c                ó4   <€ \         SV `  ! \        V3/ VB  R # r   )r    r!   r   )r   rK   r$   r%   s   &&,€r   r!   ÚWittenBellInterpolated.__init__v   s   ø€ Ü‰Òœ UÑ5¨fÔ5r   r   r9   r3   s   @@r   rR   rR   s   s   ù‡ € Ù8÷6õ 6r   rR   c                   ó:   a a€ ] tR t^zt oRtRV 3R lltRtVtV ;t# )ÚAbsoluteDiscountingInterpolatedz9Interpolated version of smoothing with absolute discount.c                ó<   <€ \         SV `  ! \        V3R RV//VB  R# )rG   ÚdiscountN)r    r!   r   ©r   rK   rX   r$   r%   s   &&&,€r   r!   Ú(AbsoluteDiscountingInterpolated.__init__}   s*   ø€ Ü‰ÒÜ ñ	
Ø0:¸HÐ/Eð	
ØIOô	
r   r   )g      è?r9   r3   s   @@r   rV   rV   z   s   ù‡ € ÙC÷
÷ 
r   rV   c                   ó:   a a€ ] tR t^ƒt oRtRV 3R lltRtVtV ;t# )ÚKneserNeyInterpolatedz-Interpolated version of Kneser-Ney smoothing.c                óx   <€ ^ Tu;8:  d   ^8:  g   M \        R4      h\        SV `  ! \        V3RRVRV//VB  R# )rA   zCDiscount must be between 0 and 1 for probabilities to sum to unity.rG   rX   rK   N)Ú
ValueErrorr    r!   r   rY   s   &&&,€r   r!   ÚKneserNeyInterpolated.__init__†   sM   ø€ Ø�XÖ" Ö"ÜØUóð ô 	‰ÒÜ�uñ	
Ø&0°(¸GÀUÐ%Kð	
ØOUô	
r   r   )gš™™™™™¹?r9   r3   s   @@r   r\   r\   ƒ   s   ù‡ € Ù7÷
÷ 
r   r\   N)r   Únltk.lm.apir   r   Únltk.lm.smoothingr   r   r   r   r   r5   r;   rE   rR   rV   r\   r   r   r   Ú<module>rb      s|   ðñ ç 0ß HÑ Hô7ˆ-ô 7ô Wˆ}ô Wô.-ˆhô -ôG�Mô Gô4F ô Fô46Ð6ô 6ô
Ð&?ô 
ô

Ð5ö 

r   