Skip to content

Instantly share code, notes, and snippets.

@vestige
Created April 3, 2019 11:22
Show Gist options
  • Save vestige/356ca54461d8d8a39e9d11e3fe2413ca to your computer and use it in GitHub Desktop.
Save vestige/356ca54461d8d8a39e9d11e3fe2413ca to your computer and use it in GitHub Desktop.
dictionary.rb
class Dictionary
def initialize
@random = []
open('dic/ramdom.txt') do |f|
f.each do |line|
line.chomp!
next if line.empty?
@random.push(line)
end
end
@pattern = []
open('dic/pattern.txt') do |f|
f.each do |line|
pattern, phrases = line.chomp.split("¥t")
next if pattern.nil? or phrases.nil?
@pattern.push({'pattern' => pattern, 'phrases' => phrases})
end
end
end
attr_reader :random, :pattern
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment