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.



3
4
5
6
# File 'lib/teer/vector_store.rb', line 3

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

Instance Attribute Details

#dataObject (readonly)

Returns the value of attribute data.



42
43
44
# File 'lib/teer/vector_store.rb', line 42

def data
  @data
end

Instance Method Details

#as_json(options = nil) ⇒ Object



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

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

#countObject



16
17
18
# File 'lib/teer/vector_store.rb', line 16

def count
  @data.count
end

#keyObject



8
9
10
# File 'lib/teer/vector_store.rb', line 8

def key
  @data[0]
end

#meanObject



24
25
26
# File 'lib/teer/vector_store.rb', line 24

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

#sumObject



20
21
22
# File 'lib/teer/vector_store.rb', line 20

def sum
  @data.reduce(:+)
end

#to_sObject



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

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



12
13
14
# File 'lib/teer/vector_store.rb', line 12

def value
  @data[1]
end