ling/c sc/psyc 438/538 lecture 3 sandiway fong. administrivia homework 2 graded
TRANSCRIPT
![Page 1: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/1.jpg)
LING/C SC/PSYC 438/538
Lecture 3Sandiway Fong
![Page 2: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/2.jpg)
Administrivia
• Homework 2 graded
![Page 3: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/3.jpg)
Today’s Topics
• Homework 2 review– reminder: submit plain text or PDF please
(no .doc/.docx)
• Perl
![Page 4: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/4.jpg)
Short Homework 2 Review
• Is tough sledding an idiom or compositional in meaning?
• Compositional:– Meaning(tough sledding) = Meaning(tough) ⨂
Meaning(sledding)– Literal meaning: "kick the bucket"
• Idiom:– Meaning(tough sledding): explicitly learned and
stored
![Page 5: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/5.jpg)
Short Homework 2 Review
• The chickens are ready to eat• In what way(s) is this sentence structurally
ambiguous?
gardenbetty.com
X eat YX = the chickens
Berkeley Parser
![Page 6: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/6.jpg)
Short Homework 2 Review
• The chickens are ready to eat• In what way(s) is this sentence structurally
ambiguous?
wikipedia
X eat YY = the chickens
![Page 7: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/7.jpg)
Short Homework 2 Review
• John said he dislikes nearly everyone he meets • In what way(s) is this sentence referentially
ambiguous? 1. John said John dislikes nearly everyone John meets2. John said Pete dislikes nearly everyone Pete meets3. John said Pete dislikes nearly everyone John meets4. …
![Page 8: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/8.jpg)
Perl Day
• Learn Perl– Books… see next slide– Online resources• http://learn.perl.org/• we begin with ...• http://perldoc.perl.org/perlintro.html
philosophy: Natural Language Principles in PerlIf a language is designed so that you can ``learn as you go'', then the expectation is that everyone is learning, and that's okay.http://www.wall.org/~larry/natural.html
![Page 9: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/9.jpg)
Perl DayUA has free access to O'Reilly's Safari library:• http://proquest.safaribooksonline.com.ezproxy2.library.arizona.edu/search?
q=perl
![Page 10: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/10.jpg)
Perl arrays and hashes
• Scalars: – strings, numbers (integers, floating point numbers),
references• Arrays:– Store multiple scalars together– Idea: list of scalars– Access by index: 0,1,2,…
• Hash (aka Associative Array):– Like an array except access not through a numeric index– Use user-specified keys
$variable
@variable
%variable
different namespaces:$apple @apple %appleare different data structuresand can co-exist simultaneously
most programming languages will offer youall of these basic data types
![Page 11: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/11.jpg)
Perl Week
![Page 12: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/12.jpg)
Perl Week
![Page 13: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/13.jpg)
Perl Week• Notes on arrays and hashes
– arrays are indexed from 0,1,2,3…– hashes are like arrays with user-defined indexing
(aka associative array or hash table)
– initialization (use round brackets and commas)• @a = (“zero”, “one”, “two”, “three”, “four”);• %h = (“zero”, 0, “one”, 1, “two”, 2, “three”, 3, “four”, 4);
(key/value pairs)
– access to individual elements (square brackets vs. curly braces)• $a[1] “one”• $h{zero} 0
![Page 14: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/14.jpg)
Perl Week
• Notes on arrays and hashes– output
• print @a zeroonetwothreefour• print “@a” zero one two three four• print %h three3one1zero0two2four4
(note: different order)• print “%h” %h (literal, no interpolation)
What happens here?– %pos = ("apple", "n", "speak", "v", "happy", "a", "walk", "n",
"walk", "v");– print $pos{"walk"}, "\n";
(hash keys are unique)
controlled by variable $”default: a space
![Page 15: LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded](https://reader036.vdocuments.net/reader036/viewer/2022062408/56649f1c5503460f94c326c4/html5/thumbnails/15.jpg)
Perl Week
• Conditionals– if ( @a < 10 ) { print “Small array\n” } else {print “Big array\n” }– Note: @a here is a scalar = size of array– unless (@a > 10) { print “@a\n” }– Note: if size of array a is ≤ 10, it prints the contents of array a
Looping%fruits = ("apple", "green", "orange", "orange", "lemon", "yellow");foreach $fruit (keys %fruits) { print $fruit, " => ", $fruits{$fruit}, "\n” }gives output:lemon => yellowapple => greenorange => orangeNote: apparently
keys %fruits = (“lemon” “apple” “orange”) is an array