Wednesday, May 12, 2010

Sorting a Dictionary in C# 2

During corpus processing tasks, I need to create and sort dictionaries for very simple tasks of frequency list generation. For this purpose I always have to seek on the web for solutions. C# is now at version 4 and it has lots of variations and innovations in its syntax. There are additional typing conventions, keywords, namespaces like powerful System.LINQ and extension methods. But being a linguistics student I am unable find time to upgrade my skills from C# 2005 a.k.a C# 2 to latest versions. It is not necessary perhaps also because I need C# for text processing tasks which is done very easily with C# 2 and its System.Collections.Generic namespace.
So here is a code sample which can be used to sort a dictionary with respect to its values. I have blended 2 or 3 methods into one so that it takes input as dictionary and gives output as dictionary. Code may be inefficient due to my inabilities in programming but still it works for me. Hopefully for you it would work also. :-)
public static Dictionary Sort (Dictionary dict)
{
List> list = new List>();
foreach(KeyValuePair kvp in dict)
{
list.Add(kvp);
}
list.Sort(
delegate(KeyValuePair firstPair,
KeyValuePair nextPair)
{
return nextPair.Value.CompareTo(firstPair.Value);
}
);
Dictionary d = new Dictionary();
foreach(KeyValuePair kvp in list)
{
d.Add(kvp.Key, kvp.Value);
}
return d;
}

Tuesday, May 11, 2010

Qt Gets Multitouch Support

Qt is one of the very first things I encountered in Linux and Open Source world. I was very fond of KDE 3.x.x and the mother of KDE was Qt, a GUI tool kit which was used to develop KDE and its applications. I always liked the light white and blue interface of KDE as compared to brownish one of Gnome. Then after the release of the adventurous KDE 4, I had to move to a stable desktop environment, Gnome. But KDE is still my love. I always try to use KDE whenever possible. Actually once I tried to develop for KDE as well, of course through Qt. I was looking for some way to develop C# applications using Qt, but since then I am unable to get it done. There is a way (Qyoto) to build applications using Qt and C# but this is not for beginners. A person like me would like to have a GUI designer as there is one in Mono Develop for GTK#, and a very good easy to use IDE to write the applications, and also the documentation to get help. But all these things are still not available in case of Qyoto. It is a good potential project, but still it is not usable for persons like me.
So that was the history of my love regarding Qt and KDE Qt was bought by Nokia a few years back and now it is being developed by Nokia in their own way, to make it fit for smarphones and other such devices. Qt was once dual licensed but now it is released under LGPL and code can be accessed more easily. The news which let me write this post was this one actually. Qt gets multitouch support, means it is now more easy to develop applications for hand held devices. Additionally Qt's software model would be changed to a more modular nature in coming days.

Sunday, May 9, 2010

WebOS based HP's Tablet ??

As we talked about previously about the acquirement of Palm by HP. We also discussed a little about the consequences of this move in the future or near future. The predictions in technology are not very difficult to make. You just have a wise brain and good analytical skills which can tell you what can be there next. So the IT Gurus are making two plus two four and a rumor regarding new HP Tablet is on the way on Internet.
Looks promising? It may be a new competitor of Apple iPad and other such products. So let us see whats gonna happen next.
Update: Here is something more about it

Thursday, May 6, 2010

My New Old Laptop

Just got a new OLD laptop, IBM Thinkpad. More specifications are underway because it is not currently with me. I was trying to have a laptop since 2007 and now finally got one. Thank to Allah G. :-)

Saturday, May 1, 2010

Forensic Linguistics in Pakistan

Forensic Linguistics is the sub field of Linguistics which is used to identify criminals, gangsters and solve legal cases as well. In foreign countries it considers as a vital part of investigation. Linguists are serving in this field as a phonetician, stylistician, and discourse analyst and so on. That’s why the legal institution is very much responsible and efficient, that the crime rate of that countries is very low.

Now, if we look at Pakistan’s condition, why crime is getting its root deeper and deeper in Pakistan? Gangsters, underworld etc. because Pakistan has not a fully fledge system of investigation.

I personally think that forensic linguistics should be in Pakistan with its full sense. At this time, not even a single university offering forensic linguistics as a subject or its specialization. If it would be in Pakistani Universities it can help students or professionals in near future. It also would help our legal field specially for finding criminals out (which is very unusual in our country).

A forensic Linguist can be:

Phonetician, Stylisitican, discourse analyst, semanticist etc. These things are also very much important in our legal way of investigation rather “3rd degree”.

So in my point of view it would be a dual process like the competence of students would be improved as well as it would help our country to sustain the anti-criminal cell. May be a little hard effort in this field can serve a lot.

Ahh! But our bad luck is this that we do not have a single subject on it. Students like me who love forensic field in any discipline would be very happy… InshahAllah I will try my level best to introduce forensic linguistic in Pakistan as a subject. Because I know that efforts & struggles make dreams come true. This field would serve a lot at national level & may be Criminals get civilized 

Anyway, my dream is to be a forensic linguist inshahAllah.

Friday, April 30, 2010

sudo apt-get upgrade -d

If your update manager is not working and a new LTS version of Ubuntu is out there. Follow this method as I always does.
Hit Alt+F2 and in the run box type
sudo gedit /etc/apt/sources.list
Now replace 'karmic' with 'lucid'. Save the file and now write in terminal
sudo apt-get update
and then
sudo apt-get upgrade -d
Put your computer on a scheduled shut down and sleep. As I always does. :-)

Thursday, April 29, 2010

HP Buys Palm

Ohh, my goodness HP Buys Palm. Ohh, what a hot topic it is. The whole world is going mad to tweat it, share it and talk about it, HP just announced to acquire Palm for 1.2 billion dollars. That's great man, really great. But let me ask one thing, DO YOU KNOW WHAT IS PALM?
Ops, if you don't know let us try to know what is Palm, or more specifically Palm OS :-).
Palm OS is a mobile operating system which was introduced in mid 90s and since then it is being used on mobile and hand held devices like PDAs. Palm was sold and purchased by several other companies in the past also. Palm Inc. was suffering these days so HP came to rescue them. Now they would be a sub part of HP and a new addition to HP's product line.
What next? Well next would be a new player in the smart phone market. As Nokia enhancing its business capabilities buy acquiring various software and hardware related companies, Google has entered into the market by introducing Android and NexusOne, Apple is a big stack holder as an iPhone producer, Microsoft is already producing Windows Mobile OS so why not HP? HP will enter into the market with the experience and goodwill of Palm and its products and both will get benefits. You may hear in a few days that Palm OS or its products are open sourced, HP is going to introduce a new smartphone and things like that. So next days are going to be really interesting regarding the smarphone market.