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 Last Time: http://perldoc.perl.org/perlintro.html
Quick Quiz (you should have received an back from me) Today's class: Quick Quiz Review Quick Homework 1 Continue with perlintro …

3 Quick Quiz on Chapter 1 Review
NN = common noun NP = noun phrase VBD = verb past tense VP = verb phrase

4 Quick Quiz on Chapter 1 Review

5 Quick Quiz on Chapter 1 Review

6 Syntactic Labeling (Standard)
How to read the parse Phrasal Labels: VP = Verb Phrase, S = Sentence, SBAR = Embedded Sentences, NP = Noun Phrase, PP = Prepositional Phrase. ADJP = Adjectival Phrase. Basic declarative sentence: [S NP [VP VBD NP]] Part of Speech (POS) labels: 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:

7 Quick Homework 1 Q1: What's supposed to be funny about this?
Q2: Run the 1st sentence on the Berkeley Parser (from Quick Quiz 1). Critique the parse. Q3: Run the 1st sentence on the Google Parser. Critique the dependency parse. (

8 Quick Homework 1 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

9 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

10 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

11 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)

12 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

13 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)

14 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