Download presentation
Presentation is loading. Please wait.
Published byLinda Page Modified over 9 years ago
1
LING 408/508: Programming for Linguists Lecture 27 December 9 th
2
Class Inheritance
3
Higher order functions map(function,list) apply function to each member of the list in turn creating a transformed list
4
Higher order functions map(function,list) apply function to each member of the list in turn creating a transformed list inline anonymous function: lambda example: λx.x+x lambda x:x+x
5
Higher order functions reduce(function,list) apply 2-argument function from left to right 1 st argument will be cumulative value 2 nd argument is fresh argument from the list number of cannonballs in pyramid (Wikipedia):
6
Higher order functions filter(function,list) apply function to each member of the list collect those for which the function returns true
7
Standard Deviation Example textbook code seems problematic…
8
Median Median: – average of middle two if even number of elements – middle element of list if odd number of elements
9
Lists Comparisons: – default sort order: cmp(x,y) – returns -1 (x y)
10
Lists create a list of Student objects in variable data
11
Dictionaries Hash table: List: – delimiter: square brackets Dictionary: – delimiter: curly braces
12
Dictionaries
13
Word frequency table program: tokenization
14
Dictionaries Word frequency table program default = 0
15
Dictionaries Word frequency table program
16
Corpus Lead NYTimes article one year ago tomorrow: http://www.nytimes.com/2014/12/10/world/senate-intelligence-committee-cia-torture-report.html
17
Non-ASCII Corpus
18
wc.py for non- ascii ” regular expression convert and insert space for curly quotes, commas, single quotes, and periods not preceded by a capital letter sys.argv list holds command line filename and n most freq words
19
Results sys.argv[1] sys.argv[2] top 2 content words in the article
20
Adminstrivia TCEs are fully online (paper TCEs are history) https://tce.oirps.arizona.edu/TCEOnline
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.