Presentation is loading. Please wait.

Presentation is loading. Please wait.

LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.

Similar presentations


Presentation on theme: "LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong."— Presentation transcript:

1 LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong

2 Administrivia Homework 3 Make Up:
If you missed HW3, there is an alternate HW3. me. Last Time: Quick Quiz (you should have received an back from me) Today's class: Quick Quiz Review Quick Homework 4 perlintro …

3 Quick Quiz on Chapter 1

4 Quick Quiz on Chapter 1 I made her duck. 1. Eye made her duck.
Eye maid her duck. I maid her duck. Label: Short for: PRP pronoun PRP$ possessive pronoun NN common noun VBD verb past tense NP noun phrase VP verb phrase S sentence

5 Quick Quiz on Chapter 1 I made her duck. Eye made her duck.
Label: Short for: PRP pronoun PRP$ possessive pronoun NN common noun NNP proper noun VBD verb past tense VBZ verb 3rd pers. sg. present NP noun phrase VP verb phrase S sentence Quick Quiz on Chapter 1 I made her duck. Eye made her duck. Eye maid her duck. I maid her duck.

6 Quick Homework 4 Q1: Explain what's supposed to be funny about this?

7 Quick Homework 4 1. Commas are important people.
Q2: Run the these two sentences on the Berkeley Parser. Critique the parse. ( Q3: Compare with the Google Parser. Critique the dependency parses. (

8 Quick Homework 4 Resources Universal dependencies relations:
Universal Part of Speech (POS) tags: Tree labels VP = Verb Phrase, S = Sentence, SBAR = Embedded Sentences, NP = Noun Phrase, PP = Prepositional Phrase. ADJP = Adjectival Phrase. Tree POS tags: DT = Determiner, JJ = Adjective, JJR = Adjective (Comparative Form), NN = Common Noun, NNS = Common Noun (plural), NNP = Proper Noun, VB = Verb (base form), VBD = Verb (past tense), IN = Preposition, PRP$ = Possessive Pronoun. More here:

9 Quick Homework 4 email me your answers by the end of Wednesday Rules:
Subject: 438/538 Your Name Homework 1 One PDF file only (include any diagrams) – no multiple attachments, no Word documents

10 Programming From last time…
Search: how do I look for patterns (regex) in a text corpus? grep -Eo ':\s+Yea[^h]' 2150Mon.txt perl -nle 'print $1 if /(.):\s+Yep/' 2149Mon.txt  command line options: -nle -n loop over lines of the input file -l print newlines -e execute code from command line

11 Perl http://perldoc.perl.org/perlintro.html One-liner:
perl -e 'PerlCode' Notes from the tutorial: whitespace not always necessary, e.g. print"Hello class!\n”; is fine, but good idea to consistently use spacing (not just for readability) variable names must not begin with a number (use a letter), so $538students is out $students538 is ok error messages are frequently uninformative (and sometimes misleading), e.g. Bareword found where operator expected at example.prl line 3, near "$538students" (Missing operator before students?) error not associated with the variable starting with a number “Nanny mode”: helps with debugging: makes you declare variables with my

12 print as a statement vs. function
Perl Python3 Same behavior, different assumptions about end of line (\n) from these two programming languages escape character Note also the differences in syntax: (..) in Python3, no parentheses (needed) in Perl ; need to separate the statements in Perl, none in Python

13 Perl vs. Python3 Scalars: (basically things that take up one 32/64 bit word of memory) variables begin with ($) - no such type requirement in Python Numbers (integer, floating point) Python includes complex numbers (cmath library) Strings (double ".." or single quoted '..') References (pointers to (non-)scalars)

14 Perl vs. Python3 Variable interpolation Perl: Python3: Python2.7:
print "My name is $name\n"; print "My name is \$name\n"; print 'My name is \$name\n'; Python3: print("My name is", name) Python2.7: Note: white spacing

15 Perl Arrays like a simple ordered list… (in Python, we use a list)
Literal: @ARRAY = ( … , … , …) (round brackets; comma separator) Python: array = [… , … , … ] Access: $ARRAY[ INDEX] (zero-indexed; negative indices ok; slices ok) Python: array[index] Index of last element:  $#array (a scalar) Python: array[-1] Coercion @ARRAY = number of elements in scalar context Python: len(array) Built-in functions: $ELEMENT; $ELEMENT, $OFFSET, $LENGTH, $ELEMENT $ELEMENT above can Python: array.sort(), array.reverse() Built-in arrays: @ARGV (command line arguments) @_ (sub(routine) arguments)

16 Exercises If you’re new to programming, practice using Perl
read the intro and run all the examples!


Download ppt "LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong."

Similar presentations


Ads by Google