No need to buy the book Free online at httpwwwnltkorgbook Read Chapter 1 httpnltkgooglecodecomsvntrunkdocbookch01html Install NLTK see next slide Warning It might not be easy and it might not be your fault ID: 285138
Download Presentation The PPT/PDF document "Prepare for next time" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.
Slide1
Prepare for next time
No need to buy the book
Free online at http://www.nltk.org/bookRead Chapter 1 http://nltk.googlecode.com/svn/trunk/doc/book/ch01.htmlInstall NLTK (see next slide)Warning: It might not be easy (and it might not be your fault)Let us know how it goes(both positive and negative responses are more appreciated)Slide2
Installing NLTK
http://nltk.googlecode.com/svn/trunk/doc/book/ch01.html
Chapter 01: pp. 1 - 4PythonNLTKDataSlide3
HomeworkSlide4
George Miller’s Example: Erode
Exercise: Use “erode” in a sentence:My family erodes a lot.
to eat into or away; destroy by slow consumption or disintegration Battery acid had eroded the engine.Inflation erodes the value of our money.Miller’s Conclusion:Dictionary examples are more helpful than defs
Definition
Examples
George Miller: Chomsky’s Mentor
&
WordnetSlide5
Introduction to Programming
Traditional(Start with Definitions)
Constants: 1Variables: xObjects:lists, strings, arrays, matricesExpressions: 1+xStatements: Side Effectsprint 1+x;Conditionals:If (
x
<=1) return 1;
Iteration:
for
loops
Functions
Recursion
Streams
Non-Traditional
(Start with Examples)
Recursion
def
fact(x
):
if(x
<= 1): return 1
else: return
x
* fact(x-1)
Streams:
Unix Pipes
Briefly mentioned
Everything elseSlide6
Python
def fact(x): if(x <= 1): return 1
else: return x * fact(x-1)def fact2(x): result=1 for i in range(x): result *=(i+1); return resultExercise: Fibonacci in Python
Recursion
IterationSlide7
ListsSlide8
StringsSlide9
SubscriptingSlide10
Python Objects
Lists
>>> sent1['Call', 'me', 'Ishmael', '.']>>> type(sent1)<type 'list'>>>> sent1[0]'Call'>>> sent1[1:len(sent1)]['me', 'Ishmael', '.']Strings>>> sent1[0]
'Call'
>>> type(sent1[0])
<type '
str
'>
>>> sent1[0][0]
'C'
>>> sent1[0][1:len(sent1[0])]
'all'
First
RestSlide11
Flatten: Inverse of Split
>>> def flatten(list):
if(len(list) == 1): return list[0]; else: return list[0] + ' ' + flatten(list[1:len(list)]);
First
Rest
flatten = split
-1Slide12
Types & Tokens
Polymorphism
PolymorphismSlide13
Polymorphism(From Wikipedia)Slide14
Flatten: Inverse of Split
>>> def flatten(list):
if(len(list) == 1): return list[0]; else: return list[0] + ' ' + flatten(list[1:len(list)]);
+