class TwitterKorean::KoreanToken

Attributes

metadata[RW]

Public Class Methods

build_by_formed_str(str) click to toggle source

by form like `한국어(Noun: 0, 3)`

# File lib/twitter_korean/korean_token.rb, line 7
def build_by_formed_str(str)
  token = new(str[0...str.rindex('(')])

  infos = str[(str.rindex('(') + 1)...str.rindex(')')]
  attrs = {
    pos: infos.match(/\w+/).to_s,
    offset: infos.match(/\d+/).to_s.to_i,
    length: infos.match(/\d+$/).to_s.to_i
  }

  token.metadata = TwitterKorean::KoreanToken::Metadata.new(attrs)
  token
end