+
   !͵c                   s    R t ^ RIHt ^ RIt^ RItRR R lltRR R lltRR R	 lltRR
 R lltR R lt	R R lt
 ! R R4      t]! 4       tRtR R lt]R8X  d
   ]! 4        R# R# )uG  
This module is used to get synonyms, hypernyms, and hyponyms from NLTK.

If nltk cannot be imported, it raises “ImportError”,
if the wordnet corpus is not installed it raises “LookupError”.

If “LookupError" is raised because the corpus is mising, install
it using:

    python3
    import nltk
    nltk.download()

)ListNTc                R    V ^8  d   QhR\         R\        R\        \         ,          /#    wordkeep_originalreturnZstrZboolr    format   "1/usr/share/ibus-typing-booster/engine/itb_nltk.py__annotate__r   '   s%      3 t tCy     c                sH   \        \        P                  P                  P	                  V 4       UUu0 uF,  pVP                  4        F  pVP                  RR4      kK  	  K.  	  upp4      pW9   d   VP                  V 4       V'       d   V .V,           pVR,          # u uppi )a  List synonyms for word

:param word: The word for which synonyms should be looked up
:param keep_original: Whether the original word should be in
                      the result as well. If the original word
                      is kept in the results, it is put first
                      in the list.

Examples:

>>> synonyms('fedora')
['fedora', 'Stetson', 'felt hat', 'homburg', 'trilby']

>>> synonyms('fedora', keep_original = False)
['Stetson', 'felt hat', 'homburg', 'trilby']
_ NNN)sortednltkcorpuswordnetsynsetsZlemma_namesreplaceremove)r   r   synsetZ
lemma_nameresults   &&   r   synonymsr   '   s    " &*kk&9&9&A&A$&G@&GF*0*<*<*>J  ''S1*> 2&G@ AF ~d&!9@s   2B
c                r   r   r   r   r
   r   r   r   A   s%      3 t tCy r   c                   \        \        P                  P                  P	                  V 4       UUUu0 uFQ  pVP                  4        F:  pVP                  4        F#  pVP                  4       P                  RR4      kK%  	  K<  	  KS  	  uppp4      pW9   d   VP                  V 4       V'       d   V .V,           pVR,          # u upppi )a  List hyponyms for word

:param word: The word for which hyponyms should be looked up
:param keep_original: Whether the original word should be in
                      the result as well. If the original word
                      is kept in the results, it is put first
                      in the list.

Examples:

>>> hyponyms('hat')
['hat', 'Panama', 'Panama hat', 'Stetson', 'bearskin', 'beaver', 'boater', 'bonnet', 'bowler', 'bowler hat', 'busby', 'campaign hat', 'cavalier hat', 'cocked hat', 'cowboy hat', 'deerstalker', 'derby', 'derby hat', 'dress hat', 'dunce cap', "dunce's cap", 'fedora', 'felt hat', "fool's cap", 'fur hat', 'high hat', 'homburg', 'leghorn', 'millinery', 'opera hat', 'plug hat', 'poke bonnet', 'sailor', 'shako', 'shovel hat', 'silk hat', 'skimmer', 'slouch hat', 'snap-brim hat', 'sombrero', "sou'wester", 'stovepipe', 'straw hat', 'sun hat', 'sunhat', 'ten-gallon hat', 'tirolean', 'titfer', 'top hat', 'topper', 'toque', 'trilby', 'tyrolean', "woman's hat"]

>>> hyponyms('hat', keep_original = False)
['Panama', 'Panama hat', 'Stetson', 'bearskin', 'beaver', 'boater', 'bonnet', 'bowler', 'bowler hat', 'busby', 'campaign hat', 'cavalier hat', 'cocked hat', 'cowboy hat', 'deerstalker', 'derby', 'derby hat', 'dress hat', 'dunce cap', "dunce's cap", 'fedora', 'felt hat', "fool's cap", 'fur hat', 'high hat', 'homburg', 'leghorn', 'millinery', 'opera hat', 'plug hat', 'poke bonnet', 'sailor', 'shako', 'shovel hat', 'silk hat', 'skimmer', 'slouch hat', 'snap-brim hat', 'sombrero', "sou'wester", 'stovepipe', 'straw hat', 'sun hat', 'sunhat', 'ten-gallon hat', 'tirolean', 'titfer', 'top hat', 'topper', 'toque', 'trilby', 'tyrolean', "woman's hat"]
r   r   r   )
r   r   r   r   r   hyponymslemmasnamer   r   )r   r   r   Zhyponymlemmar      &&    r   r   r   A   s    & &*kk&9&9&A&A$&G7&GF'-'8G%,^^%5E ZZ\))#s3 &6 4'8 4&G7 8F ~d&!97   ACc                r   r   r   r   r
   r   r   r   ^   s%      C  S	 r   c                r   )a  List hypernyms for word

:param word: The word for which hyperyms should be looked up
:param keep_original: Whether the original word should be in
                      the result as well. If the original word
                      is kept in the results, it is put first
                      in the list.

Examples:

>>> hypernyms('fedora')
['fedora', 'chapeau', 'hat', 'lid']

>>> hypernyms('fedora', keep_original = False)
['chapeau', 'hat', 'lid']
r   r   r   )
r   r   r   r   r   	hypernymsr   r   r   r   )r   r   r   Zhypernymr   r   r    r   r"   r"   ^   s    " &*kk&9&9&A&A$&G8&GF(.(8(8(:H%-__%6E ZZ\))#s3 &7 4(: 4&G8 9F ~d&!98r!   c                r   r   r   r   r
   r   r   r   y   s%      # d d3i r   c                s    \        V RR7      \        V RR7      ,           \        V RR7      ,           pW9   d   VP                  V 4       V'       d   V .V,           pVR,          # )a  List all related words (synonyms, hypernyms, and hyponyms)

:param word: The word for which related words should be looked up
:param keep_original: Whether the original word should be in
                      the result as well. If the original word
                      is kept in the results, it is put first
                      in the list.

Examples:

>>> related('fedora')
['fedora', 'Stetson', 'felt hat', 'homburg', 'trilby', 'chapeau', 'hat', 'lid']
F)r   r   )r   r"   r   r   )r   r   r   s   && r   relatedr#   y   s\    " 	U+
D
.	/
4u
-	. 
 ~d&!9r   c                    V ^8  d   QhRR/# r   r   N r   r
   r   r   r      s     # #t #r   c            
     s    \         P                  P                  P                  R4       R#   \        3 d1   p \        T P                  P                   RT  24       \        T hRp ? i\         dO   p \        RT P                  P                   RT  R\        P                  ! 4       ^ ,           24       \        T hRp ? ii ; i)zaInit this module

Try to load the wordnet corpus here to make sure this module is
really usable.
Zcarz: NzUnexpected error: r   )r   r   r   r   ZLookupErrorZprintZ	__class____name__Z	ExceptionsysZexc_info)Zerrors    r   _initr)      s    ###E*> %))*"UG45u$ #"5??#;#;"<BugQ"#% 	&U"#s'   )- C +A$$C 1C 2A	B;;C c                r$   r%   r&   r   r
   r   r   r      s      d r   c                 s    R# )zCleanup, nothing to do hereNr&   r&   r   r   _delr*      s    
r   c                   sD   a  ] tR t^t o V 3R lR ltV 3R lR ltRtV tR# )__ModuleInitializerc                   < V ^8  d   QhRR/# r%   r&   r	   __classdict__   "r   r    __ModuleInitializer.__annotate__   s      $ r   c                s    \        4        R # N)r)   Zself   &r   __init__Z__ModuleInitializer.__init__   s    r   c                r,   r%   r&   r-   r/   r   r   r0      s       r   c                s    R # r1   r&   r2   r3   r   __del__Z__ModuleInitializer.__del__   s    r   r&   N)r'   Z
__module__Z__qualname__Z__firstlineno__r4   r5   Z__static_attributes__Z__classdictcell__)r.   s   @r   r+   r+      s       r   r+   c                r$   r%   r&   r   r
   r   r   r      s      d r   c                 s   \         '       d)   ^ RIp ^ RIpV P                  4       pVP	                  4        ^ RIp\        4        VP                  4       w  rE\         '       dg   XP                  4        XP                  V4      pVP                  4        VP                  R4       VP                  R^4       VP                  R^4       \        P                  ! V4       R# )uh   
Used for testing and profiling.

“python3 itb_nltk.py”

runs some tests and prints profiling data.
NZ
cumulativer   r   )	BENCHMARKcProfilepstatsZProfileZenabledoctestr)   ZtestmodZdisableZStatsZ
strip_dirsZ
sort_statsZprint_statsr(   Zexit)r7   r8   Zprofiler9   ZfailedZ
_attemptedZstatss          r   mainr:      s     y""$	G"??,VyW%&&"%)R(HHVr   Z__main__)T)Z__doc__Ztypingr    r(   r   r   r   r"   r#   r)   r*   r+   Z__module_initr6   r:   r'   r&   r   r   <module>r;      se   (  
 4:66#   $%	8 zF r   