1 / 13

LING/C SC/PSYC 438/538

LING/C SC/PSYC 438/538. Lecture 2 8/25 Sandiway Fong. Today’s Topics. Checklist You should have read Chapter of JM Quick Quiz Today is Perl Day! You should have installed Perl on your own computer Started playing around with Perl http://learn.perl.org/.

sian
Download Presentation

LING/C SC/PSYC 438/538

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LING/C SC/PSYC 438/538 Lecture 2 8/25 Sandiway Fong

  2. Today’s Topics • Checklist • You should have read Chapter of JM • Quick Quiz • Today is Perl Day! • You should have installed Perl on your own computer • Started playing around with Perl • http://learn.perl.org/

  3. Search and Question Answering (QA) • Examples:

  4. Search and Question Answering (QA)

  5. Search and Question Answering (QA) • Powerset.com (wikipedia powered)

  6. Search and Question Answering (QA)

  7. Quick Quiz: 5 minutes • Write on a piece of paper • Your name • 538 or 438 • Answers to: • Is the word spoilsport an example of compositional semantics or not? Explain your answer. • Re: human language processing vs. machine models of language Did the authors cite any examples of this in chapter 1?

  8. Perl Day • Learn Perl • Books… • Online resources • http://learn.perl.org/ • we begin with ... • http://perldoc.perl.org/perlintro.html

  9. Perl History • Invented by Larry Wall in the mid-1980s • Perl = “Practical Extraction and Reporting Language” • It’s a programming language that aggregates many pre-existing tools from Unix: • Efficient text processing: awk, sed • Searching: grep (regular expression search) • Shell scripting: c-shell and others • Interpreted language, no compilation phase down to machine code (cf. C) • lends itself to rapid prototyping and the writing of small programs. • (Disadvantage: not as fast as C.) • Huge collection of Perl modules (.pm) already written and freely available on CPAN - Comprehensive Perl Archive Network

  10. Perl Day • Let’s go through • http://perldoc.perl.org/perlintro.html

  11. Perl Day • Reading Perl code (perldata): • 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. • 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. • 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.

  12. Perl Day • 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 completely uninformative (and sometimes misleading), e.g. Bareword found where operator expected at example.prl line 3, near "$538students" (Missing operator before students?) • Is the error associated with the variable starting with a number • so make sure you write code consistently. • Semicolon (;) is not always necessary • Command separator token semantics vs. end of command (termination) token • Best practice is to terminate every command with a semicolon

  13. Homework • Practice using Perl • Preparatory reading: • Chapter 2 of the textbook (no quiz) • We’ll be using Perl’s regular expression engine for this

More Related