Class: Words::Evocations
- Inherits:
-
Object
- Object
- Words::Evocations
- Defined in:
- lib/evocations.rb
Instance Method Summary (collapse)
- - (Object) [](index)
- - (Object) destination_ids(pos = :all)
- - (Object) destinations(pos = :all)
- - (Object) first
-
- (Evocations) initialize(evocation_construct, source_synset, wordnet_connection)
constructor
A new instance of Evocations.
- - (Object) last
- - (Object) means
- - (Object) medians
- - (Object) size
- - (Object) to_s
Constructor Details
- (Evocations) initialize(evocation_construct, source_synset, wordnet_connection)
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
- (Object) [](index)
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 |
- (Object) destination_ids(pos = :all)
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 |
- (Object) destinations(pos = :all)
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 |
- (Object) first
34 35 36 37 38 |
# File 'lib/evocations.rb', line 34 def first self[0] end |
- (Object) last
40 41 42 43 44 |
# File 'lib/evocations.rb', line 40 def last self[size-1] end |
- (Object) means
16 17 18 19 20 |
# File 'lib/evocations.rb', line 16 def means @means ||= @evocation_construct["means"].split('|') end |
- (Object) medians
22 23 24 25 26 |
# File 'lib/evocations.rb', line 22 def medians @medians ||= @evocation_construct["medians"].split('|') end |
- (Object) size
28 29 30 31 32 |
# File 'lib/evocations.rb', line 28 def size means.size end |
- (Object) to_s
73 74 75 76 77 |
# File 'lib/evocations.rb', line 73 def to_s "#{size} evocations from the #{@source}" end |