Sha256: cfedc8f9499bcb63feba64b52dfef78394a60cdbb30aa9831dbe0f7b2ce30447
Contents?: true
Size: 1001 Bytes
Versions: 2
Compression:
Stored size: 1001 Bytes
Contents
# frozen_string_literal: true class StoryKey::Lexicon < StoryKey::Base def entries @entries ||= StoryKey::GRAMMAR.values.flatten.uniq.index_with do |part_of_speech| import_entries(part_of_speech).sort_by(&:token) end end def prepositions @prepositions ||= entries.values.flatten.filter_map(&:preposition).uniq.sort end def sha @sha ||= Digest::SHA256.hexdigest(entries.to_s).first(StoryKey::LEXICON_SHA_SIZE) end private def import_entries(part_of_speech) [].tap do |ary| StoryKey::Data::ENTRIES[part_of_speech].each do |group, entries| entries.each do |text| ary << new_entry(part_of_speech, text, group == :countable) end end end end def new_entry(part_of_speech, text, countable) StoryKey::Entry.new \ raw: text, text: text.gsub(/\[|\]/, ''), part_of_speech:, token: StoryKey::Tokenizer.call(text), countable:, preposition: text.match(/\[(.+)\]/).to_a[1] end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
story_key-0.3.0 | lib/story_key/lexicon.rb |
story_key-0.2.0 | lib/story_key/lexicon.rb |