ling c sc psyc 438 538 n.
Download
Skip this Video
Loading SlideShow in 5 Seconds..
LING/C SC/PSYC 438/538 PowerPoint Presentation
Download Presentation
LING/C SC/PSYC 438/538

Loading in 2 Seconds...

play fullscreen
1 / 8

LING/C SC/PSYC 438/538 - PowerPoint PPT Presentation


  • 123 Views
  • Uploaded on

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

loader
I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
capcha
Download Presentation

PowerPoint Slideshow about 'LING/C SC/PSYC 438/538' - phiala


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.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
Presentation Transcript
ling c sc psyc 438 538

LING/C SC/PSYC 438/538

Lecture 4

9/1

Sandiway Fong

administrivia
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
adminstrivia
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
sentiment analysis
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

perl week
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
perl week1
Perl Week

Generalized form

  • Arrays:
    • insertion and deletion from the ends

0

1

2

n-2

n-1

shift/unshift

pop/push

perl week2
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

perl week3
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.