# File lib/wordnet/lexicon.rb, line 289 def removeSynset( synset ) # If it's not in the database (ie., doesn't have a real offset), # just return. return nil if synset.offset == 1 # Start a transaction on the data table @env.begin( BDB::TXN_COMMIT, @dataDb ) do |txn,datadb| # First remove the index entries for this synset by iterating # over each of its words txn.begin( BDB::TXN_COMMIT, @indexDb ) do |txn,indexdb| synset.words.collect {|word| word + "%" + pos }.each {|word| # If the index contains an entry for this word, either # splice out the offset for the synset being deleted if # there are more than one, or just delete the whole # entry if it's the only one. if indexdb.key?( word ) offsets = indexdb[ word ]. split( SubDelimRe ). reject {|offset| offset == synset.offset} unless offsets.empty? indexDb[ word ] = newoffsets.join( SubDelim ) else indexDb.delete( word ) end end } end # :TODO: Delete synset from pointers of related synsets # Delete the synset from the main db datadb.delete( synset.offset ) end return true end