Pages

Showing posts with label python. Show all posts
Showing posts with label python. Show all posts

Tuesday, 22 May 2012

Visualizing EC2

I hacked up a small application over the weekend to visualize EC2 instances at one place. Python/boto/web.py does the work of retrieving the data and JS (GraphDracula) displays it.

The need for this rose at work - where we use EC2 to host our infrastructure. The original intention behind it was an easier way to view things like
  • Which availability zone has which instances
  • Open ports between security groups
  • Which security group has which instances
  • and so on
Not all of this has been done yet, but will be.
Here it is on Github - https://github.com/talonx/ec2viz

Thursday, 21 July 2011

Some string matching

This puzzle from Facebook's engineering puzzles page is a good introduction to string matching.
A solution is possible using an algorithm called Levenshtein distance.

Let's take the example on the puzzle page -
TIHS SENTENTCNES ISS NOUT VARRRY GOUD

It's a munged up version of
THIS SENTENCE IS NOT VERY GOOD
The original problem statement involves minimizing the score (number of changes necessary) to transform each word in the munged up sentence into words that are in a predefined wordlist. It says nothing about grammatical correctness of the result.

So going by that, the score and the output sentence from my implementation are respectively, 8 and
TICS SENTENCES IDS NOT VAGARY GAUD

From the standpoint of the original problem, this solution is correct.
But not from a grammatical point of view. After some poking around, I realized it's not possible for this program to spew out the correct version of the sentence without it being aware of English grammar rules.


P.S. Without getting into grammar correction, of which I have no idea how to implement, I made a small change in the program as an experiment. The second version favours a smaller word whenever the scores for two are equal.
And the result is (Score remains the same)
TIS SENTENCES IS NOT VARY GOD