+
     h#  c                   sB    R t ^ RIt^ RIt ! R R4      t ! R R4      tR# )aC  

pypwl:  pure-python personal word list in the style of Enchant
==============================================================

This module provides a pure-python version of the personal word list
functionality found in the spellchecking package Enchant.  While the
same effect can be achieved (with better performance) using the python
bindings for Enchant, it requires a C extension.

This pure-python implementation uses the same algorithm but without any
external dependencies or C code (in fact, it was the author's original
prototype for the C version found in Enchant).

Nc                   sf   a  ] tR t^3t o RtRR ltR tR tRR ltR.]n	        R t
R tR	 tR
tV tR# )TriezClass implementing a trie-based dictionary of words.

A Trie is a recursive data structure storing words by their prefix.
"Fuzzy matching" can be done by allowing a certain number of missteps
when traversing the Trie.
c                sV    R V n         / V n        V F  pV P                  V4       K  	  R# )FN)_eos_keysinsert)selfZwordsw   && 2/usr/lib/python3.14/site-packages/enchant/pypwl.py__init__ZTrie.__init__;   s%    	
AKKN     c                s    VR 8X  d
   RV n         R# V^ ,          p W,          pVP                  VR,          4       R#   \         d    \        4       pY0T&    L5i ; i) Ti   NNN)r   KeyErrorr    r   r   wordkeysubtrie   &&  r   r   ZTrie.insertA   sV    2:DIq'C$) NN48$  $&#S	$s   = AAc                s    VR 8X  d
   RV n         R# V^ ,          p W,          pVP                  VR,          4       R#   \         d     R# i ; i)r
   Fr   N)r   remover   r   r   r   r   ZTrie.removeM   sK    2:DIq'C)) tBx(  s   = AAc                s   . pV^ 8  d   V# V^ 8X  d+   VR8X  d$   V P                   '       d   VP                  R4        W^ ,          ,          pVP                  VR,          V4      pV F,  pV^ ,          V,           pWs9  g   K  VP                  V4       K.  	   V P                  VR,          V^,
          4      pV F  pWc9  g   K  VP                  V4       K  	   V P
                   FK  pW,          P                  W^,
          4      pV F$  pW,           pWs9  g   K  VP                  V4       K&  	  KM  	   V P
                   FS  pW,          P                  VR,          V^,
          4      pV F$  pW,           pWs9  g   K  VP                  V4       K&  	  KU  	  V#   \        \        3 d     ELi ; i  \        3 d     Li ; i  \        \        3 d     Li ; i  \        \        3 d     T# i ; i)zSearch for the given word, possibly making errors.

This method searches the trie for the given <word>, making
precisely <nerrs> errors.  It returns a list of words found.
r
   r   )r   appendsearchZ
IndexErrorr   r   )	r   r   nerrsresr   Zsubresr   w2ks	   &&&      r   r   ZTrie.searchY   s    19JA:$"*yyy

2	7mG^^DHe4F!Wq[=JJrN 	[[b5195F<JJqM 	ZZai8AB}

2    	ZZR%!)<AB}

2     
? H% 		 } 		 H% 		 H% 	
	sa   A F F (F5 F5 =G G 8AG G F21F25GGGGG32G3r   c                s(    V P                   V,          # Nr   )r   r      &&r   __getitem__ZTrie.__getitem__   s    zz#r	   c                s"    W P                   V&   R # r   r   )r   r   Zval   &&&r   __setitem__ZTrie.__setitem__   s    

3r	   c              #  s   "   V P                   '       d   R x  V P                   F'  pV P                  V,           F  pW,           x  K  	  K)  	  R# 5i)r
   Nr   r   )r   r   r   s   &  r   __iter__ZTrie.__iter__   s<     999HAjjmmf $ s   AAr   N) )i    )__name__
__module____qualname____firstlineno____doc__r   r   r   r   _DOC_ERRORSr   r   r    __static_attributes____classdictcell__Z__classdict__   @r   r    r    3   s?     
%
)5n "F r	   r    c                   s   a  ] tR t^t o RtRR ltR tR tR tR t	R t
R	 tR
 tRR.]n        R tR tR tR tRtV tR# )PyPWLzPure-python implementation of Personal Word List dictionary.
This class emulates the PWL objects provided by PyEnchant, but
implemented purely in python.
Nc                sN   RV n         \        4       V n        Ve}   \        P                  P                  V4      V n        V P                  V n        \        V4      pV F$  pVP                  4       pV P                  V4       K&  	  VP                  4        R# RV n        RV n        R# )a)  PyPWL constructor.
This method takes as its only argument the name of a file
containing the personal word list, one word per line.  Entries
will be read from this file, and new entries will be written to
it automatically.

If <pwl> is not specified or None, the list is maintained in
memory only.
Nr,   )providerr    _wordsosZpathZabspathpwltagopenstripadd_to_sessionclose)r   r0   pwl_fZlnr   s   &&   r   r   ZPyPWL.__init__   s}     f?wws+DHxxDHIExxz##D)  KKMDHDHr	   c                sN    V P                   P                  V4      p\        V4      # )zCheck spelling of a word.

This method takes a word in the dictionary language and returns
True if it is correctly spelled, and false otherwise.
)r.   r   Zbool)r   r   r   r   r   checkZPyPWL.check   s"     kk  &Cyr	   c                s   ^
p^p^ pV P                   P                  W4      p\        V4      V8  dM   WC8  dG   V^,          pV P                   P                  W4       F  pWe9  g   K  VP                  V4       K  	  K\  VRV # )zSuggest possible spellings for a word.

This method tries to guess the correct spelling for a given
word, returning the possibilities in a list.
N)r.   r   Zlenr   )r   r   ZlimitZmaxdepthZdepthr   r   s   &&     r   suggestZPyPWL.suggest   sx     kk  -#h5#3QJE[[''4<JJqM 5 6E{r	   c                s    V P                   eJ   \        V P                   R4      pVP                  VP                  4       : R24       VP	                  4        V P                  V4       R# )^Add a word to the user's personal dictionary.
For a PWL, this means appending it to the file.
NZa
)r0   r2   writer3   r5   r4   )r   r   r6   r   r   addZ	PyPWL.add   sJ     883'EKK$**,01KKMD!r	   c                sb    \         P                  ! R\        ^R7       V P                  V4       R# )r9   z4PyPWL.add_to_pwl is deprecated, please use PyPWL.add)ZcategoryZ
stacklevelN)warningsZwarnZDeprecationWarningr<   r   r   r   r   
add_to_pwlZPyPWL.add_to_pwl   s&     	B'	

 	r	   c                s   V P                   P                  V4       V P                  e_   \        V P                  R4      pV P                    F&  pVP	                  VP                  4       : R24       K(  	  VP                  4        R# R# )z/Add a word to the user's personal exclude list.NZwtr:   )r.   r   r0   r2   r;   r3   r5   )r   r   r6   r   r   r   r   ZPyPWL.remove   sa     	4 884(E[[aggi12 !KKM	  r	   c                s<    V P                   P                  V4       R# )zAdd a word to the session list.N)r.   r   r>   r   r   r4   ZPyPWL.add_to_session   s    4 r	   c                    R# )aC  Store a replacement spelling for a miss-spelled word.

This method makes a suggestion to the spellchecking engine that the
miss-spelled word <mis> is in fact correctly spelled as <cor>.  Such
a suggestion will typically mean that <cor> appears early in the
list of suggested spellings offered for later instances of <mis>.
Nr!   )r   misZcorr   r   store_replacementZPyPWL.store_replacement   s     	r	   rA   c                s$    V P                  V4      # )z2Check whether a word is in the personal word list.)r7   r>   r   r   is_addedZPyPWL.is_added  s    zz$r	   c                r@   )z5Check whether a word is in the personal exclude list.Fr!   r>   r   r   
is_removedZPyPWL.is_removed  s    r	   c                    R # r   r!   )r   Zmsgr   r   _check_thisZPyPWL._check_this      r	   c                rE   r   r!   )r   s   &r   _freeZPyPWL._free  rG   r	   )r.   r-   r0   r1   r   )r"   r#   r$   r%   r&   r   r7   r8   r<   r?   r   r4   rB   r'   rC   rD   rF   rH   r(   r)   r*   r+   r   r,   r,      sZ     
0&"		!	 &+EN!  r	   r,   )r&   r/   r=   r    r,   r!   r	   r   <module>rI      s+   <" 
 j jZy yr	   