lib/ssmd/annotations/phoneme_annotation.rb in ssmd-0.6.1 vs lib/ssmd/annotations/phoneme_annotation.rb in ssmd-0.7.0

- old
+ new

@@ -5,15 +5,20 @@ module SSMD::Annotations class PhonemeAnnotation < Annotation attr_reader :x_sampa, :ipa def self.regex - /ph: ?(.+)/ + /((?:ph)|(?:ipa)): ?(.+)/ end - def initialize(x_sampa) - @x_sampa = x_sampa - @ipa = x_sampa_to_ipa x_sampa + def initialize(ph, text) + @x_sampa = text if ph == "ph" + + if ph == "ph" + @ipa = x_sampa_to_ipa x_sampa + elsif ph == "ipa" + @ipa = text + end end def wrap(text) "<phoneme alphabet=\"ipa\" ph=\"#{ipa}\">#{text}</phoneme>" end