Class: Ve::Word

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(word, lemma, part_of_speech, tokens, extra = {}, info = {}) ⇒ Word

TODO: More elegance



7
8
9
10
11
12
13
14
15
16
# File 'lib/word.rb', line 7

def initialize(word, lemma, part_of_speech, tokens, extra = {}, info = {})
  @word = word.dup
  @lemma = lemma.dup
  @part_of_speech = part_of_speech
  @tokens = tokens
  
  # TODO: I don't like this, it's too unstructured
  @extra = extra
  @info = info
end

Instance Attribute Details

#extraObject

Returns the value of attribute extra.



4
5
6
# File 'lib/word.rb', line 4

def extra
  @extra
end

#infoObject

Returns the value of attribute info.



4
5
6
# File 'lib/word.rb', line 4

def info
  @info
end

#lemmaObject

Returns the value of attribute lemma.



4
5
6
# File 'lib/word.rb', line 4

def lemma
  @lemma
end

#part_of_speechObject

Returns the value of attribute part_of_speech.



4
5
6
# File 'lib/word.rb', line 4

def part_of_speech
  @part_of_speech
end

#tokensObject

Returns the value of attribute tokens.



4
5
6
# File 'lib/word.rb', line 4

def tokens
  @tokens
end

#wordObject

Returns the value of attribute word.



4
5
6
# File 'lib/word.rb', line 4

def word
  @word
end

Instance Method Details

#as_jsonObject



30
31
32
33
34
35
36
37
38
39
40
# File 'lib/word.rb', line 30

def as_json
  {
    :_class => 'Word',
    :word => @word,
    :lemma => @lemma,
    :part_of_speech => @part_of_speech.name,
    :tokens => @tokens,
    :extra => @extra,
    :info => @info
  }
end

#base_formObject



22
23
24
# File 'lib/word.rb', line 22

def base_form
  @lemma
end

#inflected?Boolean

Returns:

  • (Boolean)


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

def inflected?
  @word != @lemma
end

#main_partObject

TODO: the main part of a word, for example 重要 in 重要な



19
20
# File 'lib/word.rb', line 19

def main_part
end