Class: WordAligner::Aligner
- Inherits:
-
Object
- Object
- WordAligner::Aligner
- Defined in:
- lib/word_aligner/aligner.rb
Constant Summary collapse
- INSERTION =
1- DELETION =
2- MATCHING =
3- SUBSTITUTE =
4
Instance Attribute Summary collapse
-
#align_cost ⇒ Object
Returns the value of attribute align_cost.
-
#align_matrix ⇒ Object
readonly
Returns the value of attribute align_matrix.
-
#aligned_hypothesis ⇒ Object
Returns the value of attribute aligned_hypothesis.
-
#aligned_transcription ⇒ Object
Returns the value of attribute aligned_transcription.
-
#backtrace_matrix ⇒ Object
readonly
Returns the value of attribute backtrace_matrix.
-
#deletions ⇒ Object
Returns the value of attribute deletions.
-
#hypothese_tokens ⇒ Object
readonly
Returns the value of attribute hypothese_tokens.
-
#hypothesis ⇒ Object
readonly
Returns the value of attribute hypothesis.
-
#insertions ⇒ Object
Returns the value of attribute insertions.
-
#matching ⇒ Object
Returns the value of attribute matching.
-
#reference_tokens ⇒ Object
readonly
Returns the value of attribute reference_tokens.
-
#substitutions ⇒ Object
Returns the value of attribute substitutions.
-
#transcription ⇒ Object
readonly
Returns the value of attribute transcription.
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(transcription, hypothesis) ⇒ Aligner
constructor
A new instance of Aligner.
- #word_error_rate ⇒ Object
Constructor Details
#initialize(transcription, hypothesis) ⇒ Aligner
Returns a new instance of Aligner.
19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/word_aligner/aligner.rb', line 19 def initialize(transcription, hypothesis) @transcription = transcription @hypothesis = hypothesis @insertions = 0 @substitutions = 0 @deletions = 0 @matching = 0 @reference_tokens = tokenize(transcription) @hypothese_tokens = tokenize(hypothesis) end |
Instance Attribute Details
#align_cost ⇒ Object
Returns the value of attribute align_cost.
11 12 13 |
# File 'lib/word_aligner/aligner.rb', line 11 def align_cost @align_cost end |
#align_matrix ⇒ Object (readonly)
Returns the value of attribute align_matrix.
17 18 19 |
# File 'lib/word_aligner/aligner.rb', line 17 def align_matrix @align_matrix end |
#aligned_hypothesis ⇒ Object
Returns the value of attribute aligned_hypothesis.
12 13 14 |
# File 'lib/word_aligner/aligner.rb', line 12 def aligned_hypothesis @aligned_hypothesis end |
#aligned_transcription ⇒ Object
Returns the value of attribute aligned_transcription.
12 13 14 |
# File 'lib/word_aligner/aligner.rb', line 12 def aligned_transcription @aligned_transcription end |
#backtrace_matrix ⇒ Object (readonly)
Returns the value of attribute backtrace_matrix.
17 18 19 |
# File 'lib/word_aligner/aligner.rb', line 17 def backtrace_matrix @backtrace_matrix end |
#deletions ⇒ Object
Returns the value of attribute deletions.
11 12 13 |
# File 'lib/word_aligner/aligner.rb', line 11 def deletions @deletions end |
#hypothese_tokens ⇒ Object (readonly)
Returns the value of attribute hypothese_tokens.
15 16 17 |
# File 'lib/word_aligner/aligner.rb', line 15 def hypothese_tokens @hypothese_tokens end |
#hypothesis ⇒ Object (readonly)
Returns the value of attribute hypothesis.
14 15 16 |
# File 'lib/word_aligner/aligner.rb', line 14 def hypothesis @hypothesis end |
#insertions ⇒ Object
Returns the value of attribute insertions.
11 12 13 |
# File 'lib/word_aligner/aligner.rb', line 11 def insertions @insertions end |
#matching ⇒ Object
Returns the value of attribute matching.
11 12 13 |
# File 'lib/word_aligner/aligner.rb', line 11 def matching @matching end |
#reference_tokens ⇒ Object (readonly)
Returns the value of attribute reference_tokens.
15 16 17 |
# File 'lib/word_aligner/aligner.rb', line 15 def reference_tokens @reference_tokens end |
#substitutions ⇒ Object
Returns the value of attribute substitutions.
11 12 13 |
# File 'lib/word_aligner/aligner.rb', line 11 def substitutions @substitutions end |
#transcription ⇒ Object (readonly)
Returns the value of attribute transcription.
14 15 16 |
# File 'lib/word_aligner/aligner.rb', line 14 def transcription @transcription end |
Class Method Details
.align(original, hypothesis) ⇒ Object
38 39 40 |
# File 'lib/word_aligner/aligner.rb', line 38 def self.align(original, hypothesis) new(original, hypothesis).result end |
Instance Method Details
#word_error_rate ⇒ Object
32 33 34 35 36 |
# File 'lib/word_aligner/aligner.rb', line 32 def word_error_rate align_sentences if align_matrix.nil? WordErrorRate.new(result) end |