'Iterate over all synsets with a given part of speech tag.
If no pos is specified, all synsets for all parts of speech
will be loaded.'

def all_synsets(self, pos=None):

    if (pos is None):
        pos_tags = self._FILEMAP.keys()
    else:
        pos_tags = [pos]
    cache = self._synset_offset_cache
    from_pos_and_line = self._synset_from_pos_and_line
    for pos_tag in pos_tags:
        if (pos_tag == ADJ_SAT):
            pos_tag = ADJ
        fileid = (u'data.%s' % self._FILEMAP[pos_tag])
        data_file = self.open(fileid)
        try:
            offset = data_file.tell()
            line = data_file.readline()
            while line:
                if (not line[0].isspace()):
                    if (offset in cache[pos_tag]):
                        synset = cache[pos_tag][offset]
                    else:
                        synset = from_pos_and_line(pos_tag, line)
                        cache[pos_tag][offset] = synset
                    if (synset._pos == ADJ_SAT):
                        (yield synset)
                    else:
                        (yield synset)
                offset = data_file.tell()
                line = data_file.readline()
        except:
            data_file.close()
            raise
        else:
            data_file.close()
