Search code examples
pythonnltkwordnetstemming

How do I Get All Attributes Of Synsets?


Please Give Me am example That have all of attribute of synset of a word i know only this attribute: name , lemma_names , definition

synsetsWord = ObjWn.synsets( 'Book' )
        i = 0 
        for senseWord in synsetsWord:
            synsetsWord[i] = senseWord.name
            print 'Sense Lema Name: ' , senseWord.lemma_names
            print 'Sense Definition : ' , senseWord.definition
            i = i + 1

thanks


Solution

  • Use the dir() built-in function in the interpreter.

    Here is an example:

    Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
    [GCC 4.4.3] on linux2
    Type "help", "copyright", "credits" or "license" for more information.
    >>> import itertools
    >>> help(itertools)
    
    >>> dir(itertools.chain)
    ['__class__', '__delattr__', '__doc__', '__format__', '__getattribute__', '__hash__', '__init__', '__iter__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', 'from_iterable', 'next']
    

    You can supply any object to dir() to get a list of its attributes.