Class: Teer::VectorStore

Inherits:
Object
  • Object
show all
Defined in:
lib/teer/vector_store.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data, locale) ⇒ VectorStore

Returns a new instance of VectorStore.



5
6
7
8
# File 'lib/teer/vector_store.rb', line 5

def initialize(data, locale)
  @data = data
  @locale = locale || :GB_en
end

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



44
45
46
# File 'lib/teer/vector_store.rb', line 44

def data
  @data
end

Instance Method Details

#as_json(options = nil) ⇒ Object



46
47
48
# File 'lib/teer/vector_store.rb', line 46

def as_json(options = nil)
  @data.as_json(options)
end

#countObject



18
19
20
# File 'lib/teer/vector_store.rb', line 18

def count
  @data.count
end

#keyObject



10
11
12
# File 'lib/teer/vector_store.rb', line 10

def key
  @data[0]
end

#meanObject



26
27
28
# File 'lib/teer/vector_store.rb', line 26

def mean
  @data.reduce(:+) / @data.count
end

#sumObject



22
23
24
# File 'lib/teer/vector_store.rb', line 22

def sum
  @data.reduce(:+)
end

#to_sObject



30
31
32
33
34
35
36
37
38
39
40
41
42
# File 'lib/teer/vector_store.rb', line 30

def to_s
  length = @data.length
  case length
  when 0
    ''
  when 1
    @data[0]
  else
    sentence = @data.join(', ')
    # should support all languages at some point
    sentence.reverse.sub(' ,', ' dna ').reverse
  end
end

#valueObject



14
15
16
# File 'lib/teer/vector_store.rb', line 14

def value
  @data[1]
end