Class: Words::Evocations
- Inherits:
-
Object
- Object
- Words::Evocations
- Defined in:
- lib/evocations.rb
Instance Method Summary collapse
- #[](index) ⇒ Object
- #destination_ids(pos = :all) ⇒ Object
- #destinations(pos = :all) ⇒ Object
- #first ⇒ Object
-
#initialize(evocation_construct, source_synset, wordnet_connection) ⇒ Evocations
constructor
A new instance of Evocations.
- #last ⇒ Object
- #means ⇒ Object
- #medians ⇒ Object
- #size ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(evocation_construct, source_synset, wordnet_connection) ⇒ Evocations
Returns a new instance of Evocations.
10 11 12 13 14 |
# File 'lib/evocations.rb', line 10 def initialize(evocation_construct, source_synset, wordnet_connection) @evocation_construct, @source, @wordnet_connection = evocation_construct, source_synset, wordnet_connection end |
Instance Method Details
#[](index) ⇒ Object
46 47 48 49 50 |
# File 'lib/evocations.rb', line 46 def [] (index) { :destination => Synset.new(destination_ids[index], @wordnet_connection, @source.homographs), :mean => means[index], :median => medians[index] } end |
#destination_ids(pos = :all) ⇒ Object
58 59 60 61 62 63 64 65 66 67 68 69 70 71 |
# File 'lib/evocations.rb', line 58 def destination_ids(pos = :all) @destination_ids ||= @evocation_construct["relations"].split('|') case when Homographs::SYMBOL_TO_POS.include?(pos.to_sym) @destination_ids.select { |synset_id| synset_id[0,1] == Homographs::SYMBOL_TO_POS[pos.to_sym] } when Homographs::POS_TO_SYMBOL.include?(pos.to_s) @destination_ids.select { |synset_id| synset_id[0,1] == pos.to_s } else @destination_ids end end |
#destinations(pos = :all) ⇒ Object
52 53 54 55 56 |
# File 'lib/evocations.rb', line 52 def destinations(pos = :all) destination_ids(pos).map { |synset_id| Synset.new synset_id, @wordnet_connection, @source.homographs } end |
#first ⇒ Object
34 35 36 37 38 |
# File 'lib/evocations.rb', line 34 def first self[0] end |
#last ⇒ Object
40 41 42 43 44 |
# File 'lib/evocations.rb', line 40 def last self[size-1] end |
#means ⇒ Object
16 17 18 19 20 |
# File 'lib/evocations.rb', line 16 def means @means ||= @evocation_construct["means"].split('|') end |
#medians ⇒ Object
22 23 24 25 26 |
# File 'lib/evocations.rb', line 22 def medians @medians ||= @evocation_construct["medians"].split('|') end |
#size ⇒ Object
28 29 30 31 32 |
# File 'lib/evocations.rb', line 28 def size means.size end |
#to_s ⇒ Object
73 74 75 76 77 |
# File 'lib/evocations.rb', line 73 def to_s "#{size} evocations from the #{@source}" end |