class ExactMatch
Public Class Methods
new()
click to toggle source
Calls superclass method
DataBase::new
# File lib/promper/matching.rb, line 20 def initialize super end
Public Instance Methods
combine_matches_and_phoneme_chunks(final_matches,phoneme_chunks)
click to toggle source
# File lib/promper/matching.rb, line 71 def combine_matches_and_phoneme_chunks(final_matches,phoneme_chunks) final_matches.zip(phoneme_chunks) end
determine_first_letter(node_target_phoneme)
click to toggle source
# File lib/promper/matching.rb, line 24 def determine_first_letter(node_target_phoneme) node_target_phoneme[0] end
determine_remaining_phoneme_chunks(final_matches, node_target_phoneme)
click to toggle source
# File lib/promper/matching.rb, line 64 def determine_remaining_phoneme_chunks(final_matches, node_target_phoneme) chunks = final_matches.map do |phonemes| phoneme_length = phonemes.length this_chunk = node_target_phoneme[phoneme_length..-1] end end
length_okay?(word, node_target_phoneme)
click to toggle source
# File lib/promper/matching.rb, line 50 def length_okay?(word, node_target_phoneme) word.length <= node_target_phoneme.length end
letter_match?(word, node_target_phoneme, index=0)
click to toggle source
# File lib/promper/matching.rb, line 46 def letter_match?(word, node_target_phoneme, index=0) word[index] == node_target_phoneme[index] end
match(node_target_phoneme)
click to toggle source
# File lib/promper/matching.rb, line 32 def match(node_target_phoneme) first_letter = determine_first_letter(node_target_phoneme) relevant_values = pull_relevant_values_from_dict(first_letter) matches = relevant_values.select {|word, phoneme_representation| passes_tests?(word, node_target_phoneme)} phoneme_chunks = determine_remaining_phoneme_chunks(matches, node_target_phoneme) combine_matches_and_phoneme_chunks(matches,phoneme_chunks) end
passes_tests?(word, node_target_phoneme)
click to toggle source
# File lib/promper/matching.rb, line 40 def passes_tests?(word, node_target_phoneme) letter_match?(word, node_target_phoneme) && length_okay?(word, node_target_phoneme) && remaining_letter_match?(word, node_target_phoneme) end
pull_relevant_values_from_dict(key)
click to toggle source
# File lib/promper/matching.rb, line 28 def pull_relevant_values_from_dict(key) db[key] end
remaining_letter_match?(word, node_target_phoneme)
click to toggle source
# File lib/promper/matching.rb, line 54 def remaining_letter_match?(word, node_target_phoneme) word_length = word.length word_length.times do |letter| unless letter_match?(word, node_target_phoneme, index=letter) return false end end true end