1 def dump_wordlist wordlist, stream
2 stream.puts 'Content-Type: text/x-mailvisa-wordlist'
3 stream.puts 'Version: 1'
4 stream.puts 'Messages: ' + wordlist[:messages].to_s
6 wordlist[:words].each { |k,v| stream.puts k + "\t" + v.to_s }
9 def load_wordlist stream
16 key, value = line.split ': '
20 raise 'Invalid file format' if
21 header['Content-Type'] != 'text/x-mailvisa-wordlist'
22 raise 'Unsupported wordlist version: ' + header['Version'] if
23 header['Version'] != '1'
26 :messages => header['Messages'].to_i
31 key, value = line.split "\t"
32 words[key] = value.to_f
35 wordlist[:words] = words