def find_phoneme_stress(self, phonemes): # This algorithm should use the same way of counting syllables as the # Syllabifier but should also remember which one has the stress # print u'DEBUG: Unmassaged phonemes ',phonemes phoneme= self._massage_phonetic_word(phonemes[1]) # print u'DEBUG: massaged phonemes: ', phoneme syllabifyer = Syllabifyer(phoneme, mock = self.mock) syllabifyer.syllabify() # WILL ALWAYS ONLY BE ONE WORD syllables = syllabifyer.get_syllable_set()[0][0] print u"DEBUG: find_phoneme_stress | Final output: {0}".format(syllables) i = 0 ss = syllables.split(".") while i < len(ss): if "'" in ss[i]: return i i += 1 return 0
def find_phoneme_stress(self, phonemes): # This algorithm should use the same way of counting syllables as the # Syllabifier but should also remember which one has the stress # print u'DEBUG: Unmassaged phonemes ',phonemes phoneme = self._massage_phonetic_word(phonemes[1]) # print u'DEBUG: massaged phonemes: ', phoneme syllabifyer = Syllabifyer(phoneme, mock=self.mock) syllabifyer.syllabify() # WILL ALWAYS ONLY BE ONE WORD syllables = syllabifyer.get_syllable_set()[0][0] print u"DEBUG: find_phoneme_stress | Final output: {0}".format( syllables) i = 0 ss = syllables.split(".") while i < len(ss): if "'" in ss[i]: return i i += 1 return 0
def input_to_observations(self): # STEP 0: Get input from user # stored in self.user_input self.get_input() # STEP 1: Syllabify ortographic text syllabifyer = Syllabifyer(self.ortographic_text, mock=self.mock) syllabifyer.syllabify() self.syllables = syllabifyer.get_syllable_set() # STEP 1.5: VALIDATE INPUT self.validate_input(self.user_input, self.syllables) print print '\n-----\n'.join(' ||| '.join(y for y in x) for x in self.syllables) """ SAME STEP """ # STEP 2: Translate user input to phonetic version (maybe remotely) self.phonetic_text = self.transcribe_input( self.ortographic_text, mode=PhoneticTranscriber.REMOTE, protocol='UDP', mock=self.mock) # IF DEBUG print "\nPrinting data to validate." for line in self.phonetic_text: for w in line: print u"{0} == became ==> {1}".format(w[0], w[1]) # STEP 3: Syllabify phonetic text (using external binary) """ /SAME STEP""" # STEP 4: Fuse together syllables and phoneme syllable (not syllables...) in one # Observation object return self.mark_syllables_for_stress(self.syllables, self.phonetic_text)
def input_to_observations(self): # STEP 0: Get input from user # stored in self.user_input self.get_input() # STEP 1: Syllabify ortographic text syllabifyer = Syllabifyer(self.ortographic_text, mock = self.mock) syllabifyer.syllabify() self.syllables = syllabifyer.get_syllable_set() # STEP 1.5: VALIDATE INPUT self.validate_input(self.user_input, self.syllables) print print '\n-----\n'.join(' ||| '.join(y for y in x ) for x in self.syllables) """ SAME STEP """ # STEP 2: Translate user input to phonetic version (maybe remotely) self.phonetic_text = self.transcribe_input(self.ortographic_text, mode = PhoneticTranscriber.REMOTE, protocol = 'UDP', mock = self.mock) # IF DEBUG print "\nPrinting data to validate." for line in self.phonetic_text: for w in line: print u"{0} == became ==> {1}".format(w[0],w[1]) # STEP 3: Syllabify phonetic text (using external binary) """ /SAME STEP""" # STEP 4: Fuse together syllables and phoneme syllable (not syllables...) in one # Observation object return self.mark_syllables_for_stress(self.syllables, self.phonetic_text)