Class: RMMSeg::Token

Inherits:
Object
  • Object
show all
Defined in:
lib/rmmseg/token.rb

Overview

A Token consists of a term’s text and the start and end offset of the term.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(text, start_pos, end_pos) ⇒ Token

text is the ref to the whole text. In other words: text[start_pos...end_pos] should be the string held by this token.



20
21
22
23
24
# File 'lib/rmmseg/token.rb', line 20

def initialize(text, start_pos, end_pos)
  @text  = text
  @start = start_pos
  @end   = end_pos
end

Instance Attribute Details

#endObject

The one greater than the position of the last byte of the token. This is byte index instead of character.



15
16
17
# File 'lib/rmmseg/token.rb', line 15

def end
  @end
end

#startObject

The start position of the token. This is byte index instead of character.



11
12
13
# File 'lib/rmmseg/token.rb', line 11

def start
  @start
end

#textObject

The text of the token



7
8
9
# File 'lib/rmmseg/token.rb', line 7

def text
  @text
end

Instance Method Details

#to_sObject



26
27
28
# File 'lib/rmmseg/token.rb', line 26

def to_s
  @text.dup
end