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

Slides:



Advertisements
Similar presentations
LING 388: Language and Computers Sandiway Fong Lecture 2.
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.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong. Today’s Topics File input/output – open, References Perl modules Homework 2: due next Monday by midnight.
1 Perl Perl basics Perl Elements Arrays and Hashes Control statements Operators OOP in Perl.
Syntax I: Constituents and Structure Gareth Price – Duke University.
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 3 8/30 Sandiway Fong.
LING 388: Language and Computers Sandiway Fong Lecture 10.
Books. Perl Perl (Practical Extraction and Report Language) by Larry Wall Perl 1.0 was released to usenet's alt.comp.sources in 1987 Perl 5 was released.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded.
LING 388: Language and Computers Sandiway Fong Lecture 12.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
Perl Basics. sh-bang !!!! Every perl program starts with a sh-bang line #!/usr/bin/perl # hello.pl printf “Hello, world!\n”; printf STDOUT “Hello, world!\n”;
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
Introduction to Perl October 4, 2004 Class Meeting 7 * Notes on Perl by Lenwood Heath, Virginia Tech © 2004.
More Perl Data Types Scalar: it may be a number, a character string, or a reference to another data type. -the sigil $ is used to denote a scalar(or reference)
Department of Electrical and Computer Engineering Introduction to Perl By Hector M Lugo-Cordero August 26, 2008.
Perl Day 5. Arrays vs Hash Arrays are one way to store multiple things in a variable. Hashes are another. Arrays are one way to store multiple things.
LING/C SC/PSYC 438/538 Lecture 20 Sandiway Fong 1.
Perl Scripting III Arrays and Hashes (Also known as Data Structures) Ed Lee & Suzi Lewis Genome Informatics.
LING/C SC/PSYC 438/538 Lecture 18 Sandiway Fong. Adminstrivia Homework 7 out today – due Saturday by midnight.
LING/C SC/PSYC 438/538 Lecture 6 Sandiway Fong. Homework 4 Submit one PDF file Your submission should include code and sample runs Due date Monday 21.
LING/C SC/PSYC 438/538 Lecture 10 Sandiway Fong. Today's Topics A note on the UIUC POS Tagger Fun with POS Tagging Perl regex wrap-up.
LING/C SC/PSYC 438/538 Lecture 19 Sandiway Fong 1.
The Scripting Programming Language
LING/C SC 581: Advanced Computational Linguistics Lecture Notes Feb 17 th.
PHP using MySQL Database for Web Development (part II)
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong.
Basic Parsing with Context Free Grammars Chapter 13
CIIT-Human Computer Interaction-CSC456-Fall-2015-Mr
Chapter 5 - Control Structures: Part 2
Shell Scripting March 1st, 2004 Class Meeting 7.
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 7 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 21 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 20 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 7 Sandiway Fong.
Chapter 14 Introduction to Ruby.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
LING/C SC 581: Advanced Computational Linguistics
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
Perl Variables: Array Web Programming.
What are Adjectives? Adjectives are modifiers. They modify nouns or pronouns. This means they tell us more about how a noun or pronoun looks or behaves.
LING/C SC/PSYC 438/538 Lecture 6 Sandiway Fong.
Name: _______________________________
Introduction to Perl Jarrad Battaglia.
LING/C SC/PSYC 438/538 Lecture 10 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 12 Sandiway Fong.
PERL: part II hashes, foreach control statements, and the split function By: Kevin Walton.
LING/C SC/PSYC 438/538 Lecture 23 Sandiway Fong.
Perl I/O Learning Objectives:
LING/C SC/PSYC 438/538 Lecture 24 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 15 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 13 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 17 Sandiway Fong.
Artificial Intelligence 2004 Speech & Natural Language Processing
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/PSYC 438/538 Lecture 12 Sandiway Fong.
Presentation transcript:

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

Today’s Topics Sorting: Homework 4 Review More Perl: fc (fold case), hash sort Homework 4 Review More Perl: Implicit Coercion Conditionals Loops On Thursday: Homework 5 first programming homework

Last Time: Arrays: insertion and deletion from the ends Generalized form: shift/unshift 1 2 n-2 n-1 pop/push Perl functions may have side effects and also return values Good ex: print push @a, "a", "\n";

Perl Arrays Sorting: {$a cmp $b} {$a <=> $b} default (ASCII table order) {$a <=> $b} numeric flip $a $b for reverse order enable function fc for Unicode casefolding

Handling characters beyond ASCII … Unicode encoding (utf-8)

Handling characters beyond ASCII … Note: open pragma most general solution https://perldoc.perl.org/open.html

Perl Hashes Sorting with a hash Usage: sort byage keys %age Let's sort fruits by color, ascending, descending…

Homework 4 Review Relevant tags: Stanford Parser: I made her duck Phrasal: S Sentence; NP Noun Phrase; VP Verb Phrase Part of Speech (POS): PRP Personal Pronoun; VBD Verb Past; PRP$ Possessive Personal Pronoun; NN Common Noun; . . Dependency links: nsubj; nmod:poss; dobj

Homework 4 Review Lisp S-EXP syntax: Tree representation:

Homework 4 Review ❌? cf. I baked [ John] [a cake] ❌ Verb: duck ❌ Ditransitive verb: duck

Homework 4 Review Winograd’s SHRDLU system: Tree Representation: Move the red block on top of the smaller green one Tree Representation: PP modifies VP (not NP)

Homework 4 Review Another interpretation: Stanford parse: http://www.gettyimages.co.uk/detail/photo/red-green-blue-and-yellow-building-blocks-high-res-stock-photography/77937865

Homework 4 Review

Implicit Coercion Example: Example: Perl features implicit coercion of data types Example: the following program prints Equal! == is the numeric equality comparison operator my $one_string = "1"; my $one_number = 1; if ($one_string == $one_number) { print "Equal!\n" } else { print "Different!\n" } Example: the following program prints 3 is my number . is the string concatenation operator my @a = qw(one, two, three); my $string = @a." is my number"; print "$string\n";

Implicit Coercion print "4" * 4 16 print "4" x 4 (“x” is the repetition operator) 4444 @a = (4) x 4 (in list context) (4, 4, 4, 4)

Conditionals and Looping 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

Conditionals and Looping

Conditionals and Looping Looping over arrays %fruits = qw(apple green orange orange lemon yellow); foreach $f (keys %fruits) { print $f, " => ", $fruits{$f}, "\n” } gives output: lemon => yellow apple => green orange => orange Note: keys %fruits = ("lemon", "apple", "orange") is an array

ARGV Command line: perl argv.perl 1 2 3

General Looping