Exemplo n.º 1
0
def getSyllableText(word):
	syl = ''
	for i in Syllables.getSyllables(word):
		syl = syl + '\t' + ''.join(i) + '\t/'
		# remove trailing '/'
	syl = syl[1:-2]
	return syl
Exemplo n.º 2
0
def hasRhythmicLength(word, index):
	""" does the sylIndex-th syllable have rhythmic vowel length """
	exp = Base.explode(word)
	syl = Syllables.getSyllables(word)
	rl = getRhythmicVowelLengthPattern(word)
	rlexp = []
	for s in range(len(syl)):
		for r in range(len(syl[s])):
			rlexp.append(rl[s])
	return rlexp[index]
Exemplo n.º 3
0
def getRhythmicVowelLengthText(word):
	rhy = ''
	syls = Syllables.getSyllables(word)
	rlen = getRhythmicVowelLengthPattern(word)

	for i in range(len(syls)):
		if rlen[i]:
			syls[i] = ''.join(syls[i]) + '\t'
		rhy = rhy + '\t' + ''.join(syls[i]) + '\t/'
	# remove trailing '/'
	rhy = rhy[1:-2]
	return rhy
Exemplo n.º 4
0
def getStressText(word):
	stress = ''
	syls = Syllables.getSyllables(word)
	spat = getStressPattern(word)

	for i in range(len(syls)):
		if spat[i]:
			syls[i] = ''.join(syls[i]).upper()
		stress = stress + '\t' + ''.join(syls[i]) + '\t/'
	# remove trailing '/'
	stress = stress[1:-2]
	return stress
Exemplo n.º 5
0
def getStressPattern(word):
	stressPat = []
	syl = Syllables.getSyllables(word)
	rhy = getRhythmicVowelLengthPattern(word)
	ruleOne = False
	numStressed = 0

	for i in range(len(syl)):
		if ruleOne:
			numStressed += 1
		# first syllable is closed
		if i < len(syl) - 1:
			if i == 0 and Syllables.syllableMatches(syl[i], 'C'):
				stressPat.append(True)
				ruleOne = True
				numStressed = 0
			# syllable is closed and previous syllable is unstress/open
			elif i > 0 and Syllables.syllableMatches(syl[i], 'C') and not stressPat[-1] and Syllables.syllableMatches(syl[i - 1], 'V'):
				stressPat.append(True)
				ruleOne = True
				numStressed = 0
			# syllable contains VV
			elif Syllables.syllableMatches(syl[i], '[C]VV[C]'):
				stressPat.append(True)
				ruleOne = True
				numStressed = 0
			# syllable is rhythmically lengthened
			elif rhy[i]:
				stressPat.append(True)
				ruleOne = True
				numStressed = 0
			# after finding one of the above rules, every even number syllable gets stress
			elif ruleOne and numStressed > 0 and numStressed % 2 == 0 and Syllables.syllableMatches(syl[i], 'C'):
				stressPat.append(True)
			#syllable preceeding one containing VV
			#FIXME group of OR statements below is a workaround because '[]' format doesn't work correctly in syllableMatches()
			elif i < len(syl) - 1 and (
					Syllables.syllableMatches(syl[i + 1], 'CVV') or Syllables.syllableMatches(syl[i + 1], 'VVC') or Syllables.syllableMatches(
					syl[i + 1], 'VV')):
				stressPat.append(True)
			else:
				stressPat.append(False)
		else:
			stressPat.append(False)
	return stressPat
Exemplo n.º 6
0
def getRhythmicVowelLengthPattern(word):
	"""returns a list of booleans representing which syllables have rhythmic length """
	rhythmicLength = []
	syl = Syllables.getSyllables(word)
	cvCount = 0

	for s in syl:
		if Syllables.syllableMatches(s, 'CV'):
			cvCount += 1
			if cvCount % 2 == 0:
				#FIXME should not be true if cvCount = 0 because of the cvCount +=1 line, but need to test just to make sure. 0 should return false
				rhythmicLength.append(True)
			else:
				rhythmicLength.append(False)
		else:
			cvCount = 0
			rhythmicLength.append(False)

	# probably not best this way, but last syllable doesn't receive rhythmic Length ever.
	rhythmicLength[-1] = False

	return rhythmicLength