# File lib/wordnet/lexicon.rb, line 249 def storeSynset( synset ) strippedOffset = nil pos = nil # Start a transaction @env.begin( BDB::TXN_COMMIT, @dataDb ) do |txn,datadb| # If this is a new synset, generate an offset for it if synset.offset == 1 synset.offset = (datadb['offsetcount'] = datadb['offsetcount'].to_i + 1) end # Write the data entry datadb[ synset.key ] = synset.serialize # Write the index entries txn.begin( BDB::TXN_COMMIT, @indexDb ) do |txn,indexdb| # Make word/part-of-speech pairs from the words in the synset synset.words.collect {|word| word + "%" + pos }.each {|word| # If the index already has this word, but not this # synset, add it if indexdb.key?( word ) indexdb[ word ] << SubDelim << synset.offset unless indexdb[ word ].include?( synset.offset ) else indexdb[ word ] = synset.offset end } end # transaction on @indexDb end # transaction on @dataDB return synset.offset end