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

Slides:



Advertisements
Similar presentations
Arrays A list is an ordered collection of scalars. An array is a variable that holds a list. Arrays have a minimum size of 0 and a very large maximum size.
Advertisements

LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong. Administrivia Homework 1 graded – you should have gotten an from me.
LING/C SC/PSYC 438/538 Lecture 4 9/1 Sandiway Fong.
2ex.1 Lists and Arrays. 2ex.2 Comments on exercises Always run your script with “ perl -w ” and take care of all warnings  submitted scripts should not.
JaySummet IPRE Python Review 2. 2 Outline Compound Data Types: Strings, Tuples, Lists & Dictionaries Immutable types: Strings Tuples Accessing.
LING/C SC/PSYC 438/538 Lecture 2 Sandiway Fong. Today’s Topics Did you read Chapter 1 of JM? – Short Homework 1 (submit by midnight Saturday) Some slides.
Perl Tutorial Presented by Pradeepsunder. Why PERL ???  Practical extraction and report language  Similar to shell script but lot easier and more powerful.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong. Continuing with Perl Homework 3: first Perl homework – due Sunday by midnight – one PDF file, by .
LING/C SC/PSYC 438/538 Lecture 2 Sandiway Fong. Today’s Topics Did you read Chapter 1 of JM? – Short Homework 2 (submit by midnight Friday) Today is Perl.
LING/C SC/PSYC 438/538 Lecture 3 8/30 Sandiway Fong.
Built-in Data Structures in Python An Introduction.
Chapter 9: Perl Programming Practical Extraction and Report Language Some materials are taken from Sams Teach Yourself Perl 5 in 21 Days, Second Edition.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded.
10. Python - Lists The list is a most versatile datatype available in Python, which can be written as a list of comma-separated values (items) between.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Introduction to Perl “Practical Extraction and Report Language” “Pathologically Eclectic Rubbish Lister”
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
Perl COEN 351  Thomas Schwarz, S.J Perl Scripting Language Developed by Larry Wall 1987 to speed up system administration tasks. Design principles.
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
Topic 3: Lists and arrays CSE2395/CSE3395 Perl Programming Learning Perl 3rd edition chapter 3, pages 40-55, 86-91, Programming Perl 3rd edition.
2.1 Scalar data - revision numeric e-14 ( = 6.35 × )‏ operators: + (addition) - (subtraction) * (multiplication) / (division)
Arrays and Lists. What is an Array? Arrays are linear data structures whose elements are referenced with subscripts. Just about all programming languages.
Computer Science 101 Python Lists. Literals, Assignment, Comparisons, Concatenation Similar to the behavior of strings so far a = [1, 2, 3] b = range(1,
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
Organization of Programming Languages Meeting 37 April 18, 2016.
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong.
Python unit_4 review Tue/Wed, Dec 1-2
Expressions and Assignment
Containers and Lists CIS 40 – Introduction to Programming in Python
Natural Language Processing
Miscellaneous Items Loop control, block labels, unless/until, backwards syntax for “if” statements, split, join, substring, length, logical operators,
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 10 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
Natural Language Processing
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong.
Intro to PHP & Variables
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
4 (c) parsing.
LING/C SC/PSYC 438/538 Lecture 7 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
Perl Variables: Array Web Programming.
Bryan Burlingame 03 October 2018
CS 240 – Lecture 18 Command-line Arguments, Typedef, Union, Bit Fields, Pointers to Functions.
Bryan Burlingame Halloween 2018
LING/C SC/PSYC 438/538 Lecture 6 Sandiway Fong.
CISC101 Reminders Assn 3 due tomorrow, 7pm.
LING/C SC/PSYC 438/538 Lecture 12 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
CS 3304 Comparative Languages
LING/C SC/PSYC 438/538 Lecture 24 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 25 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 26 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
15-110: Principles of Computing
Introduction to Computer Science
Bryan Burlingame Halloween 2018
Python Review
Useful functions.
CISC101 Reminders Assignment 3 due today.
Arrays & Loops.
Arrays & Loops.
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 7 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong.
LING/C SC 581: Advanced Computational Linguistics
Selamat Datang di “Programming Essentials in Python”
Presentation transcript:

LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong

Administrivia Last Time: Quick Homework 1 (you should have received an email back from me) Today's class: Quick Homework 1 Review http://perldoc.perl.org/perlintro.html continue with perlintro with a dash of python

Quick Homework 1 Review 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. (https://cloud.google.com/natural-language/)

Quick Homework 1 Review Facebook Joke relies on the the human ability to flexibly attach PPs. Also, there could be a garden path here: preferred attachment site might be to lowest (most recent) VP.

Quick Homework 1 Review Berkeley Parser Not a good parse: why? subject of play can't be interpreted as the kids A constructive question: can we force the Berkeley parser to give us the syntax we want?

Quick Homework 1 Review Quirk: no period here! Assume unexpressed subject is the speaker, i.e. [S [NP PRO][VP [VBG V-ing] …]]

Quick Homework 1 Review Move the PP with an adult beverage earlier in the sentence. result is high attachment to sitting. Unfortunately, watching the kids play now modifies an adult beverage.

Quick Homework 1 Review Move the PP with an adult beverage ahead of in the sun. The VP watching the kids modifies the sun. What is the intended subject of play here?

Quick Homework 1 Review Interpret unexpressed subject as the Speaker (of the sentence)

Quick Homework 1 Review

Quick Homework 1 Review Problematic: looks like the VP modifies the NP

Quick Homework 1 Review

Quick Homework 1 Review Can we force high attachment? Change of PP attachment location Preposition with: accompaniment with cf. instrument with Can we force high attachment?

Quick Homework 1 Review High attachment achieved!

Quick Homework 1 Review

Dependency Relations http://universaldependencies.org List of universal dependencies (v2): http://universaldependencies.org/u/dep/all.html Relevant relations: ccomp: clausal complement xcomp: open clausal complement (no explicit subject) pobj (not V2): prepositional object

World and word knowledge adult beverage: not defined in a dictionary semantic compositionality at work: a beverage restricted to adults kid vs. adult: WordNet (taxonomy and semantic relations between word senses): https://wordnet.princeton.edu adult#n#1 antonym of juvenile#n#1 hypernym of kid#n#1

Google search

perlintro Notes from the tutorial: semicolon (;) is not always necessary Command separator semantics vs. end of command (termination) token Best practice? Terminate every command with a semicolon Variable types: Every variable type has its own namespace. This means that $foo and @foo are two different variables. It also means that $foo[1] is a part of @foo, not a part of $foo. This may seem a bit weird, but that's okay, because it is weird.

Perl Variable Prefixation Reading Perl code (perldata) aloud: Larry Wall was a linguist … The '$' symbol works semantically like the English word "the" in that it indicates a single value is expected. Entire arrays (and slices of arrays and hashes) are denoted by '@', which works much like the word "these" or "those" does in English, in that it indicates multiple values are expected. Also: Entire hashes are denoted by '%’… (no translation) In addition, subroutines are named with an initial '&', though this is optional when unambiguous, just as the word "do" is often redundant in English.

Perl Arrays Arrays: A note on output: Idea: list of scalars like a simple ordered list (cf. Python lists) access by index: 0,1,2,… negative indices count from the end -2..-1 A note on output: print @a zeroonetwothreefour print “@a” zero one two three four controlled by system variable $" default value: a space

perlintro: 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]

perlintro: Perl Arrays like a simple ordered list… (in Python, we use a list) Coercion @ARRAY = number of elements in scalar context Python (no coercion): len(array) Built-in functions: sort @ARRAY; reverse @ARRAY,; push @ARRAY, $ELEMENT; pop @ARRAY; shift @ARRAY; unshift @ARRAY, $ELEMENT, splice @ARRAY, $OFFSET, $LENGTH, $ELEMENT $ELEMENT above can be @ARRAY Python: array.sort(), array.reverse(), NO push (use array.append() instead), array.pop(), No shift/unshift etc… Built-in arrays: @ARGV (command line arguments) @_ (sub(routine) arguments)

perlintro: Perl Arrays Similar to pop/push, but operates at the left end of the array Python doesn't have these defined but can be simulated via slicing and concatenation: array[1:] list + array

perlintro: Perl Arrays