Module Expr Str ImportFrom alias ImportFrom alias alias alias ImportFrom alias FunctionDef arguments args NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Assign NameStore Call NameLoad NameLoad For NameStore NameLoad body If UnaryOpNot Call AttributeLoad NameLoad attr Str body Continue Assign NameStore SubscriptLoad NameLoad Slice Num Assign NameStore Call NameLoad SubscriptLoad NameLoad Slice Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore SubscriptLoad NameLoad Slice BinOpAdd NameLoad Num Assign NameStore Call AttributeLoad NameLoad attr Str Assign NameStore Call AttributeLoad SubscriptLoad NameLoad Slice NameLoad attr If UnaryOpNot Call AttributeLoad NameLoad attr body Continue Expr Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr NameLoad Expr Call AttributeLoad SubscriptLoad NameLoad Index NameLoad attr NameLoad Return TupleLoad NameLoad NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad keyword NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad keyword NameLoad Assign NameStore Call AttributeLoad NameLoad attr For NameStore Call AttributeLoad NameLoad attr body Assign NameStore Call NameLoad NameLoad NameLoad NameLoad Expr Call AttributeLoad NameLoad attr keyword Call NameLoad NameLoad keyword NameLoad Expr Call AttributeLoad NameLoad attr Return NameLoad decorator_list FunctionDef arguments args NameParam NameParam NameParam defaults body Expr Str Assign NameStore SubscriptLoad NameLoad Index NameLoad Assign NameStore Call NameLoad For NameStore NameLoad body Assign NameStore Call AttributeLoad NameLoad attr SubscriptLoad NameLoad Index NameLoad If CompareIn NameLoad NameLoad body Expr Call AttributeLoad NameLoad attr NameLoad Return Call NameLoad NameLoad decorator_list ClassDef bases NameLoad body Expr Str FunctionDef arguments args NameParam defaults body Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad Assign AttributeStore NameLoad attr NameLoad decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad Assign TupleStore AttributeStore NameLoad attr AttributeStore NameLoad attr Call NameLoad NameLoad Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call NameLoad NameLoad Str TryFinally body Return Call AttributeLoad NameLoad attr NameLoad finalbody Expr Call AttributeLoad NameLoad attr decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults Str body Expr Str Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr keyword NameLoad Assign AttributeStore NameLoad attr Call AttributeLoad NameLoad attr Return NameLoad decorator_list NameLoad FunctionDef arguments args NameParam NameParam NameParam defaults Str body Expr Str If BoolOpOr UnaryOpNot AttributeLoad NameLoad attr UnaryOpNot AttributeLoad NameLoad attr body Raise Call NameLoad Str Expr Call NameLoad NameLoad NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr decorator_list FunctionDef arguments args NameParam NameParam defaults body Expr Str Assign NameStore Call AttributeLoad NameLoad attr If AttributeLoad NameLoad attr body Return SubscriptLoad Call AttributeLoad AttributeLoad NameLoad attr attr keyword NameLoad Index Str orelse Return Call NameLoad AttributeLoad NameLoad attr AttributeLoad NameLoad attr NameLoad decorator_list decorator_list If CompareEq NameLoad Str body ImportFrom alias ImportFrom alias Assign NameStore Call NameLoad Str Assign NameStore Call NameLoad Assign NameStore Call AttributeLoad NameLoad attr NameLoad Print BinOpSub Call NameLoad NameLoad Assign NameStore Call NameLoad Print Call AttributeLoad NameLoad attr Str Print BinOpSub Call NameLoad NameLoad
N/A N/A This module contains low-level functions and a high-level class for parsing
the prolog file "wn_s.pl" from the WordNet prolog download
into an object suitable for looking up synonyms and performing query expansion.

http://wordnetcode.princeton.edu/3.0/WNprolog-3.0.tar.gz
 collections defaultdict whoosh.fields Schema ID STORED whoosh.index Index parse_file N/A N/A f N/A N/A N/A Parses the WordNet wn_s.pl prolog file and returns two dictionaries:
    word2nums and num2words.
     N/A word2nums N/A defaultdict list N/A num2words N/A defaultdict list N/A line f N/A N/A N/A N/A N/A line startswith s( N/A N/A N/A line N/A line N/A 2 N/A num N/A int N/A line N/A N/A N/A line find , N/A qt N/A N/A line find ' N/A line N/A line N/A N/A qt 1 N/A qt N/A N/A line find ' N/A word N/A N/A N/A line N/A qt lower N/A N/A N/A N/A word isalpha N/A N/A N/A N/A N/A N/A word2nums N/A word append num N/A N/A N/A N/A num2words N/A num append word N/A N/A word2nums num2words N/A make_index N/A N/A storage indexname word2nums num2words N/A N/A N/A Creates a Whoosh index in the given storage object containing
    synonyms taken from word2nums and num2words. Returns the Index
    object.
     N/A schema N/A Schema word ID syns STORED N/A ix N/A N/A storage create_index schema indexname indexname N/A w N/A N/A ix writer N/A word N/A N/A word2nums iterkeys N/A N/A syns N/A synonyms word2nums num2words word N/A N/A N/A w add_document word N/A unicode word syns syns N/A N/A N/A w commit N/A ix N/A synonyms N/A N/A word2nums num2words word N/A N/A N/A Uses the word2nums and num2words dicts to look up synonyms
    for the given word. Returns a list of synonym strings.
     N/A keys N/A word2nums N/A word N/A syns N/A set N/A key keys N/A N/A syns N/A N/A syns union N/A num2words N/A key N/A N/A word syns N/A N/A N/A N/A syns remove word N/A N/A sorted syns N/A Thesaurus N/A object N/A N/A Represents the WordNet synonym database, either loaded into memory
    from the wn_s.pl Prolog file, or stored on disk in a Whoosh index.
    
    This class allows you to parse the prolog file "wn_s.pl" from the WordNet prolog
    download into an object suitable for looking up synonyms and performing query
    expansion.

    http://wordnetcode.princeton.edu/3.0/WNprolog-3.0.tar.gz
    
    To load a Thesaurus object from the wn_s.pl file...
    
    >>> t = Thesaurus.from_filename("wn_s.pl")
    
    To save the in-memory Thesaurus to a Whoosh index...
    
    >>> from whoosh.filedb.filestore import FileStorage
    >>> fs = FileStorage("index")
    >>> t.to_storage(fs)
    
    To load a Thesaurus object from a Whoosh index...
    
    >>> t = Thesaurus.from_storage(fs)
    
    The Thesaurus object is thus usable in two ways:
    
    * Parse the wn_s.pl file into memory (Thesaurus.from_*) and then look up
      synonyms in memory. This has a startup cost for parsing the file, and uses
      quite a bit of memory to store two large dictionaries, however synonym
      look-ups are very fast.
      
    * Parse the wn_s.pl file into memory (Thesaurus.from_filename) then save it to
      an index (to_storage). From then on, open the thesaurus from the saved
      index (Thesaurus.from_storage). This has a large cost for storing the index,
      but after that it is faster to open the Thesaurus (than re-parsing the file)
      but slightly slower to look up synonyms.
    
    Here are timings for various tasks on my (fast) Windows machine, which might
    give an idea of relative costs for in-memory vs. on-disk.
    
    ================================================ ================
    Task                                             Approx. time (s)
    ================================================ ================
    Parsing the wn_s.pl file                         1.045
    Saving to an on-disk index                       13.084
    Loading from an on-disk index                    0.082
    Look up synonyms for "light" (in memory)         0.0011
    Look up synonyms for "light" (loaded from disk)  0.0028
    ================================================ ================
    
    Basically, if you can afford spending the memory necessary to parse the
    Thesaurus and then cache it, it's faster. Otherwise, use an on-disk index.
     __init__ N/A N/A self N/A N/A N/A N/A self w2n None N/A N/A self n2w None N/A N/A self searcher None N/A from_file N/A N/A cls fileobj N/A N/A N/A Creates a Thesaurus object from the given file-like object, which should
        contain the WordNet wn_s.pl file.
        
        >>> f = open("wn_s.pl")
        >>> t = Thesaurus.from_file(f)
        >>> t.synonyms("hail")
        ['acclaim', 'come', 'herald']
         N/A thes N/A cls N/A N/A N/A thes w2n N/A thes n2w N/A parse_file fileobj N/A thes N/A classmethod from_filename N/A N/A cls filename N/A N/A N/A Creates a Thesaurus object from the given filename, which should
        contain the WordNet wn_s.pl file.
        
        >>> t = Thesaurus.from_filename("wn_s.pl")
        >>> t.synonyms("hail")
        ['acclaim', 'come', 'herald']
         N/A f N/A open filename rb N/A N/A N/A N/A N/A cls from_file f N/A N/A N/A N/A f close N/A classmethod from_storage N/A N/A cls storage indexname N/A THES N/A N/A Creates a Thesaurus object from the given storage object,
        which should contain an index created by Thesaurus.to_storage().
        
        >>> from whoosh.filedb.filestore import FileStorage
        >>> fs = FileStorage("index")
        >>> t = Thesaurus.from_storage(fs)
        >>> t.synonyms("hail")
        ['acclaim', 'come', 'herald']
        
        :param storage: A :class:`whoosh.store.Storage` object from
            which to load the index.
        :param indexname: A name for the index. This allows you to
            store multiple indexes in the same storage object.
         N/A thes N/A cls N/A index N/A N/A storage open_index indexname indexname N/A N/A thes searcher N/A N/A index searcher N/A thes N/A classmethod to_storage N/A N/A self storage indexname N/A THES N/A N/A Creates am index in the given storage object from the
        synonyms loaded from a WordNet file.
        
        >>> from whoosh.filedb.filestore import FileStorage
        >>> fs = FileStorage("index")
        >>> t = Thesaurus.from_filename("wn_s.pl")
        >>> t.to_storage(fs)
        
        :param storage: A :class:`whoosh.store.Storage` object in
            which to save the index.
        :param indexname: A name for the index. This allows you to
            store multiple indexes in the same storage object.
         N/A N/A N/A N/A self w2n N/A N/A self n2w N/A N/A N/A Exception No synonyms loaded N/A N/A make_index storage indexname N/A self w2n N/A self n2w N/A synonyms N/A N/A self word N/A N/A N/A Returns a list of synonyms for the given word.
        
        >>> thesaurus.synonyms("hail")
        ['acclaim', 'come', 'herald']
         N/A word N/A N/A word lower N/A N/A self searcher N/A N/A N/A N/A N/A N/A self searcher document word word N/A syns N/A N/A N/A synonyms N/A self w2n N/A self n2w word N/A N/A N/A N/A __name__ __main__ N/A time clock whoosh.filedb.filestore FileStorage N/A st N/A FileStorage c:/testindex N/A t N/A clock N/A th N/A N/A Thesaurus from_storage st N/A N/A N/A clock t N/A t N/A clock N/A N/A N/A th synonyms hail N/A N/A N/A clock t