Class: LLT::Review::Alignment::Word

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Instance Attribute Details

#textObject

Returns the value of attribute text.



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

def text
  @text
end

Instance Method Details

#compare(other, diff_container) ⇒ Object

star is for additional params other classes like Treebank need



21
22
23
24
25
26
27
# File 'lib/llt/review/alignment/word.rb', line 21

def compare(other, diff_container, *)
  unless translation == other.translation
    d = diff_container[id] ||= Difference::Word.new(self)
    d.add(Difference::Translation.new(translation, other.translation))
    d.add(Difference::Nrefs.new(nrefs, other.nrefs))
  end
end

#nrefsObject



16
17
18
# File 'lib/llt/review/alignment/word.rb', line 16

def nrefs
  @container.keys.map(&:to_s).join(' ')
end

#reportObject



29
30
31
32
33
34
35
# File 'lib/llt/review/alignment/word.rb', line 29

def report
  @report ||= begin
    rep = Report::Word.new(@text)
    rep.add(Report::Translation.new(translation))
    rep
  end
end

#to_sObject



8
9
10
# File 'lib/llt/review/alignment/word.rb', line 8

def to_s
  @text
end

#translationObject



12
13
14
# File 'lib/llt/review/alignment/word.rb', line 12

def translation
  @translation ||= @container.values.map(&:to_s).join(' ')
end