Saturday, June 11, 2011

The Drawing Board

I'm on the train back home to Pennsylvania now; it's my first time taking Amtrak. I'm looking through the window at the outside scenery as Wayne suggested that I do. It's completely different from a regular car ride, where you're surrounded by other cars, houses and cities. Even though there are hundreds of strange faces around you, it is completely silent. Instead, you feel like you're by yourself, leveled with the infinite trees and passing green. Surreal - that's what you call it.

I'm coming back home to take care of a few things: (We're riding through an enormous lake now, and there's nothing but trees surrounding both sides of us) groceries, furniture, living essentials, as well as creating an ideal schedule for the rest of the summer. It's about time I set things right; our apartment, even after promises from the landlord to clean up the place by last weekend, is still covered in the previous tenants' trash and spoils. The kitchen repairs are an unfinished mess; the locks are broken, and there are stains covering the walls, especially in the bathroom. We can't even bring in furniture or unpack because the repairs and cleaning has yet to be done. You can imagine that my mom was furious when I told her what sort of living conditions we were in; it seemed like she wanted to give the landlord a piece of her mind. She's a tough mom, and I've learned a lot about responsibility and taking things into your own hands. That's why we're not going to wait anymore for someone to clean up the place; we'll do it ourselves. ;)

Things I need to bring back
+ (check) vacuum cleaner
+ (will buy tomorrow, Friday at IKEAS) beds, mattresses, sheets
+ (will buy) desks, (check) chairs, (check) lamps
+ (check) dust wipes and (check) stain remover
+ (check) air freshener
+ (check) sponges and mops
+ posters, (check) lights, plants (you wouldn't believe how much of a difference plants add)
+ (check) laundry detergent, (check) towels
+ pencils, pens, paper
+ (check) cute things ^.^ (just because I like :D)
+ (check) movies and video games! (I find that just having these around add quality living .. somehow)

Additionally, now that the kitchen should soon be refurnished (and if not, there's a stove and oven in the lounge room), I'd like to start cooking. We've been living on cold cut sandwiches and ramen for way too long now (not that I'm complaining about the ramen)

Kitchen things to bring back
+ (check) saucepan
+ (check) pot
+ (check) rice cooker
+ (check) kettle
+ (check) spatula, (check) ladles, (check) forks/spoons/knives, (check) chopsticks
+ (check) regular plates and cups
+ (check) strainers
+ (check) cutting boards
+ (check) KNIVES muahahhaa (jk o_o)
+ (check) oven mittens (and apron? dunno)
+ (check) trays, (check) waxed sheets, (check) Pan
+ (check) measuring cups
+ (check) other assorted baking containers for cuter and sweeter things :)

Food to bring back
+ (check) flour, (check) (brown, white, and confectioner) sugar, (check) eggs
+ (check) vanilla/almond extract
+ (check) butter, cream, (check) milk
+ chocolate, cocoa powder, (check) chocolate chips
+ (check) baking powder, (check) custard powder
+ mint leaves and pineapple (In grade school, I remember I made mint pineapple juice for my classmates and turns it was pretty good! Time to test it again)
+ (check) rice
+ (check) soy sauce, (check) rice vinegar, (check) sesame oil, (check) oil
+ (check) salt, (check) pepper, cinnamon, spices
+ (check) dried noodles, tomato sauce, basil, cheeses
+ (check) raw beef, (check) chicken, pork
+ (check) spinach, bok choy, green beans, other asian vegetables I don't know the names of x)
+ onion, garlic, (check) mushroom, sweet potato
+ (check) blueberries, (check) strawberries, (check) bananas, (check) apples, (check) oranges
+ (check) bread (lots!), (check) cereal, (check) orange juice
+ chicken broth (can make by boiling chicken bones and meat in hot water :))


(closes laptop to get off the train)

Recent work on the Wikitopics project:

With the goal to improve the Generate Newsworthy HIT underway, our most recent addition is a column that displays the k-sentences containing the most recent dates from the corresponding Wikipedia page since we found that Wikipedia pages are regularly updated when a notable event directly related to the page occurs. The updates do not happen for all Wikipedia pages, but for the ones that do, Turkers are able to distinguish the newsworthy articles on the spot. Here is what the 'Generate Newsworthy HIT' looks like now:

The recent changes are in gold (Missing sentences for positive and negative controls)

The first step towards generating the k-sentences containing the most recent dates was to understand Byung Gyu's pick_recent_xml.py script. After installing a few python modules and rearranging data:


This script outputs the sentence containing the most recent date: what we want is to change the script to output the k-most recent.

Error (start)
I actually had a misunderstanding with the instructions, so what I had originally done was output the sentence with the most recent date in addition to the k-surrounding sentences (oops sorry Chris!) Here's a peek into that. >.>

Outputting the line number and the sentences

Here's how that script worked

Error (finished)

Okay! SO you can ignore everything in that section. :D Here's how I extracted the k-sentences containing the most recent dates.


blue: confirms the proper format to run the script
pink: sets the paths and prepares iteration over multiple files
gold: initializes variables containing sentences with dates
orange: writes the the k-sentences containing the most recent dates to the variable 'result'
purple: writes 'result' to a file called [ARTICLE].sentences and closes the file

Directory where the files are stored

Once pick_recent_xml2.py runs through the generate_newsworthy.sh shell script, we also modify generate_newsworthy.pl to read the corresponding file to write the sentences containing recent dates to the .csv file.

Works for just a few articles

Works for all articles
 
Side note: generate_newsworthy.sh takes 40 minutes to run o_o ... we'll have to see if we can fix that

Here's another run of the graded-wikitopics.py script now that we have a few more submissions from Turkers:

Turkers who failed the evaluation

Shows the Approve/Reject decisions

With the recent date sentences extracted for the sentences needing labeling, here is my progress so far, which includes the next steps. (Chris and a few other researchers will be leaving for Oregon for the next two weeks, so we created a huge list of possible things to do)

Todo-List
+ Complete Generate Newsworthy HIT
   - (check) combine the 'Google News' and 'Recent sentences' column
   - (check) change the width of the lower table to 1000px instead of 800px
   - (check) change the width of the last two columns to 300px each
   - generate the recent date sentences for the positive and negative controls
     - changed get_positives_article.py script to print the date of the article as well
   - create bullet points for every recent date sentence extracted
   - add google news link at the bottom (so that there is no ambiguity) instead of linking the entire recent date sentences
   - go back to just one column of drop-downs
   - instead of random articles on HIT, make HIT display articles from clusters (email BA)
   - sentences HIT (Wikipedia interface, highlight/click sentences to tell why current)
+ manage DropBox for all the previous HIT batches (because Amazon is deleting them after a certain amount of days!!)
+ JQuery Cookies
   - cookie to automatically fill out the 'Age, Location' items
   - cookie to collapse the instructions if done once
+ create a third parallel file with citations -> name, date, link citation (wpextractor parses xml/wikimarkup) (interesting sentences with references to articles)
    - wget to get the link citation, 'beautiful soup' pulls out the text from the html (python), and you would run nltk to sentence split() -> serif on the results (marks the date + coreference solutions, markup names of people and organizations and generates parse trees)

Miscellaneous
+ (check) Download DropBox and accept Chris' past MTurk files
  - For some reason I happened upon a case of the 'Malware Protection' virus right after this .. o_o All my windows closed, and tray popups were flying onto the screen like crazy. Of course, a window of the 'System Scan' popped up, so I tried to access the internet, and then realized that the virus (it's called a rogue I believe) would not let me open any other applications besides itself - this was also the case even after restarting. So after restarting in safe mode for the first time in a thousand years (really, I've never used it before so I gave it a shot), the virus surprisingly wasn't making any active attacks. I ran Malewarebytes' Anti-Malware and Spy++ ASAP and flushed it out of the system - everything's perfect now! Best free software ever.
    I looked on the internet to see if downloading DropBox caused this, but it doesn't seem like there's a connection - DropBox should be completely safe. It's weird ... I'll have to run system scans more often now - you should go run one now (and download Malewarebyte's Anti-Malware/Spy++ if you haven't already. I swear they look fishy, but they're on your side. :))

Python
+ variable = [{FORMAT} for {EVERY_ELEMENT} in {THIS_SET} {CONDITIONS}] (list comprehension, a quick way to write lists)
+ dict({LIST}) (creates a python dictionary from the list inside)
+ utils.convert_date({STRING}) (converts string that represents a date to a datetime object)
+ for i, a enumerate({LIST}) (i stands for the index and a stands for {LIST}[i])
+ for a, b zip({LIST_A}, {LIST_B}) (iterates over two lists in parallel)
+ for i, a, b enumerate(zip({LIST_A}, {LIST_B})) (i stands for the index, a stands for {LIST_A}[i], and b stands for {LIST_B}[i])
   + supposedly faster way: for i, a, b izip(count(), {LIST_A}, {LIST_B})
      
   from itertools import izip, count
   alist = ['a1', 'a2', 'a3']
   blist = ['b1', 'b2', 'b3']

   for i, a, b in izip(count(), alist, blist):
      print i, a, b
   ------------------------------------------
   >>> def foo():
   ...  for i, x, y in izip(count(), a, b):
   ...   pass
   ...
   >>> def bar():
   ...  for i, (x, y) in enumerate(zip(a, b)):
   ...   pass
   ...
   >>> delta(foo)
   0.0213768482208
   >>> delta(bar)
   0.180979013443 
   (source)  


+ lambda (creating anonymous functions (not bound to a name))
+ min({LIST}, key={ARBITRARY_FUNCTION}) (finding minimum element of dictionary, where key determines how the minimum is found)
+ {LIST}.remove({ELEMENT}) (removes an element from a list)

Perl
+ counter++; (just like Java, has '++' trick and needs a semicolon)

SERIF
+ marks the date + coreference solutions (meaning that SERIF can match pronouns to their actual subjects, superscript references ...)
+ markup names of people and organizations and generates parse trees 

History behind the 'Hello World' tradition (from Wikipedia)
The first known instance of the usage of the words "hello" and "world" together in computer literature occurred earlier, in Kernighan's 1972 Tutorial Introduction to the Language B,[1] with the following code:
main( ) {
  extrn a, b, c;
  putchar(a); putchar(b); putchar(c); putchar('!*n');
}
a 'hell';
b 'o, w';
c 'orld';
 

Monday, June 6, 2011

"Grades are back"

Now that the Generate Newsworthy HITs have been released, our main objective is to code an evaluation script to decide whether to approve or reject a Turker's submission (it's also disconcerting to see that not many Turkers are interested in these HITs. We might need to figure out how to address that).

Chris and I had written a very similar script back in Winter during an event called mini-SCALE where all the researchers were brought to one conference room with the common purpose of making progress on their projects and presenting it at the end of the week-long event. My focus was on the Haitian-English Anonymization HIT, in which the task was to anonymize (cross out phone numbers, names, and other personal information) messages that were sent for aid during the Haiti Earthquake. The evaluation script for this specific HIT would basically read in a .csv file downloaded from MTurk, parse (analyze text) the answers, and then write another .csv file with the Approve and Reject columns filled out (an x for 'Yes, this Turker did a great job - we'll accept and pay for the submitted work' and a message for 'Sorry, this Turker did not submit quality work).


Similarly, the script now, called grading-wikitopics.py (link here), is coded to fill out the Approve and Reject columns for the 'Generate Newsworthy HIT.' You can see the output when run as follows:


.csv file with HITS that I filled out :D

Chris recommended that I do some of my own HITs to collect data for the grading-wikitopics.py since we want to know where to set the threshold percentages for accepting or rejecting a Turker's HIT. In other words, if a Turker's submission is x% blank, do we reject it or accept it; if a Turker's submission has some of the control (questions that we included that we know the answers to) questions wrong, how many can they get wrong before we reject their submission? We allow leeway since not all Turkers will submit perfect submissions and not all perfect submissions are needed for data - we can very well manage with submissions that have missing fields. Of course, we try to constrict the collected data to be as accurately congregated as possible, so in between accuracy and quantity is what we are shooting for.

It was also very interesting to be in the position of doing the HITs because it gave me insight on how I could improve the HIT design and instructions. To have both perspectives on the Generate Newsworthy HIT is a great advantage for me since I gain a stronger understanding of how to communicate my goals and minimize and ambiguity or misunderstandings. These were some of the updates I would like to include to the most recent HIT:

     1. Tell Turkers to follow these exact instructions:
         a. Google the topic through both the Web tab and News tab
         b. Look for any news articles around ${date} that mention the topic, and select options as follows
         c. If few or no articles appear on the topic, then you can regard it as a non-newsworthy topic
     2. Figure out how to make the HIT more appealing (perhaps more concise instructions will do the job)
     3. Possibly include a segment about why we want to label these topics as newsworthy or not - Turkers might be more interested if we do.

After a quick push to the git repository, I'm off to do some more HITs for the grading-wikitopics.py script.

Exploring New Things

This weekend, I found a few pictures on my camera when Wayne and I made ramen one day during final's week. We were both starving and remembered that his dad shipped over some mini-ramen packages. That's when Wayne says to just throw them all into a pot. (Lol he just saw me writing this post and said "people will think we're retarded, no one makes ramen like that.") Ramen's supposedly 'grad-student' food *shrugs*. It's yummy, and it's what I eat a lot now. :3




Wayne put in a TON of black pepper

I spent some time this Sunday learning about one of the courses I'm taking next fall semester: Introduction to Video Game Design (600.255) taught by Peter H. Fröhlich (He's just plain awesome; I also had him for Intermediate Programming (600.120), an introduction to C/C++ spring semester 2011) The focus of this course to create a semester-long project in python game development by utilizing Pygame in teams of 3-4. Last year, the objective was to design a 2D, side-scrolling, level-based game in the tradition of Super Mario Bros; the year before that, the students were allowed to create anything, and I hope he will give us the same option this semester - I just sent him a quick email about that so hopefully I'll know soon. :) In addition to the project, teams are asked to keep a blog up and I still found a few up and running! I'd like to go through these as I dabble in Pygame this summer. Here are the basic steps I took to get introduced to Pygame:

1. Download Pygame - pygame-1.9.1.win32-py2.6.msi 3MB (hope it works well on Windows!)
2. Run the download to install
3. Check out Pygame installed on the Linux computers ugrad5.cs.jhu.edu using (to confirm Pygame is on our ugrad-machines too :))
python -m pygame.docs.__main__

Introduction screen - by the way you *click* to make the screen go down
4. First Pygame program outlined in introduction screen (learning by doing):

#importing modules
import sys, pygame

#initializing the imported modules

pygame.init()

#sets variables

size = width, height = 320, 240
speed = [1, 1]
black = 0, 0, 0

#creates a graphical window

screen = pygame.display.set_mode(size)

#returns the ball image as a 'Surface'

ball = pygame.image.load("ball.gif")
#creates a variable of a rectangular area to perform animation

ballrect = ball.get_rect()

while True:
        #tracking GUI (Graphical User Interface) events

        for event in pygame.event.get():
                #if we quit the window (press the red x button)

                if event.type == pygame.QUIT: sys.exit()

        #moving the ball

        ballrect = ballrect.move(speed)
        if ballrect.left < 0 or ballrect.right > width:
                speed[0] = -speed[0]
        if ballrect.top < 0 or ballrect.bottom > height:
                speed[1] = speed[1]

        #erasing the screen by filling with a black color
        #otherwise, will leave a trail-like effect

        screen.fill(black)
        #redraws the ball to the position

        screen.blit(ball, ballrect)
        #to show everything we've done onto the screen

        pygame.display.flip()

Output (bounced really quickly!)

I also finished Google FUSE's 5-step todo list including joining the Google FUSE group and completing a quick CS skills spreadsheet. (Some quick peeks) 




I'll be going to their headquarters in New York City from July 18th-22nd for a retreat-style program to network with other aspiring computer science students and get tips on the career and research fields. They even have a day countdown on their website heh ^_^.


Their focus is geared towards underrepresented students, and I think that's a noble stride to attracting more students into computer science. It's analogous to a girl feeling more comfortable joining a group if there were more girls just as a guy would feel more comfortable joining a group with more guys. It will be interesting seeing how they address this topic! One of the first things they did was ask us how we felt about it. I went to dig up some of my answers for their application a few months back.

1. Tell us about an experience that inspired your interest in the computer science field, or a specific aspect of it. Any inspiration is fair game!
I had been long interested in computer science since I began high school, always wanting to be involved in the constantly evolving technological world, and finally took a shot at it my senior year of high school by taking an online course. Let’s just say that I could not get enough of it. I was thrilled by the all-encompassing aspect of computer science; the combination of logical reasoning from mathematics and critical thinking skills from reading and writing that was computer science offered me a novel interest and perspective to learning. I was determined to continue my studies in the computer science field.
My notable achievements in the introductory online course paved way to multiple scholarships in advanced courses in Scheme and Java programming languages, allowing me to succeed in the Collegeboard AP Exam that same year. Needless to say, I knew I wanted to study computer science in college as my fascination in the field grew stronger. I came into college with a lasting passion that lead me to taking courses well beyond my years in multiple areas of computer science and especially in artificial intelligence.
Computer science allowed me to design and solve problems that could be applied to an expansive range of subjects one would never imagine had any relation or connection to such as software in finance and electronic health records in medicine. I soon began to visualize approaches to solving global-size problems through computer science: from reducing human error in diagnosing and prescribing patients to aiding search-and-rescue teams during natural disasters to breaking down language barriers through advanced electronic translation to even increasing levels of critical thinking and reasoning in students. I found computer science as an answer to our future, and there was no doubt that I wanted to be a part of the effort. I am involved in computer science today for a better tomorrow.

2. This event is being created to connect underrepresented students in computer science with one another. Why is this important to you?
Last week, I went to a talk by Hanna Wallach, a research professor at University of Massachusetts Amherst, on women in open source software. When she asked the undergraduates what percentage of women we thought were involved in open source, none of us were without gaping mouths as we heard her say “only 1.5% of open source contributors were women from the FLOSSPOLS survey conducted in 2006.” But it wasn’t the statistics that left the lasting impression on us as we exited the lecture hall, but her advocate for increasing gender diversity in open source development. We left with eager eyes to bring diversity to not only women and not only in open source development, but also all backgrounds of race, color, gender, and ancestry in all divisions of computer science.
Diversity brings the spawning of creative ideas and solutions to problems through combining the multiple backgrounds of contributors in a team. I believe that it is not specifically race or gender that produces this creativity, but the unique experiences of each person that offer them their own perspectives to tackling challenges that when brought together, allow the team as a whole to approach the situation at hand in a wide variety of angles. In application, by bringing together students with such unique qualities, we are each extending our own horizons by learning how other people of very different backgrounds see the same objects or situations in life. We become better equipped to solve problems by having a worldly perspective and an open mind, and in effect, we become more confident as computer scientists to defy limitations and follow our passions, and more encouraged to teach others of our experiences. It is for this reason that Google FUSE is not just an opportunity for underrepresented students to learn about computer science, but also a chance to learn about each other to share knowledge, wisdom, and experiences as students of unique backgrounds.

Saturday, June 4, 2011

COMPLETE AUTOMATION

My sister's pretty awesome. She's a smart girl, and she's not afraid to say what she thinks or believes. She always lights up the place with her weirdness and laughs, and I always have a blast doing something new or remember the good old times whenever I'm with her. We'll frequently recall old TV shows that we used to get a kick out of watching like Courage the Cowardly Dog or Flapjack and then naturally burst out into role-play. Sometimes it feels like we're part of the same person; we can finish each other's sentences and know what the other is thinking before they say it. Sometimes it's hard to be away from Julie, and it's always a treat to talk with her on the phone or visit home again. Mom's been telling me how she's doing so much better in school now, staying after class to ask her teachers questions before the upcoming finals, and studying until she's confident of the material and concepts. I'm extremely proud of her, and it's sort of weird to see her grow up. I'm rooting for her to be the artist and game designer she dreams of becoming. ^_^

 <.jpg picture of her artwork>

Today was a big success! We posted our Generate Newsworthy HIT (we're doing a pilot study at the moment so we're trying to get feedback on our HIT design and instructions. LET US COLLECT YOUR INFO! Come do our HITs :D) on Amazon Mechanical Turk just in time for the weekend. It took a lot of debugging, but I'm happy that Chris and I stuck it through to finally get this HIT up and running.

Moment it went up

Here's a quick run-down of the steps taken to get where we are now as well an assessment of the problems we had.

1. (check) Incorporate the positive and negative control outputs into generating the .csv file (an excel spreadsheet where each column is a variable, and we upload it onto MTurk to work with our HIT template)
2. (check) Fix any bugs of the whole spreadsheet including (I sent this to Chris last night)
      a. (check) The script prints outside of the columns <-- this should be a quick fix, the for loop is probably iterating more than needed

          The problem was that the loop was iterating twice, so it printed the controls twice, hence the two extra columns. After fixing that boundary mistake, the extra printing was fixed.

 
      b.
(check) The script only calls one article for the positive control and one article for the negative control for all 100 <-- I can fix this by initially generating more control articles and put them into a directory, and then use a for loop to iterate over each one
           We changed the format of the positive and negative controls to tab-separated lines where each line represents an article. The order of the properties of the article is as follows: title, trending score (I'm not too sure what this is, but we don't really use it o_O), the first sentence of its Wikipedia page, and the first section of its Wikipedia page. 
           This allowed us to the read the file into an array and utilize separate counters (i.e. $positive_counter = 0) for each control array that would reset to 0 once the counter is-equal-to or exceeds the size of the array (well, it can ever exceed the size of the array, but I guess we put it in for good measure. :))

Showing the one article and its tab separations (vi shows on multiple lines but everything in the outer pink is just one line)

      c. The csv files had bugs from the earlier, original script (I attached the old csv file we used), in that sometimes it doesn't print the lead_section variable, so the columns get messed up. I'm not sure how this error came to be but I'm guessing that it probably cam from within the .pl script
           What happened was that some of the files we were trying to read in simply did not exist! So the printing statement was skipped and thus, those lines of the .csv file were offset. We made it such that the loops would skip over any of the articles that did not have the necessary existing files. This is what that part of the code looks like:


3. (check) Check for any bugs in the actual HIT template (the JavaScript/CSS/HTML I wrote to make the HIT look like what it looks like)
           We're good to go! We added in some extra features to the HIT including a separate column asking Turkers to indicate when the article was newsworthy; so they have two tasks: tell us, is this article related to some newsworthy event? and two, when was this article newsworthy? We also made it so that the article could be clicked to its respective Wikipedia page. 

Updated 'Generate Newsworthy HIT'

A look into the options for the second column

 A look into the csv generation generation :o
(1 2)
(3 4)
 
     a. Spend 45-60mins researching geolocation for the Turkers
            Turns out it really wasn't needed, so we didn't spend time on this. Maybe I can on the weekend. :P

-Random picture to separate different content- 

Another big thing that happened today was that Omar F. Zaidan, one of Jason's and Chris' Ph.D. students, gave me a rundown of Amazon's MTurk API (so much to MTurk!). Basically what you can do with the API is completely automate the processes of uploading data, publish HITs, paying workers - anything you can think of that you can do with the web interface. In other words, instead of going to the website and clicking on the actual buttons, you can run a command-line program to do everything for you. Of course, you have to program the features you want as well as the decision processes using MTurk's API (which is in Java), and Omar showed me all the code he wrote (located here) that I could take to use for the 'Generate Newsworthy HIT.' Apparently, once everything's set to go, a 'Generate Newsworthy HIT' will be created and released daily along with the 1000 top Wikipedia articles of the day, and something-related-with-cron-job will do this job for us at a set time every day. Chris told me it'll cost $50 per day, but he said to let him take care of the financial side of things. :)

MTurk Notes
+ RequesterServiceRaw and ReqesterService (which extends RequesterServiceRaw) are the two classes you'll probably use the most
+ Anything on MTurk that you can imagine to be a class (i.e.. a HIT, a Turker) is probably a class
+ Omar allowed us to have many, many options when running the Java code (such as 'don't approve or reject anything if set to false')
+ His code is relatively reusable and extensible, and I might not need to make any changes when using it since uploading the data and publishing the HIT (these sort of steps) are the same for every kind of HIT.
   - the layout follows: write custom script to generate file to upload + write the HIT template -> pass to Omar's Java code -> write a script to decode and analyze the data -> pass to Omar's Java code
+ There are a few things you can do with the MTurk API that you cannot do with the regular website interface, such as change what the HIT looks like once it has already been published
+ Other related links: 
    - "There's also a tool kit for interaction with Mechanical Turk, called TurKit, which you might consider researching as well:"  http://groups.csail.mit.edu/uid/turkit/ (from Chris)
    -  And here's the javdoc for the Java API: http://people.csail.mit.edu/glittle/MTurkJavaAPI/ (from Omar) 

Todo List
+ people are telling me to keep away from Perl; the only way to beat the enemy, is to learn about it!
+ get feedback from the Generate Newsworthy HIT and improve upon it
+ create a script to approve/reject the submissions (pretty neat, first automation thing on MTurk that I learn about! I worked on something similar with Chris last winter, so I'll show the previous script written)

Ah there's so much more to write about! I gotta wait until tomorrow. :)

Thursday, June 2, 2011

Good food, a soft pillow, and Portal 2

Last Friday my parents picked Wayne and me up from Johns Hopkins to go back home in Pennsylvania for the Memorial Day weekend. We arrived to a home-cooked meal, mewing Kitty and Kitten (my two cats), and as always, my sister who was on the computer playing Vindictus. And since Wayne and I had been sleeping on the floor for the past week at an empty, temporary apartment, my old bed was absolute heaven. What can I say? It's strange how emotions and experiences are relative to one another - I'm sure that when I was in high school, I could have never predicted what it was like to be away from home. But now that it's already been a full year, it's safe to say that I miss my family like no one else, and that they're the ones I'm working hard for!

Before my parents sent us back to Johns Hopkins, we made a quick trip to the King of Prussia Mall and Costco for clothes and food. I'll have to wait until next time to cook because of apartment renovations, but you betcha I'm going to learn. :) Here's what we bought!

Clothes
<.jpg of the pictures of clothes when I get my camera>

Food
1 bag of oranges
1 bundle of bananas
2 french baguettes
1 jar of strawberry jam
1 jar of peanut butter
1 roll of aluminum foil
1 jar of spicy tofu
1 jar of spicy, pickled green beans
1 case of mandarin oranges cups
1 loaf of whole wheat bread
1 case of yoghurt
2 heads of lettuce
1 case of canned fruit
2 bottles of mango juice
1 package of salsa additions
1 cup of hot spiced olives
1 case of blueberries
1 cup of sliced cucumbers
1 package of cold cut meat
1 package of frozen sweet potato fries
4 tv dinners
1 carton of milk
4 cooked sausages

When we got back, Wayne and I finished playing Portal 2! It's really an amazing game, and I was surprised to find it having an adventure element to it. For sure there's an initial learning curve, but it's not long before using portals feels natural! I'm hooked on the ending song now, and definitely going to back to play the original Portal. I think I kind of forgot what it's like to play games again after I quit Junior year of high school. I've still been buying the games, but I could still get into them like I used to while having many other real-world responsibilities in mind. I'm glad Portal 2 changed that for me, especially since I think the best games have the ability to evoke emotion as Portal 2 did - I'm sure it will be a blast getting back into gaming. That being said, my sister, Wayne and I are eagerly waiting the release of Dragon Nest BETA. ;)


Back to Johns Hopkins University

The big goal of this week is to get our 'Generate Newsworthy HIT' out on Amazon Mechanical Turk. Chris gave me this list of things to do:




Before we could get the HIT out in public though, there were still a few things I had to take care of:

Pre-release
1. Incorporate the positive and negative control outputs into generating the .csv file (an excel spreadsheet where each column is a variable, and we upload it onto MTurk to work with our HIT template)
2. Fix any bugs of the whole spreadsheet including (I sent this to Chris last night)
      a. The script prints outside of the columns <-- this should be a quick fix, the for loop is probably iterating more than needed
      b. The script only calls one article for the positive control and one article for the negative control for all 100 <-- I can fix this by initially generating more control articles and put them into a directory, and then use a for loop to iterate over each one
      c. The csv files had bugs from the earlier, original script (I attached the old csv file we used), in that sometimes it doesn't print the lead_section variable, so the columns get messed up. I'm not sure how this error came to be but I'm guessing that it probably cam from within the .pl script

3. Check for any bugs in the actual HIT template (the JavaScript/CSS/HTML I wrote to make the HIT look like what it looks like)
     a. Spend 45-60mins researching geolocation for the Turkers

Getting the sentence/section extractor for Wikipedia articles working
I ran into some trouble Tuesday morning figuring out Python modules (packs of code that you can conveniently use rather than writing your own functions, because some of them are very advanced) and how Byung Gyu's programs relied on them. Questions that came up included:

1. How do you install Python modules if you aren't logged into an administrator account?
2. Is it more efficient to install your own Python modules or utilize someone else's? Is either necessary?
3. What is the PYTHONPATH?
4. What does it mean to write the line 'import ...' at the top of your code?

Unfound modules: wpTextExtractor, mwlib, pkg_resource, _uscan, splitting

-------------------------------------------------------------------------------------------
[Neat Tricks 1] I began by installing modules as needed, and learned quite a few Linux commands along the way as I figured there must have been a faster way than just tediuos c/pying files/fumbling here and there:

wget [url] (downloads the file into the current directory)
find [path] | grep [directory] (finds a specific file or [directory] based on the [path])

[Neat Tricks 2] Additionally, I discovered about the tilde in the context of paths (such as ~/wikitopics/src/):

~ (stands for the $HOME environment variable; /home/yourusername)

From StackOverFlow.com:
"Unless you're writing a shell script or using some other language that knows to substitute the value of $HOME for ~, tildes in file paths have no special meaning and will be treated as any other non-special character."
Another good advantage to tilde's is that if the home directory changes, the path does not need to change because the '~' tilde character already compensates for that. Planning to research more on this.

[Neat Tricks 3] The last little thing that I forgot to mention (that Chris taught me on the first day), is that pressing 'tab' finishes off a file/directory name. For instance, if you've typed:

emacs wiki-

And the full filename is wiki-02.1-mylib (and no other names have 'wiki-' has a prefix), then pressing tab will finish it for you! Meh I used to write it out completely. :P I'm really getting the hang of it now as well as CTRL+e (goes to the end of the line), CTRL+a (goes to the beginning of the line) and CTRL+k (cuts everything after on the line). They're little things that make utilizing the Linux environment much easier.
-------------------------------------------------------------------------------------------

Then half-way through, instead of installing everything, Chris showed me that we could simply utilize Byung Gyu's installed modules rather than installing them ourselves. We simply link to the directories using 'ln -s [path]', and also set the PYTHONPATH environment variable by typing export PYTHONPATH=/[path]:[path], where the colons separate paths that Python searches.

This is the message that Chris sent me with more details on setting PYTHONPATH:

You can set PYTHONPATH in your ".bash" file which is loaded every time you log in (assuming you are using bash as your default shell instead of csh or something).

Here's how you can set it to include NLTK

export PYTHONPATH="/usr/local/bin/python:/usr/local/lib/python2.5/site-packages/nltk-2.0b7-py2.5.egg/"

You can also point to specific modules in your own directory space or in ByungGyu's by adding a colon and then the path.  For instance:

export PYTHONPATH="/usr/local/bin/python:/usr/local/lib/python2.5/site-packages/nltk-2.0b7-py2.5.egg/:/home/hltcoe/bahn/wikipydia"


I know, I know. It was a pretty forwards and backwards time.

The overall lesson that we learned from all this mumbo jumbo was that Python looks for modules according to the PYTHONPATH, which can point to multiple paths. Using this, we can utilize Byung Gyu's installed modules rather than installing our own and figuring out the write-permissions that come along with a non-adminstrator account. By navigating the PYTHONPATH, we were able to make the script sucessfully run with the necessary Python modules, and this was the output:


It basically gets sentences from respective Wikipedia pages of the randomly generated articles from the negative control worked on last Friday. Woot! Just to have it output something distinguishable is a remarkable feeling. Chris was very patient with me, and I was glad he took the time to help me work through this situation. I definitely got a hold of many Python fundamentals, and the next goal is to upload this HIT - I'm working to make it soon!

Friday, May 27, 2011

Catching Devilish Scammers on MTurk

The past two days I've been working on creating positive and negative controls for the 'Generate Newsworthy HIT'. These are important in case we happen upon cheaters who randomly choose options for the tasks, similar to proctors for the SATs. At the same time, it will not punish the good Turkers who work hard on our HITs. :)

Generate Newsworthy HIT
The goal of this HIT is to ask Turkers to help us decide whether or not our top 1000 wikipedia pages (based off of pageviews) are truly newsworthy with regards to if it was current in the past or present. Sometimes, random articles make it into our top 1000 articles as we are only relying on page views and relatively simple algorithms at the moment. Automating this check will probably be one of the more difficult parts of the project, so to get some more information on how 'newsworthy' our articles are currently, we submit this HIT to MTurk.

Chris sent me new introductions for the HIT. Pretty!




Positive Controls
The overall idea of the positive controls is that we collect the articles Wikipedia puts on their current news webpage each day. We then perform an intersection between Wikipedia's current news and our top 1000 articles [over a period of days so may be 2000-15000+] by checking if any of Wikipedia's current news articles match our generated top 1000 articles - such articles are the intersection, and we assume these articles to be positively current, so Turkers should always choose 'Yes, the article is current' or 'Yes, the article was current'. We will include one of these intersection articles somewhere within the 12 articles (we've only setup 10 currently, but will soon add in 12) we give the Turkers to label for newsworthiness.

This is the generated output of the generate_positive.py script. The blocks of articles appear as follows:

1. Articles pulled from Wikipedia's Current News Portal (Portal!)
2. Congregated articles that we generated by page views over a period of time
3. Intersecting articles mentioned both in the Wikipedia Current News Portal and our top congregated articles


Negative Controls
The second quality control that we have for the HIT is the negative control, which are articles that should be labeled as 'No, the article is not current'. The way we went about generating the negative control is by simply taking random articles from Wikipedia and checking to make sure that they're not in our top 1000 articles [over a period of days] (and possibly also not mentioned in Wikipedia's Current News Portal - thinking about adding this). This way, we'll have a collection of articles that are surely not current! Along with the positive control articles, we will include the negative control articles somewhere within the 12 articles given to Turkers. This dual-combo of controls sets a quality standard for Turker submissions so that we can better decide which submissions to consider.

This is the generated output of the generate_negative.py script. The blocks of articles appear as follows:

1. Articles randomly generated from Wikipedia
2. Congregated articles that we generated by page views over a period of time
3.(Set Difference) Randomly generated articles in step 1 that are not in our top congregated articles




I was glad to hear that both Chris and Byung Gyu were proud to see me finish off these controls. ^^ The project seems to be making great progress, and I imagine that we'll soon be able to release the HIT live for Turkers to do. The plan is to automate the generate_positive.py and generate_negative.py to distinguish two articles in which we most probably know the answer to, and release the HIT with the controls and 10 unknown articles we want labeled for newsworthiness. This will be a daily HIT for Turkers to complete! I wonder if we can even automate distinguishing newsworthiness without MTurk in the future!

MediaWiki
You can use MediaWiki software to create wiki-pages (API), and they have some interesting ways to write the articles on Wikipedia without needing to know HTML. For instance (pulled from Wikipedia - so meta :P):

MediaWiki syntax Equivalent HTML Rendered output
"Take some more [[tea]]," the March Hare said to Alice, very earnestly.

"I've had nothing yet," Alice replied in an offended tone: "so I can't take more."

"You mean you can't take ''less''," said the Hatter: "it's '''very''' easy to take ''more'' than nothing."
<p>"Take some more <a href="/wiki/Tea" title="Tea">tea</a> ," the March Hare said to Alice, very earnestly.</p>
<p>"I've had nothing yet," Alice replied in an offended tone: "so I can't take more."</p>

<p>"You mean you can't take <i>less</i>," said the Hatter: "it's <b>very</b> easy to take <i>more</i> than nothing."</p>
"Take some more tea," the March Hare said to Alice, very earnestly. "I've had nothing yet," Alice replied in an offended tone: "so I can't take more."
"You mean you can't take less," said the Hatter: "it's very easy to take more than nothing."

Python
+ import datetime (datetime Python module for the purpose of working with the date and the time)
   + date = datetime.date(2011, 05, 11) (creates a date object)
+ import simplejson | import json as simplejson (using the JSON format)
+ path = os.environ["HOME"] (environment variables in Python)
+ u'The_Pirate_Bay' (unicode strings that are different from regular strings! You can't get rid of the starting u through string[-2:]
+ var = [string].encode("utf-8") (the right way to convert unicode strings to regular strings in UTF-8)

How I broke down problems
+ Really great to figure things out, learned a whole lot of stuff as I was making progress through it. One thing I realized was that it's important to remember that there exists many types of objects and concepts even though they may appear similar to one another. By keeping an open mind, you have do a direction to solving those odd bugs/problem.

Todo List
+ generate the first section and first sentence of the randomly chosen negative controls
+ geolocation services for the 'Generate Newsworthy HIT' (45-60mins)

Wednesday, May 25, 2011

Fresh Start

I've been talking with my parents a lot lately about school and our ambitions as a whole to be successful and happy. I haven't had a chance to do that and just think about the future in the while because of the time put into this semester's courses, but it's a lucky feeling to have been able to since summer started. My boyfriend and I even walked for an hour and a half to Inner Harbor Baltimore - I love things like this. I DID come out with blisters between my toes (because someone wore flipflops for the trip ...), but I'd trade that any day for an amazing trip like that. It's only been a few days into summer but I feel like so much has happened already, and I'm constantly learning everyday about myself and natural language processing at my research lab.

These are all the tasks I completed yesterday:

Todo List
+ (check) learn about ssh/secure shell
+ (not yet!) complete 'Generate Newsworthy HIT'
   (check)     + get a more solid understanding of JavaScript/CSS/HTML
+ (check) correct escaped string in newsworthy.csv
+ (check) getting acquainted with GitHub
+ (check) start learing Perl

CSS/HTML
<!-- COMMENT --> (how to comment)

JavaScript
How to Show/Hide text
1. create a controlling link with <a href="javascript:function(id);">Click</a>
2. give elements an id <div id = ...
3. javascript function: getElementsByTagName("div")
4. use .style method to get style object of element if (item.style.display = 'block' ...
(I followed this tutorial: http://webdesign.about.com/od/dhtml/a/aa101507.htm)

Linux Commands
+ ln -s [path] (to access directories of another user with all the read/write permissions intact)
+ scp [file] username@domain.name:directory (to pull files from remote machine onto another)

SSH/Secure Shell
Secure Shell is a program developed by SSH Communications Security Ltd. that allow users to log into other computers over a network. They use public key crptyography to match a public key and a private key to allow users into the system (and might also prompt for a password). Through this, I can login to another computer through my laptop, store files there, move them to my own, and perform any other edits as I want.

Generate Newsworthy HIT

+ added paragraph that Chris wrote, fixed up little errors in value options
+ fixed the tables (much more quickly than before). The time I spent consolidating some CSS concepts (tables) really helped :)
+ changed document to JavaScript generated HIT template so that could be used to unescape string AND it's much, much neater

How to approach problems

+ Sometimes, it's a good idea to make a fresh start. Perhaps you've got a bunch of code that has a bug in it somewhere, but you just can't figure it out. Opt Pulling up an older version or starting from scratch if you feel like debugging is taking way too long. I frequently do this for bugs that are right in front of my nose but due to familiarity are overlooked.
+ Good idea to design your code beforehand if it has many things going on at once. I had to rewrite the Generate Newsworthy HIT, and I felt that I could have been more efficient if I had planned out what needed to be done beforehand. All in all, I did learn much more about CSS/HTML/HIT design in general, so the 1st draft created a template for me to write even better code
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

These are the tasks Chris sat down and figured out with me today



Perl
+ $ (single, like an integer) metacharacter
+ @ (multiple, like an array) metacharacter
+ substr([string], [starting character], [length of substring])
+ open FILE "<$path" (reading a file)
+ <FILE> (read one line at a time of file)
  - (tutorial at http://www.perlfect.com/articles/perlfile.shtml)

Yay I've learned some perl and fixed the generate_newsworthy.pl code to be able to generate the HIT with the first sentence as well. So if the Wikipedia article is "Twitter", the variable lead_sentence# will have "Twitter is a website, owned and operated by Twitter Inc., which offers a social networking and microblogging service, enabling its users to send and read messages called tweets." This is the HIT currently:

(HIT template)
  

(example HIT)


Todo List
+ make worksheets since Theresa asked me to teach Molly and Amy about Mechanical Turk

(need to add more............)