Sha256: 2c71f6897760093995726c2ab8ac116fe183df9db6272dfdb936e57f7332046e

Contents?: true

Size: 552 Bytes

Versions: 1

Compression:

Stored size: 552 Bytes

Contents

require "yaml"

module Eman
  class Dictionary

    INDICES_FILE = File.expand_path('../dictionary/indices.yml', __FILE__)
    WORDS_FILE = File.expand_path('../dictionary/words.yml', __FILE__)

    def self.find_similar(word)
      index = fetch_index(word)
      fetch_words(index)
    end

    private

      def self.fetch_index(key)
        indices = YAML.load_file(INDICES_FILE)
        indices[key]
      end

      def self.fetch_words(index)
        words_list = YAML.load_file(WORDS_FILE)
        words_list[index] || []
      end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
eman-0.0.3 lib/eman/dictionary.rb