How to write your own spell checker ? C#.net

Hi There,
Today I wrote a readable & usable implementation of Norvig's Spell corrector.
Norvi's implementation of spell check is awesome! On his site he has link to many other implementation in various languages, including C#.

Most of the implementation are focused on minimum number of lines , so they are not readable. I have written my own implementation which you can use on your own risk.

Here is the source code (DOWNLOAD)

You can also check-out entire code using this svn command




            svn checkout https://jugad.googlecode.com/svn/trunk/C%23/SpellCheck SpellCheck




How Algorithm works?



1.Initially Algorithms builds a dictionary* data-structure of words, from a huge English text. (so algorithm does not uses dictionary# file as such). This dictionary* contains words-to-frequency-of-occurrence mapping. lets say it as nWords.



2.When you will fetch a word(lets say 'w') for spell correction,Then the algorithm builds a list of all possible words that can be formed from w by doing following operation

  1. Deletion (delete 1 character, for all possible combination)
  2. Transposition (flip 1 character, for all possible combination)
  3. Alteration (modify 1 character, for all possible combination)
  4. Insertion (insert 1 character, for all possible combination)

Lets say name of this list is 'edits' , note that all words in this list are just 1 step away from original word.
3. If edits has 1 or more words that exists in nWords, then it returns the word from nWords with maximum frequency, as a result.
4. If No words in 'edits' are present in nWords, then it creates another edits using edits to get second level word (word which are 2 step away from original input word)
5.Repeats from step-3 (or give up if your are already 2/3 steps apart from original word 'w')
Read more Here.

How To Use This code ?
To use this code instantiate class spell by passing huge-string of English text (from where it will build dictionary)
Then call function correct() to get the corrected word as result.

Note:This code is just to demonstrate the algorithm, modify constructor to build dictionary directly from file. You can also avoid calling sort operation in function 'correct'. Thoroughly understand the code before using it. Notify me if you find any critical problem.


*dictionary data-structure of programming
#real dictionary

How to get Tabs (navigation bar) on new blogger templates

Hi There,
First of all you might have seen that blogger has brought-up new Template Designer. This article is to tell you that "how can you add tabs in these new templates?"

Its very easy

  1. Open http://draft.blogger.com/home
  2. Go To layout section and add a page element of type "HTML/Javascript" just below "Blog Header"
  3. Now add this code in the widget.



<ul>
<li><a href="http://sampleurl.com">Sample URL</a></li>
<li><a href="http://example.com" >Example Links</a></li>
</ul>

Note that between ul tag you can add many as li items as you want.
each li item will have a anchor ("a") element whose href property needs to be set to the URL you want this tab to link, and text portion goes in between.

customize this code as you want, and then paste them in the widget section.
save your widget and enjoy the tabs.

Thanks for reading my blog



How to organize life using twitter?

{Happy Birthday To Twitter, Today on 21st March 2010, little bird (twitter) is all grown up. }
Today in this article I am going to tell you some little tip to organize your life with twitter. Read my old article about how I have linked my social network.

Twitter is popular because of 2 main reasons, Simplicity & Accessibility. Twitter Updates (tweets) are just 140 character long, and you can post these update from any media e.g Browser, twitter clients, phone client, by SMS or even by writing down on paper.

For centuries there are 2 very popular ways of organizing life,
1.Note Making
2.ToDo List
Despite these things being a popular way of organizing life, majority of people fails to maintain a single note-book or a ToDo list, because if your life is so organized to maintain a ToDo List or notebook then probably you never need them. Point is, either you are using a paper, phone, iPod or your laptop to maintain your ToDo list , none of them is accessible all the time & everywhere. Eventually this accessibility problem is almost solved by twitter, So there can not be any better tool like twitter to organize your life.

I always loved 2 tools on web for maintaining my todo list and notes, because they are also accessible via twitter.

EverNote
EverNote is very nice note making tool. I am not going to tell you much about it. You can just go an try it. I love its web-clip boorkmarklet to take note while browsing. Addition to specific client it has for iPhone, Android and Win-Mobile, You can also add a note in EverNote by just @replying to @myen or send a DM(direct message) to it. Now since tweet can be posted by all ways described above , you can access your note from every where.

e.g
   note to self "kill all currupt politicians" @myen
OR
d myen think about explaination why photo frame is better than diamond necklace on valentine's day
Remember The Milk

Remember the milk has a very similar accessibility options as EverNote, the difference is in aproach, This is a ToDo list for task management. You can also access it by sending DM to @rtm
e.g.
d rtm pick up the milk
d rtm !complete call jimmy

Search Your Tweets
Here is last tip, Since twitter has become your primary place to dump thoughts, Its better to have a way to search your tweets. Twitter search is a real time search, it only gives you results from a very small time-frame, sometime you might like to search your old tweets. To get this functionality here is a hack, subscribe your twitter feed in Google Reader, Google readers stores all the feeds subscribed by you and indexes it, so that you can search them latter. RSS feed of your tweets will be at this address (if you have unprotected updates only)
http://twitter.com/statuses/user_timeline/[your TWITTER HANDLE].rss

[Update-Jun25-2011]
twitter might discontinue RSS feeds soon, so this technique might not work now. There is an awesome service written by Remy Sharp to search old tweet try is. SnapBird



Thanks for reading my blog. Hope this was helpful. Please share on twitter and Facebook if you liked it.

Awesome QUESTIONS are back

Do not miss the part-1 and part-2 of awesome questions. AND here are few more
  1. If love of money is the root of all evil, why do churches want it?
  2. If love is blind, why is lingerie so popular?
  3. If Jimmy cracks corn & no one cares, why is there a stupid song about him?
  4. If it’s true that we are here to help others, then what exactly are the others here for?
  5. If it takes more muscles to frown than smile, then wouldn’t unhappy people’s faces be in better shape?
  6. If I save time, when do I get it back ?
  7. If I save the whales, where do I keep them?
  8. If flying is so safe, why do they call the airport the terminal?
  9. If electricity comes from electrons, does that mean that morality comes from morons?
  10. If you are reading a very INTERESTING book about anti-gravity. Can you put it down?
  11. How can an email be both URGENT & FYI?
  12. If vegetarians eat vegetables, what do humanitarians eat?
  13. Why do people make loud nosies when there tryin to make someone be quiet?
  14. If past tense of sit is sat, why not past tense of fit is fat?
  15. People say "The moment u stop learning u r dead", then why population is still increasing?
Thanks Guys have fun :)
If you have any awesome question about the blog, please post as comment. Do share on twitter and Facebook if you like it. 

How to add custom about me page on blogger



Note: This blog post is deprecated !!! Use Pages Feature to create about-me page 

Hi There,
Here I am going to talk about a dirty hack to make custom about me page on blogger. Lets have a look what you are going to get after doing all this.

So, Basically you are going to make an blog post which will contain "about me information" which you wanted to put on your blog. Then you will remove date entry(time stamp) / and comment option for this page so that it will not look like a post.
Note: Save your existing template before, doing anything. If you break anything , you can restore the template back.
STEP-1
Create a blog post with title "about me" and content whatever you want. Then go to Post option

STEP-2




Go to post option and click "Don't allow comment" and Set time-stamp to a very old date (may be much before your birth).

Step-3
To remove time-stamp from this post your have to wrap part of code which generates Time stamp in your template with this code.
<b:if cond='data:post.allowComments'>



</b:if>

This is basically a way to tell that whatever "post does not allow comment" will not generate few things (which is time-stamp in our case). 
Step-4
Go to layout section of your blog, and go to edit HTML. Choose "Expand Widget Templates" option.

Now select all the text from Text area and put in your favorite "Text Editor" . (FYI My favorite editor is Notepad++).

Now wrap following 2 block with code above
<h2 class='date-header'><span><data:post.dateHeader/></span></h2>
AND
<div class='post-footer-line post-footer-line-1'>




Part-1

Part-2
Once you are done with this editing, go paste the entire thing back to blogger text-area and save the template.

Note: You should wrap the code very carefully, basic HTML knowledge is very essential for this.  Every Div block starts and ends some where , so wrapping must be perfect.




You can link the URL of the page on "About Me Tab" Read My other post.

Thats it, Your are done!!!

Chrome Extension to analyse tweeter (Twitter User) Behavior

Recently I was looking on various sites that shows some statistics about tweeters (twitter user). They are great but they often focus on one thing, there is no single place where we can see all these analysis. So i closely analysed these websites to come-up with YQL hack to bring all of them on a single page. Mainly I focused myself on these websites.

  1. http://twitterholic.com/
  2. http://web.forret.com/tools/twitter-tq.asp
  3. http://tweeps.info/
  4. http://happytweets.com/
  5. http://tweeteffect.com/
TweetChrome

[I am also trying to pull information from http://tweetstats.com]

Well if I would have hosted this functionality something like this (actually hosted ).  No one will use it, because people are very lazy. So I have created a chrome extension here.

If you use chrome then you can simple see source code here.

Thanks for reading my blog.