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

Returns a new instance of Token.



16
17
18
19
20
# File 'lib/rmmseg/token.rb', line 16

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

Instance Attribute Details

#end_posObject (readonly)

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_pos
  @end_pos
end

#start_posObject (readonly)

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_pos
  @start_pos
end

#textObject (readonly)

Text of the token.



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

def text
  @text
end