Code examples
General
- Hello-world example (code)
- Documentation example (code)
File-IO
- Reading file content into a string variable (code)
- Reading from file into list of lines (code)
- Reading from file line by line and processing each line (code)
- Fast and compact file input (code)
- Reading file content into a string variable, embedded in a try statement (code)
- Writing string content to a file (overwriting existing file) (code)
- Appending string content to a file (code)
- Writing Unicode strings to a file with specific encoding (code)
Parsing
- Grammatik file (code)
- Grammatik parser (code)
- Top-down parser (code)
- Bottom-up parser (code)
- Chart-parser
Counting
- Counting words 1 (code)
- Counting words 2 (Unicode tokens) (code)
- Counting words 2 (Unicode tokens) (code)
- Counting words 3 (sort dictionary by value) (code)
- Counting words 4 (sort dictionary by value) (code)
- Counting words 5 (tokenize with regular expression) (code)
- Counting words 6 (without function words) (code)
N-gram models
- General n-gram class with persistance functions (code)
- Language Identification (LID)
- Generating n-grams from the Brown corpus (code)
- Chi2 test for collocations (code)
- Calculating Mutual Information and Relative Entropy for bigrams (code)
Vector Space and Clustering
- Generating a vector space (code)
- K-means clustering (code)
- Expectation Maximization clustering (code)
(C) 2005 by Damir Ćavar, dcavar _at_ indiana _dot_ edu