prepare for next time

14
Prepare for next time • No need to buy the book – Free online at http://www.nltk.org/book • Read Chapter 1 http://nltk.googlecode.com/svn/trunk/doc/book/ ch01.html Install 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)

Upload: rusty

Post on 16-Feb-2016

28 views

Category:

Documents


0 download

DESCRIPTION

Prepare for next time. No need to buy the book Free online at http://www.nltk.org/book Read Chapter 1 http://nltk.googlecode.com/svn/trunk/doc/book/ch01.html Install NLTK (see next slide) Warning: It might not be easy (and it might not be your fault) Let us know how it goes - PowerPoint PPT Presentation

TRANSCRIPT

Page 1: Prepare for next time

Prepare for next time

• No need to buy the book– Free online at http://www.nltk.org/book

• Read Chapter 1 – http://nltk.googlecode.com/svn/trunk/doc/book/ch01.html

• Install 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)

Page 2: Prepare for next time

Installing NLTKhttp://nltk.googlecode.com/svn/trunk/doc/book/ch01.html

• Chapter 01: pp. 1 - 4– Python– NLTK– Data

Page 3: Prepare for next time

Homework

Page 4: Prepare for next time

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 & Wordnet

Page 5: Prepare for next time

Introduction to ProgrammingTraditional(Start with Definitions)• Constants: 1• Variables: x• Objects:

– lists, strings, arrays, matrices• Expressions: 1+x• Statements: Side Effects

– print 1+x;• Conditionals:

– If (x<=1) return 1;• Iteration: for loops• Functions• Recursion • Streams

Non-Traditional(Start with Examples)

• Recursiondef fact(x):

if(x <= 1): return 1else: return x * fact(x-1)

• Streams:– Unix Pipes

• Briefly mentioned– Everything else

Page 6: Prepare for next time

Pythondef fact(x):

if(x <= 1): return 1else: return x * fact(x-1)

def fact2(x):result=1for i in range(x):result *=(i+1);return result

• Exercise: Fibonacci in Python

Recursion

Iteration

Page 7: Prepare for next time

Lists

Page 8: Prepare for next time

Strings

Page 9: Prepare for next time

Subscripting

Page 10: Prepare for next time

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

Rest

Page 11: Prepare for next time

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-1

Page 12: Prepare for next time

Types & Tokens

PolymorphismPolymorphism

Page 13: Prepare for next time

Polymorphism(From Wikipedia)

Page 14: Prepare for next time

Flatten: Inverse of Split

>>> def flatten(list):if(len(list) == 1): return list[0];else: return list[0] + ' ' + flatten(list[1:len(list)]);

+