1 / 8

LING/C SC/PSYC 438/538

LING/C SC/PSYC 438/538. Lecture 4 9/1 Sandiway Fong. Administrivia. Reminder homework from lecture 3 due: next Tuesday midnight (I want to go through it in class next Wednesday) Guest lectures Dr. Nirav Merchant, Bioinformatics, Monday September 20 th

phiala
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 4 9/1 Sandiway Fong

  2. Administrivia • Reminder • homework from lecture 3 • due: next Tuesday midnight • (I want to go through it in class next Wednesday) • Guest lectures • Dr. Nirav Merchant, Bioinformatics, Monday September 20th • Dr.  Ray  Tillman,US  Air  Force  Research  Labs,  Mesa  AZ, TBA

  3. Adminstrivia • Related course • LING 408 / 508, Fall 2010 • Computational Techniques for Linguists • Instructor: Erwin Chan • Monday, Wednesday, Friday 12:00-12:50 PM, Social Sciences 224 • This course will introduce students to computer programming for analyzing linguistic data. The programming languages to be used are Python and R. • http://www.u.arizona.edu/~echan3/508/508-fa10-syllabus.pdf

  4. Sentiment Analysis • (thanks: Don Merson) • http://www.kurzweilai.net/mining-mood-swings-on-the-real-time-web • Viralheat uses natural-language processing and machine learning to sift through Twitter, Facebook fan pages, viral video sites, and Google Buzz posts to determine the Web’s collective sentiment toward various topics. go beyond how often something is mentioned

  5. Perl Week • Last topics today • Other useful things for arrays: shift, unshift, push, pop • simple file input/output (I/O) • $ARGV[0] • Reading • http://perldoc.perl.org/perlintro.html • Section on Regular expressions • in conjunction with chapter 2 of JM

  6. Perl Week Generalized form • Arrays: • insertion and deletion from the ends 0 1 2 n-2 n-1 shift/unshift pop/push

  7. Perl Week Files: must be opened for reading or writing (overwrite or append modes) Opening a file creates a file handle (Perl variable) – not to be confused with filename Specify the file handle from input or writing to output

  8. Perl Week • Example Perl code (template) for reading in a file line-by-line (file 4.prl): open($txtfile, $ARGV[0]) or die "$ARGV[0] not found!\n"; while ($line = <$txtfile>) { print "$line"; } • the command $line = <$txtfile> reads in from the file referenced by the file handle $txtfilea single line at a time (including the newline at the end of the line) and places that line in the variable $line. (At the end of the file, $line is just an empty string – which fails the while condition and thus exits the loop.) • the filename is picked up from the command line and placed in the array @ARGV. • Hence: • perl 4.prl words2.txt • returns words2.txt not found! via the die statement because the open statement would evaluate to false (assuming words2.txt doesn’t exist). The while loop doesn’t get executed at all. • But • perl 4.prl words.txt • would execute the while loop and print each line of the file when words.txtexists.

More Related