Thursday, March 27, 2014

[My projects] "jTextBrew" TextBrew implementation in JAVA


Thanks to Chris Brew we have this awesome customizable edit distance algorithm called TextBrew.
It can be used for fuzzy string matching and can be used even for shorthands and abbreviation matching. By changing a few parameters you can use it particularly for your purpose.
You can read more about TextBrew algorithm here http://www.ling.ohio-state.edu/~cbrew/795M/string-distance.html.

What I have done is to create a JAVA implementation of the modified https://github.com/relaynetwork/fuzzy-string-matching project, for my own purpose in one of my other project.
You can find jTextBrew at https://github.com/puneetsl/jtextbrew.

A few examples of the use of this library:

  1. TextBrew.compare("BRYN MAWR PIZZA II", "BR MA PI II");
    would return 52% match
  2. You can change costs using the following function:
    TextBrew.setCosts(Match, Insert, Delete, Substitute);

Why is it handy?
When combined with other fuzzy string matching algorithms taking weighted average can give really good results. I am currently using it for auto spell correction, combining it with n-gram. And this is giving really good result.

Don't forget to star this project on GitHub in case you use it. ;)

Friday, January 17, 2014

[Using code] If AAP was implemented in object oriented way


So I was wondering what if Aam Aadmi Party was implemented in Obeject Oriented way(AAP in OOP), thus I am writing here snippets of the code which I wrote in 5-10 minutes and would open source it, so that you guys can extend this effort :P.
I am starting here with class AamAadmiParty:

package indian.politics;
//Version 0.1
//Author: Puneet Singh
public class AamAadmiParty extends Congress implements Socialism, Communism, Populism, Mobocracy{

 //Created Kejriwal using singleton design pattern, can't create so honest man again
 public Kejriwal kej = Kejriwal.getInstance();
 public void getDonations(int money){
  this.putItInWebsite(money);
 }
 public void putItInWebsite(int money) {
  System.out.println(money);
 }
 
 private boolean doKhulaseAndRunAway(boolean isFormedGovernmentWithCongress)
 {
  if(!isFormedGovernmentWithCongress)
  {
   isFormedGovernmentWithCongress = this.madePeopleFoolEnough();
   return doKhulaseAndRunAway(isFormedGovernmentWithCongress);
  }
  else
  {
   return true;
  }
 }
 public void before2014()
 {
  kej.honesty();
 }
 private void after2014()
 {
  indian.politics.Congress i = null;//null as in the number if seats expected in 2014
  mergeWithCongress(i);
 }
 private void mergeWithCongress(Congress c) {
  System.out.println("We are against communal forces!!");

 }
 private boolean madePeopleFoolEnough() {
  return false;
 }
}


And the other class would be Kejriwal implemented using Singleton Pattern:

package indian.politics;

public class Kejriwal {
 private static volatile Kejriwal instance = null;

 private ()Kejriwal {
 }

 public static Kejriwal ()getInstance {
  if (instance == null) {
   synchronized (Kejriwal.class) {
    if (instance == null) {
     instance = new ();Kejriwal}}}
    
   
  
  return instance;}
 
 protected void honesty()
 {
  System.out.println("I am honest, every one else is dalal");
  honesty();//infinite until stackoverflow}}
 



You can get started with the complete source code using this link https://code.google.com/p/aapinoop
I hope you are familiar with SVN.