Class: CodyRobbins::Syllabify

Inherits:
Object
  • Object
show all
Defined in:
lib/cody_robbins/syllabify.rb,
lib/cody_robbins/syllabify/syllable.rb

Defined Under Namespace

Classes: Syllable

Instance Method Summary collapse

Constructor Details

#initialize(language, transcription) ⇒ Syllabify

Create a new syllabified representation of an IPA transcription.

Examples:

transcription = CodyRobbins::Syllabify.new(:en, 'dɪˌsɔrgənəˈze͡ɪʃən')

transcription.to_s      #=> 'dɪ.ˌsɔr.gə.nə.ˈze͡ɪ.ʃən'
transcription.syllables #=> [dɪ, ˌsɔr, gə, nə, ˈze͡ɪ, ʃən]

Parameters:

  • language (Symbol, String)

    The ISO 639 code of the language represented in the transcription. If the language has a two-letter ISO 639-1 code, use that; otherwise, use the three-letter ISO 639-3 code. This maps to the phoneme inventory definitions in the languages directory.

  • transcription (String)

    An IPA transcription to syllabify. Any phonemes represented by digraphs must be combined with a tie as discussed in the README.



17
18
19
20
21
# File 'lib/cody_robbins/syllabify.rb', line 17

def initialize(language, transcription)
  set_language(language)
  set_transcription(transcription)
  initialize_coda_and_onset
end

Instance Method Details

#syllablesArray

Return the individual Syllable objects representing the transcription’s syllables.

Examples:

CodyRobbins::Syllabify.new(:en, 'dɪˌsɔrgənəˈze͡ɪʃən').syllables #=> [dɪ, ˌsɔr, gə, nə, ˈze͡ɪ, ʃən]

Returns:

  • (Array)

    The Syllable objects representing each individual syllable.



39
40
41
# File 'lib/cody_robbins/syllabify.rb', line 39

def syllables
  @syllables ||= build_syllables
end

#to_sString

Render a syllabified IPA transcription of the input transcription. Syllables are delimited by the IPA syllable delimiter.

Examples:

CodyRobbins::Syllabify.new(:en, 'dɪˌsɔrgənəˈze͡ɪʃən').to_s #=> 'dɪ.ˌsɔr.gə.nə.ˈze͡ɪ.ʃən'

Returns:

  • (String)


29
30
31
# File 'lib/cody_robbins/syllabify.rb', line 29

def to_s
  syllables_as_strings.join(SYLLABLE_DELIMETER)
end