Class: RMMSeg::Token
- Inherits:
-
Object
- Object
- RMMSeg::Token
- 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
-
#end ⇒ Object
The one greater than the position of the last byte of the token.
-
#start ⇒ Object
The start position of the token.
-
#text ⇒ Object
The text of the token.
Instance Method Summary collapse
-
#initialize(text, start_pos, end_pos) ⇒ Token
constructor
text
is the ref to the whole text. - #to_s ⇒ Object
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.
19 20 21 22 23 |
# File 'lib/rmmseg/token.rb', line 19 def initialize(text, start_pos, end_pos) @text = text @start = start_pos @end = end_pos end |
Instance Attribute Details
#end ⇒ Object
The one greater than the position of the last byte of the token. This is byte index instead of character.
14 15 16 |
# File 'lib/rmmseg/token.rb', line 14 def end @end end |
#start ⇒ Object
The start position of the token. This is byte index instead of character.
10 11 12 |
# File 'lib/rmmseg/token.rb', line 10 def start @start end |
#text ⇒ Object
The text of the token
6 7 8 |
# File 'lib/rmmseg/token.rb', line 6 def text @text end |
Instance Method Details
#to_s ⇒ Object
25 26 27 |
# File 'lib/rmmseg/token.rb', line 25 def to_s @text.dup end |