Class: Lumix::Lookup::Document
- Inherits:
-
Object
- Object
- Lumix::Lookup::Document
- Defined in:
- lib/lumix/lookup.rb
Instance Method Summary collapse
- #add_token(text_id, position, word, tag, s_begin, s_end, t_begin, t_end) ⇒ Object
- #flush ⇒ Object
-
#initialize(lookup) ⇒ Document
constructor
A new instance of Document.
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. @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 |
#flush ⇒ Object
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 |