LING/C SC/PSYC 438/538 Lecture 3 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

CPSC 422, Lecture 16Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 16 Feb, 11, 2015.
LING 388: Language and Computers Sandiway Fong Lecture 2.
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong. Administrivia Homework 1 graded – you should have gotten an from me.
Tutorial 1 Scanner & Parser
Introduction to Computers and Programming - Class 2 1 Introduction to Computers and Programming Class 2 Introduction to C Professor Avi Rosenfeld.
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.
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.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
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 .
Computer Science 101 Introduction to Programming.
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.
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.
IDL Tutorial Day 1 Goals: 1) Introduce IDL basics 2) Describe fundamental IDL structures Angela Des Jardins
Computer Programming for Biologists Class 3 Nov 13 th, 2014 Karsten Hokamp
Introducing Python CS 4320, SPRING Lexical Structure Two aspects of Python syntax may be challenging to Java programmers Indenting ◦Indenting is.
Internet & World Wide Web How to Program, 5/e © by Pearson Education, Inc. All Rights Reserved.
CPSC 422, Lecture 15Slide 1 Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 15 Oct, 14, 2015.
LING/C SC/PSYC 438/538 Lecture 8 Sandiway Fong. Adminstrivia Homework 4 not yet graded …
Perl Variables: Array Web Programming1. Review: Perl Variables Scalar ► e.g. $var1 = “Mary”; $var2= 1; ► holds number, character, string Array ► e.g.
LING/C SC/PSYC 438/538 Lecture 18 Sandiway Fong. Adminstrivia Homework 7 out today – due Saturday by midnight.
Open Source Server Side Scripting ECA 236 Open Source Server Side Scripting PHP Basics.
2.1 Scalar data - revision numeric e-14 ( = 6.35 × )‏ operators: + (addition) - (subtraction) * (multiplication) / (division)
Python 1 SIGCS 1 Intro to Python March 7, 2012 Presented by Pamela A Moore & Zenia C Bahorski 1.
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.
Programming Perl in UNIX Course Number : CIT 370 Week 2 Prof. Daniel Chen.
Arrays and Lists. What is an Array? Arrays are linear data structures whose elements are referenced with subscripts. Just about all programming languages.
NLP. Introduction to NLP #include int main() { int n, reverse = 0; printf("Enter a number to reverse\n"); scanf("%d",&n); while (n != 0) { reverse =
Today… Style, Cont. – Naming Things! Methods and Functions Aside - Python Help System Punctuation Winter 2016CISC101 - Prof. McLeod1.
LING/C SC 581: Advanced Computational Linguistics Lecture Notes Feb 17 th.
LING/C SC/PSYC 438/538 Lecture 5 Sandiway Fong.
Topics Designing a Program Input, Processing, and Output
Pamela Moore & Zenia Bahorski
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.
LING/C SC/PSYC 438/538 Lecture 2 Sandiway Fong.
Intelligent Systems (AI-2) Computer Science cpsc422, Lecture 15
LING/C SC/PSYC 438/538 Lecture 5 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.
IPC144 Introduction to Programming Using C Week 1 – Lesson 2
LING/C SC/PSYC 438/538 Lecture 4 Sandiway Fong.
LING/C SC 581: Advanced Computational Linguistics
Introduction to Python
LING/C SC/PSYC 438/538 Lecture 3 Sandiway Fong.
Perl Variables: Array Web Programming.
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 23 Sandiway Fong.
LING 408/508: Computational Techniques for Linguists
Topics Designing a Program Input, Processing, and Output
LING/C SC/PSYC 438/538 Lecture 24 Sandiway Fong.
Homework Reading Programming Assignments Finish K&R Chapter 1
LING/C SC/PSYC 438/538 Lecture 13 Sandiway Fong.
LING/C SC/PSYC 438/538 Lecture 11 Sandiway Fong.
Topics Designing a Program Input, Processing, and Output
Topics Designing a Program Input, Processing, and Output
EECE.2160 ECE Application Programming
Introduction to Computer Science
Class code for pythonroom.com cchsp2cs
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 581: Advanced Computational Linguistics
Presentation transcript:

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

Administrivia Homework 3 Make Up: If you missed HW3, there is an alternate HW3. Email me. Last Time: Quick Quiz (you should have received an email back from me) Today's class: Quick Quiz Review Quick Homework 4 perlintro … http://perldoc.perl.org/perlintro.html

Quick Quiz on Chapter 1

Quick Quiz on Chapter 1 I made her duck. 1. Eye made her duck. Eye maid her duck. I maid her duck. Label: Short for: PRP pronoun PRP$ possessive pronoun NN common noun VBD verb past tense NP noun phrase VP verb phrase S sentence

Quick Quiz on Chapter 1 I made her duck. Eye made her duck. Label: Short for: PRP pronoun PRP$ possessive pronoun NN common noun NNP proper noun VBD verb past tense VBZ verb 3rd pers. sg. present NP noun phrase VP verb phrase S sentence Quick Quiz on Chapter 1 I made her duck. Eye made her duck. Eye maid her duck. I maid her duck. 2. 3. 4.

Quick Homework 4 Q1: Explain what's supposed to be funny about this?

Quick Homework 4 1. Commas are important people. Q2: Run the these two sentences on the Berkeley Parser. Critique the parse. (http://tomato.banatao.berkeley.edu:8080/parser/parser.html) Q3: Compare with the Google Parser. Critique the dependency parses. (https://cloud.google.com/natural-language/)

Quick Homework 4 Resources Universal dependencies relations: https://universaldependencies.org/u/dep/index.html Universal Part of Speech (POS) tags: https://universaldependencies.org/u/pos/index.html Tree labels VP = Verb Phrase, S = Sentence, SBAR = Embedded Sentences, NP = Noun Phrase, PP = Prepositional Phrase. ADJP = Adjectival Phrase. Tree POS tags: 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: https://www.ling.upenn.edu/courses/Fall_2003/ling001/penn_treebank_pos.html

Quick Homework 4 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

Programming From last time… Search: how do I look for patterns (regex) in a text corpus? grep -Eo ':\s+Yea[^h]' 2150Mon.txt perl -nle 'print $1 if /(.):\s+Yep/' 2149Mon.txt  command line options: -nle -n loop over lines of the input file -l print newlines -e execute code from command line

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

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

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)

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

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: 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() Built-in arrays: @ARGV (command line arguments) @_ (sub(routine) arguments)

Exercises If you’re new to programming, practice using Perl read the intro and run all the examples!