Class: Lumix::Lookup::Document

Inherits:
Object
  • Object
show all
Defined in:
lib/lumix/lookup.rb

Instance Method Summary collapse

Constructor Details

#initialize(lookup) ⇒ Document

Returns a new instance of Document.



5
6
7
8
9
10
# File 'lib/lumix/lookup.rb', line 5

def initialize(lookup)
  @tokens_ds = lookup.tokens
  @words = lookup.words
  @tags = lookup.tags
  @tokens = []
end

Instance Method Details

#add_token(text_id, position, word, tag, s_begin, s_end, t_begin, t_end) ⇒ Object



12
13
14
15
# File 'lib/lumix/lookup.rb', line 12

def add_token(text_id, position, word, tag, s_begin, s_end, t_begin, t_end)
  @tokens << {:text_id => text_id, :position => position, :word_id => @words[word], :tag_id => @tags[tag],
    :src_begin => s_begin, :src_end => s_end, :tagged_begin => t_begin, :tagged_end => t_end}
end

#flushObject



17
18
19
20
# File 'lib/lumix/lookup.rb', line 17

def flush
  tokens, @tokens = @tokens, [] # make sure no double-flush occurs
  @tokens_ds.multi_insert tokens
end