Class: LLT::Review::Treebank::Word

Inherits:
Object
  • Object
show all
Includes:
Core::Structures::HashContainable
Defined in:
lib/llt/review/treebank/word.rb

Defined Under Namespace

Classes: Attr

Constant Summary collapse

COMPARABLE_ELEMENTS =
%i{ lemma postag head relation }

Instance Attribute Summary collapse

Instance Method Summary collapse

Dynamic Method Handling

This class handles dynamic methods through the method_missing method

#method_missing(meth, *args, &blk) ⇒ Object (private)

used when parsers try to check in attributes we are not interested in



52
53
54
# File 'lib/llt/review/treebank/word.rb', line 52

def method_missing(meth, *args, &blk)
  super unless meth =~ /=$/
end

Instance Attribute Details

#formObject

Returns the value of attribute form.



6
7
8
# File 'lib/llt/review/treebank/word.rb', line 6

def form
  @form
end

#headObject

Returns the value of attribute head.



6
7
8
# File 'lib/llt/review/treebank/word.rb', line 6

def head
  @head
end

#inexistantObject

Returns the value of attribute inexistant.



6
7
8
# File 'lib/llt/review/treebank/word.rb', line 6

def inexistant
  @inexistant
end

#lemmaObject

Returns the value of attribute lemma.



6
7
8
# File 'lib/llt/review/treebank/word.rb', line 6

def lemma
  @lemma
end

#postagObject

Returns the value of attribute postag.



7
8
9
# File 'lib/llt/review/treebank/word.rb', line 7

def postag
  @postag
end

#relationObject

Returns the value of attribute relation.



6
7
8
# File 'lib/llt/review/treebank/word.rb', line 6

def relation
  @relation
end

Instance Method Details

#[](key) ⇒ Object



23
24
25
# File 'lib/llt/review/treebank/word.rb', line 23

def [](key)
  super(key) || send("#{key}=", '-')
end

#compare(other, diff_container, comparables) ⇒ Object



33
34
35
36
37
38
39
40
41
42
# File 'lib/llt/review/treebank/word.rb', line 33

def compare(other, diff_container, comparables)
  comparables = COMPARABLE_ELEMENTS unless comparables # default value
  comparables.each do |comparator|
    a, b = [self, other].map { |w| w[comparator].to_s }
    if a != b
      d = diff_container[id] ||= Difference::Word.new(self)
      d.add(new_difference(comparator, a, b))
    end
  end
end