mirror of
https://github.com/wassname/pysle.git
synced 2026-08-13 12:30:07 +08:00
FEATURE: Updated to new isledict format. Now using unicode IPA
It made the code a little more complex and now the system is less typing friendly but is more intuitive (no more guessing how to pronounce a character). Update includes changes to documentation.
This commit is contained in:
@@ -1,3 +1,4 @@
|
||||
#encoding: utf-8
|
||||
'''
|
||||
Created on Oct 22, 2014
|
||||
|
||||
@@ -12,16 +13,18 @@ from pysle import pronunciationtools
|
||||
# In this first example we look up the syllabification of a word and get it's
|
||||
# stress information.
|
||||
|
||||
searchWord = 'pumpkins'
|
||||
isleDict = isletool.LexicalTool('islev2.txt')
|
||||
searchWord = 'catatonic'
|
||||
isleDict = isletool.LexicalTool('ISLEdict.txt')
|
||||
lookupResults = isleDict.lookup(searchWord)
|
||||
|
||||
firstEntry = lookupResults[0]
|
||||
firstSyllableList = firstEntry[0]
|
||||
firstSyllableList = ".".join([u" ".join(syllable) for syllable in firstSyllableList])
|
||||
firstStressList = firstEntry[1]
|
||||
|
||||
print(searchWord)
|
||||
print(firstSyllableList, firstStressList) # 3rd syllable carries stress
|
||||
print(firstSyllableList)
|
||||
print(firstStressList) # 3rd syllable carries stress
|
||||
|
||||
|
||||
# Here we determine the syllabification of a word, as it was said.
|
||||
@@ -43,4 +46,6 @@ print(anotherPhoneList)
|
||||
print(stressedSyllableIndexList) # We can see the first syllable was elided
|
||||
print(stressedPhoneIndexList)
|
||||
print(flattenedStressIndexList)
|
||||
print(syllableList)
|
||||
print(syllabification)
|
||||
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
#encoding: utf-8
|
||||
'''
|
||||
Created on July 08, 2016
|
||||
|
||||
@@ -10,7 +11,7 @@ import random
|
||||
|
||||
from pysle import isletool
|
||||
|
||||
tmpPath = r"C:\Users\Tim\Dropbox\workspace\pysle\test\islev2.txt"
|
||||
tmpPath = r"C:\Users\Tim\Dropbox\workspace\pysle\test\ISLEdict.txt"
|
||||
isleDict = isletool.LexicalTool(tmpPath)
|
||||
|
||||
def printOutMatches(matchStr, numSyllables=None, wordInitial='ok',
|
||||
@@ -33,7 +34,7 @@ def printOutMatches(matchStr, numSyllables=None, wordInitial='ok',
|
||||
if numMatches is not None and i > numMatches:
|
||||
break
|
||||
word, pronList = matchTuple
|
||||
print("%s: %s" % (word, repr(pronList)))
|
||||
print("%s: %s" % (word, ",".join(pronList)))
|
||||
print("")
|
||||
|
||||
return matchList
|
||||
@@ -45,10 +46,10 @@ printOutMatches("dV", stressedSyllable="only", spanSyllable="no",
|
||||
# 3-syllable word with an 'ld' sequence that spans a syllable boundary
|
||||
printOutMatches("lBd", wordInitial="no", multiword='no',
|
||||
numSyllables=3, numMatches=10)
|
||||
|
||||
|
||||
# words ending in 'inth'
|
||||
matchList = printOutMatches("InT", wordFinal="only", numMatches=10)
|
||||
|
||||
matchList = printOutMatches(u"ɪnɵ", wordFinal="only", numMatches=10)
|
||||
|
||||
# that also start with 's'
|
||||
matchList = printOutMatches("s", wordInitial="only", numMatches=10,
|
||||
matchList=matchList, multiword="no")
|
||||
|
||||
Reference in New Issue
Block a user