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

Slides:



Advertisements
Similar presentations
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong. Administrivia Homework 3 graded.
Advertisements

LING/C SC/PSYC 438/538 Lecture 12 Sandiway Fong. Administrivia We'll postpone Homework 4 review until next week …
References and Data Structures. References Just as in C, you can create a variable that is a reference (or pointer) to another variable. That is, it contains.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong. Administrivia Homework 1 graded – you should have gotten an from me.
PHP Functions and Control Structures. 2 Defining Functions Functions are groups of statements that you can execute as a single unit Function definitions.
LING/C SC/PSYC 438/538 Lecture 4 9/1 Sandiway Fong.
Genome Sciences 373 Genome Informatics Quiz Section 3 April 14, 2015.
Part 2 Biophysics 101 Jon Radoff, TF Teaching materials by Ivan Ovcharenko
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 7: 9/11.
COMS W1004 Introduction to Computer Science June 15, 2009.
Hashes a “hash” is another fundamental data structure, like scalars and arrays. Hashes are sometimes called “associative arrays”. Basically, a hash associates.
Week 6 - Programming I So far, we’ve looked at simple programming via “scripts” = programs of sequentially evaluated commands Today, extend features to:
CSC 160 Computer Programming for Non-Majors Lecture #3: Calling Functions Prof. Adam M. Wittenstein
LING 388: Language and Computers Sandiway Fong Lecture 3: 8/28.
LING/C SC/PSYC 438/538 Lecture 5 9/8 Sandiway Fong.
Blue Day – 1/6/2015 Gold Day – 1/7/2015.  Study of functions  Relations  Functions  Last day to do a schedule change is Friday, January 16, 2015.
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.
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.
For Loops 2 ENGR 1181 MATLAB 9. For Loops and Looped Programming in Real Life As first introduced last lecture, looping within programs has long been.
LING/C SC/PSYC 438/538 Computational Linguistics Sandiway Fong Lecture 4: 8/30.
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 .
CSCI 3130: Formal languages and automata theory Tutorial 2 Chin.
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.
ECMM6018 Enterprise Networking For Electronic Commerce Tutorial 5 Server Side Scripting Perl.
4 1 Array and Hash Variables CGI/Perl Programming By Diane Zak.
1 System Administration Introduction to Scripting, Perl Session 3 – Sat 10 Nov 2007 References:  chapter 1, The Unix Programming Environment, Kernighan.
LING/C SC/PSYC 438/538 Lecture 7 9/15 Sandiway Fong.
Meet Perl, Part 2 Flow of Control and I/O. Perl Statements Lots of different ways to write similar statements –Can make your code look more like natural.
PHP Programming with MySQL Slide 4-1 CHAPTER 4 Functions and Control Structures.
Prof. Alfred J Bird, Ph.D., NBCT -bird.wikispaces.umb.edu/ Office – McCormick 3rd floor.
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong. Administrivia Homework 2 graded.
An Intro to Perl, Pt. 2 Hashes, Foreach Control, and the Split Function.
Prof. Alfred J Bird, Ph.D., NBCT Office – McCormick 3rd floor 607 Office Hours – Tuesday and.
CS 105 Perl: Data Types Nathan Clement 15 May 2014.
Math 15 Introduction to Scientific Data Analysis Lecture 8 Python Programming – Part 2 University of California, Merced.
Perl Tutorial. Why PERL ??? Practical extraction and report language Similar to shell script but lot easier and more powerful Easy availablity All details.
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”;
CS 105 Perl: Basic I/O, Context, Strings, Lists Nathan Clement January 22, 2014.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
Prof. Alfred J Bird, Ph.D., NBCT Door Code for IT441 Students.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
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)
Introduction to Perl NICOLE VECERE. Background General Purpose Language ◦ Procedural, Functional, and Object-oriented Developed for text manipulation.
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.
Programming Fundamentals I Java Programming Spring 2009 Instructor: Xuan Tung Hoang TA: Tran Minh Trung Lab 03.
CPSC 217 T03 Week V Part #1: Iteration Hubert (Sathaporn) Hu.
Week Four Agenda Link of the week Review week three lab assignment This week’s expected outcomes Next lab assignment Break-out problems Upcoming deadlines.
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 Online Lecture 7 Sandiway Fong.
JavaScript, Sixth Edition
Introduction to Programming the WWW I CMSC Winter 2004 Lecture 8.
CS170 – Week 1 Lecture 3: Foundation Ismail abumuhfouz.
Chapter 5 - Control Structures: Part 2
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 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 6 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 10 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 12 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
String Handling.
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 12 Sandiway Fong.
Presentation transcript:

LING/C SC/PSYC 438/538 Lecture 3 8/30 Sandiway Fong

Administrivia Homework out today – change: due next Wednesday midnight – (Monday being Labor Day) Reading reminder – Chapter 2 of JM.. we’ll be using Perl here

Quiz from Lecture 1 – Discussion (Quiz not handed back) 1.Is the word spoilsport an example of compositional semantics or not? Explain your answer. idioms contrasted with compositional e.g. spoilsman vs. blackboard 1.Re: human language processing vs. machine models of language Did the authors cite any examples of this in chapter 1?

Perl Week Tutorial contd… – – from arrays onwards …. – Philosophy: Natural Language Principles in Perl If a language is designed so that you can ``learn as you go'', then the expectation is that everyone is learning, and that's okay.

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 (round brackets and = (“zero”, “one”, “two”, “three”, “four”); %h = (“zero”, 0, “one”, 1, “two”, 2, “three”, 3, “four”, 4);(key/value pairs) – Access (square brackets vs. curly braces) $a[1]“one” $h{zero}0 – Output print one two three four print %hthree3one1zero0two2four4(note: different order) print “%h”%h

Perl Week Conditionals – if < 10 ) { print “Small array\n” } else {print “Big array\n” } – here is a scalar = size of array – unless > 10) { print } – 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 => yellow – apple => green – orange => orange – Note: apparently here keys %fruits = (“lemon” “apple” “orange”) is an array

Perl Week 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 = (one, two, three); my $string “ is my number”; print “$string\n”; Perl features implicit coercion of data types

Lecture 3 Homework Due next Wednesday(see lecture 1 for the rules on submissions) One file only total please! Question 1: 438 and 538 (7 points) – Given = (I, saw, the, the, cat, on, the, mat); = (the, cat, sat, on, the, mat); – Write a simple Perl program which detects repeated words (many spell checker/grammar programs have this capability) – It should print a message stating the repeated word and its position if one exists – e.g. word 3 “the” is repeated in the case of sentence1 – No repeated words found in the case of sentence2 – note: output multiple messages if there are multiple repeated words – Hint: use a loop – Submit your Perl code and show examples of your program working

Lecture 3 Homework Question 2: 438 and 538 (3 points) – Describe what would it take to stop a repeated word program from flagging legitimate examples of repeated words in a sentence – (No spell checker/grammar program that I know has this capability) – Examples of legitimately repeated words: I wish that that question had an answer Because he had had too many beers already, he skipped the Friday office happy hour

Lecture 3 Homework Question 3: 538 (10 points), (438 extra credit) – Write a simple Perl program that outputs word frequencies for a sentence – E.g. given = (I, saw, the, cat, on, the, mat, by, the, saw, table); – output a summary that looks something like: – the occurs 4 times – saw occurs twice – I, car, mat, on, by, table occurs once only – Hint: build a hash keyed by word with value frequency – Submit your Perl code and show examples of your program working