Created
August 21, 2012 08:05
-
-
Save KitWallace/3413355 to your computer and use it in GitHub Desktop.
expanding abbreviations for TTS
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# in weather | |
substitutes = { | |
"W":"West","N":"North","S":"South","E":"East", | |
"km/h":"kilometers per hour","C":"Celsius","mph":"miles per hours", | |
"Mon":"Monday","Tue":"Tuesday","Wed":"Wednesday","Thu":"Thursday","Fri":"Friday","Sat":"Saturday","Sun":"Sunday", | |
"NNE":"Nor Nor East","NE":"Nor East","ENE":"East Nor East","ESE":"East Sow East", | |
"SE":"Sow East" ,"SSE" :"Sow Sow East", "SSW":"Sow Sow West","SW":"Sow West","WSW":"West Sow West", | |
"WNW":"West Nor West","NW":"Nor West","NNW":"Nor Nor West", | |
"%":"percent" | |
} | |
# in xmlutils | |
def substitute(word,substitutes) : | |
try : | |
replacement = substitutes[word] | |
return '<sub alias="' + replacement +'">'+word+'</sub>' | |
except : | |
return word | |
def expand(text,substitutes) : | |
return " ".join([substitute(word,substitutes) for word in text.split(" ")]) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment