1 / 20

LING/C SC/PSYC 438/538

LING/C SC/PSYC 438/538. Lecture 3 9/3 Sandiway Fong. Today’s Topics. Short Homework 1 graded Text summarization a bit more on the extra-credit homework … Perl Day continues! Scalars last time… . Homework 1 Discussion. Flying saucer: idiom?. a nything disk-shaped will qualify. UFO.

shaina
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 3 9/3 Sandiway Fong

  2. Today’s Topics • Short Homework 1 • graded • Text summarization • a bit more on the extra-credit homework … • Perl Day continues! • Scalars last time…

  3. Homework 1 Discussion • Flying saucer: idiom? anything disk-shaped will qualify UFO saucer

  4. Homework 1 Discussion • Structural ambiguity: • I prodded the boy with a pole • [NP the boy] • [VP prodded[NP the boy]] • [PP with a pole]] http://www.merriam-webster.com

  5. Homework 1 Discussion • Structural ambiguity: • I prodded the boy with a pole • [NP the boy] • [VP prodded[NP the boy]] • Phrase structure: adjunction, PP adjoins to … • [NP [NP the boy] [PP with a pole]] • [VP [VP prodded[NP the boy]] [PP with a pole]] • [PP with a pole]]

  6. Homework 1 Discussion • Referential ambiguity: • John disliked nearly everyone that he knew pronoun coreferential with… not John but with someone else not mentioned in this sentence

  7. Open Text Summarizer • Web interface • http://www.splitbrain.org/services/ots • (thanks! Paul Mithun)

  8. Open Text Summarizer • From CNN this morning

  9. Open Text Summarizer • From CNN this morning

  10. Open Text Summarizer • From CNN this morning

  11. Open Text Summarizer • From CNN this morning

  12. Application of the Day • (Optional) Extra Credit for the Curious • (Deadlineextended to anytime before Thursday September 5th) • Discuss whether you think the summarizer does a good job. • Is the article one that’s easy to summarize? • Read up on summarization in J&M (23.3-23.4, pg787-795) • How do you think it works? • Do you think it should work on foreign language text? • Try it…

  13. Perl Day • Learn Perl • Books… • Online resources • http://learn.perl.org/ • we begin with ... • http://perldoc.perl.org/perlintro.html • 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. • http://www.wall.org/~larry/natural.html

  14. Useful notes • 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 frequently completely uninformative (and sometimes misleading), e.g. Bareword found where operator expected at example.prl line 3, near "$538students" (Missing operator before students?) • 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

  15. 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: • Like an array except access not through a numeric index • Use user-specified keys $variable @variable %variable different namespaces: $apple @apple %apple are different data structures and can co-exist simultaneously

  16. Perl Week

  17. Perl Week

  18. 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

  19. 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"; controlled by variable $” default: a space • (hash keys are unique)

  20. 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 => yellow • apple => green • orange => orange • Note: apparently • keys %fruits = (“lemon” “apple” “orange”) is an array

More Related