Pages

Saturday, January 14, 2012

Starting a simple HTTPServer in python

Python comes with its own web server included in the http.server library module. 

To start a web server in python:

from http.server import HTTPServer, CGIHTTPRequestHandler
port = 8080
httpd = HTTPServer((' ',port), CGIHTTPRequestHandler)
httpd.server_forever()

After starting the server when you run localhost:8080 on your browser it shows you the current directory from where the server was started. That can be changed by importing the os module.

Accessing the server on the network:

After starting the server, create a wireless network. When another computer connects to the network, the server from the first computer can be accessed using the IP address and port number. To find the IP address. 

Run the following command to find the ip address:

ifconfig

After finding the IP address of the machine where the server is hosted, using the IP address and the port number the server can be accessed on the other machine.

[IP Address]:8080


Tuesday, October 11, 2011

ai-class, ml-class and db-class


I enrolled in all three courses of Stanford which were a part of a new online initiative by them, and today when I saw the lectures and worked on the quizzes I realize how exciting the courses are. Firstly you can watch the lectures whenever you want and wherever you want + you can watch them again and again until you get the concept completely and lastly I like the concept of me choosing to take the course rather that it being thrust upon me which happens in almost all universities in India. 

There are three courses which are being offered and I have opted to take all of them and they are pretty interesting!

  1. Introduction to Artificial Intelligence (http://www.ai-class.com)
  2. Introduction to Databases (http://www.db-class.org)
  3. Machine Learning (http://www.ml-class.org)

I hope I will have a good time and will learn a lot and I am happy that some initiatives are being taken towards Online Education. I myself took up a small initiative sometime during the start of this year. Here is the link http://www.unacademy.in

Thursday, August 18, 2011

Java NoClassDefFoundError

In your Java Web project make sure you add the jar files to WEB-INF/lib and make sure that you remove the external jar files from your build path. Instead of adding them as external jar files just add them to the lib folder and save yourself the ClassDefNotFound errors which are very irritating.

Sunday, August 14, 2011

Using jQuery inline form labels

At first I thought that I would be requiring jQuery to use the inline labeling of the forms but then I figured out the HTML5 provides a simple way to do the same using a simple placeholder tag.

Code:
input type="text" placeholder="Streaming keywords" 

Thursday, May 26, 2011

Stemming of words: Porter Stemmer Algorithm

Searching for some libraries which could transform words to their root forms. So that when I encounter words like filling, filled, fill, they are all treated as the same. 


Definition of stemming: stemming is the process for reducing inflected (or sometimes derived) words to their stem, base or root form – generally a written word form


A stemmer for English, for example, should identify the string "cats" (and possibly "catlike", "catty" etc.) as based on the root "cat", and "stemmer", "stemming", "stemmed" as based on "stem". A stemming algorithm reduces the words "fishing", "fished", "fish", and "fisher" to the root word, "fish".


Something about Porter Stemmer Algorithm: 
A later stemmer was written by Martin Porter and was published in the July 1980 issue of the journal Program. This stemmer was very widely used and became the de-facto standard algorithm used for English stemming. Dr. Porter received the Tony Kent Strix award in 2000 for his work on stemming and information retrieval.


Martin Porter released an official free-software implementation of the algorithm.





public class ASimpleStemmer {

public static void main(String[] args) {
Stemmer s = new Stemmer(); // See the official implementation, link given above.
s.add("abominable".toCharArray(), 10);
s.stem();
System.out.println(s.toString()); //Output: abomin

s.add("abominate".toCharArray(), 9);
s.stem();
System.out.println(s.toString()); //Output: abomin
}
}