Programming games in historical linguistics with Python
Steven D'Aprano
steve+comp.lang.python at pearwood.info
Wed Dec 1 04:26:05 EST 2010
On Tue, 30 Nov 2010 07:03:28 -0800, Dax Bloom wrote:
> Is there a way to refer to vowels and consonants as a subcategory of
> text? Is there a function to remove all vowels? How should one create
> and order the dictionary file for the rules? How to chain several
> transformations automatically from multiple rules? Finally can anyone
> show me what existing python program or phonological software can do
> this?
Have you looked at NLTK?
http://www.nltk.org/
The questions you are asking are awfully specific for a general
programming forum like this. You might have better luck asking on a NLTK
forum, or possibly if you could pose your questions in ways that don't
assume extensive familiarity in linguistics ("word nucleus"? "codas"?).
Is there a function to remove vowels -- not specifically, but provided
you can tell us what characters you wish to treat as vowels, and provided
you are satisfied with a fairly simple search-and-replace, this will do
it:
# For Python 2.x
def disemvowel(s):
"""Quick and dirty disemvoweller."""
tbl = string.maketrans('', '')
return string.translate(s, tbl, "aeiouAEIOU")
If you want a function that can distinguish between Y being used as a
vowel from Y being used as a consonant, you'll need something much more
sophisticated -- try the NLTK.
--
Steven
More information about the Python-list
mailing list