class RMMSeg::Word
An object representing a CJK word.
Constants
- TYPES
Attributes
frequency[R]
The frequency of the word. This value is meaningful only when this is a one-character word.
text[R]
The content text of the word.
type[R]
The type of the word, may be one of the key of TYPES
.
Public Class Methods
new(text, type=TYPES[:unrecognized], frequency=nil)
click to toggle source
Initialize a Word
object.
# File lib/rmmseg/word.rb, line 21 def initialize(text, type=TYPES[:unrecognized], frequency=nil) @text = text @type = type @frequency = frequency @length = @text.length end
Public Instance Methods
byte_size()
click to toggle source
The number of bytes in the word.
# File lib/rmmseg/word.rb, line 34 def byte_size @text.each_byte.to_a.length end
length()
click to toggle source
The number of characters in the word. Not number of bytes.
# File lib/rmmseg/word.rb, line 29 def length @length end