Python demonstration code and text files

 

These files were prepared by Robert Staubs for use in the UMass Linguistics Python summer group, 2009.

 

Example of text processing using regular expressions:

regex.py

 

Program to search for a pattern in the glosses of a child phonology datafile and put the matches in a new file:

csvsearch.py

 

File referred to in script (see Pater 1997 on source):

trevor.csv

 

Some background on collection types we haven't touched on much (tuples, dictionaries, sets):

collections.py

 

Word frequency example for dictionaries (makes a dictionary of word counts, gives a list of words sorted by frequency):

wordfrequency.py

 

Text we could use with the above (Through the Looking Glass and What Alice Found There):

ttlg.txt

 

Basic function example, Sanskrit meter generation, Fibonacci in 3 different ways (closed form, recursive by way of Sanskrit meters, and the memoization one--should be doable after word frequency):

functions.py

 

Some information about dynamic programming, Fibonacci, and its relation to Sanskrit meter, in the context of a discussion of TesarŐs (1995) Gen:

Ling 751 handout

 

Random text generation based on a bigram language model built from a corpus (incomplete)

bigram_textgen_PROBLEM.py

 

Random text generation based on a bigram language model built from a corpus (complete)

bigram_textgen_SOLUTION.py

 

Syllabify a word based on onset and nuclei rules

syllabify.py

 

Build nonce words based on bigram language model of phones (incomplete--requires NLTK corpora)

bigram_noncegen_PROBLEM.py

 

Build nonce words based on bigram language model of phones (complete--requires NLTK corpora)

bigram_noncegen_SOLUTION.py

 

Skeleton version of an object-oriented approach to segmental phonology to illustrate OO concepts

phone.py

 

Generate all possible patterns permissible under a set of set definitions and a template utilizing them

patterngen.py

 

Simple set definition file usable with patterngen

sampleset.txt