Download presentation
Presentation is loading. Please wait.
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 20 th – 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 http://perldoc.perl.org/perlintro.html – Section on Regular expressions – in conjunction with chapter 2 of JM
6
Perl Week Arrays: – insertion and deletion from the ends 012n-1n-2 shift/unshift pop/push Generalized form
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 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 = ) { print "$line"; } the command $line = reads in from the file referenced by the file handle $txtfile a 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.txt exists.
Similar presentations
© 2024 SlidePlayer.com. Inc.
All rights reserved.