Friday, September 30, 2011

Urdu Text Archive

Urdu Text Archive is a collection of texts from different online sources of Urdu Unicode data. The aim was to collect raw text as first step towards creating an Urdu corpus. As there is no viable grammatical tagger for Urdu available yet, this data can only be used to create word lists or for computational linguistic purposes. The data is not sampled very well because we had least choice in data collection. The biggest source is news reports of various online Urdu news papers. The data was retrieved and freed from html programmatically using regex or html parsers in C#. The genres are typical to news domain. There are articles, news reports, columns, letters to editor, editorials etc. Another major genre is books. The books have been collected from Ejaz Akhtar’s copy left archive of open source Urdu Books. The books have data from various fields of life e.g. Poetry, Literature, Religion, Quarnic Translations, Ahadith and online editions of some magazines. The data from books section is proofread and in good quality. It can be used right away for any further development. But data from Urdu News Papers and online resources, is not so good. It is raw text with spelling errors which needs review. There are problems of space, sometimes additional spaces are introduced, other times spaced are omitted and the spellings are non standard in some cases. So a full sweep out of such error is required before creating any further resource based on this data. In present condition, the limitation of genres is also a problem for this data. The scope of data collection needs to be expanded from news papers to other fields of life as well.

Availability

The data of Urdu Text Archive can be downloaded from this link of 4share.com. The sources used for this data collection are Jang Online Edition, Nawaye Waq Online Edition, NewsUrdu.com news reports and Articles, Karachiupdates.com, AalamiAkhbar Online Newspaper and Urdu Books Archive by Ejaz Akhter. The estimate of words in this archive is 1,82,43,149 words approximately, which will be grown in future hopefully.

Future Plans

  • Expanding the archive e.g. Jasarat Online is a good source.
  • Adding more genres e.g. Urdu Chat Data, Urdu Forums Discussions after anonymization, Urdu Blogs.
  • Development of Urdu resources based on this data e.g. spell checking words lists for Urdu.
  • Refining the data and eliminating formatting. language and spelling problems.
  • Finding trends of Urdu writers on Internet.

Thursday, September 29, 2011

Sword of Truth AND Wheel of Time

I am not clear, whether it was the action of reading WoT first, or the reading of SoT. Now I am in a hollow and a fix kind of situation, drifting here and there. I want to read something, but I cannot because SoT is strikingly similar with WoT. The basic plot has lots of commonalities and I cannot help the feeling that Terry Goodkind has copied something from Robert Jordan. The story drifts apart from WoT’s world ending scenario, but the core remains strikingly same. And after reading reviews about the the similarities, I cannot help myself to read it. But my fantasy loving nature is urging me to do something (actually to listen something). Its just like some heroinchi feels bone crushing need of a cigarette when he can bear no more. Same is with me, I am in a need to read something but don’t know what to read. I’ve tried to read Brother’s Karamazov once again (actually copied in my mobile) but couldn’t develop interest just after a few minutes. What a Shame!

Well, I’ll find something to read, perhaps SoT once again, but let us see a few basic similarities between SoT and WoT. The main purpose of this barely post was to add to the clutter already floating online showing the open secret to the already knowing world. Winking smile

 

SoT WoT
Keeper Dark One
Creator Creator, Light
The Gift One Power
Male Haan Sidiene
Femal Haan Sidar
Great War Breaking
3000 Years Passed since Great War 3000 Years Passed since Breaking
Palace of Profits White Tower
Sisters of Light Eye Sedai
Sisters of Dark Black Sisters
Prelate Amyrlin Seat
Richard Rand
Baka Ban Mana, Daharans Aiel
The Imperial Order Seanchan
Sword of Truth Callandor

Thursday, September 22, 2011

Creating an Urdu Translation Glossary with C#

After a long time I have come back to C#. My limited skills allow me to do some things only with text processing and as I trained my self, my little silly looking C# scripts deal with file operations, getting word frequencies, getting counts from different text files etc etc. As I use C# as Python or other scripting language should be used, to write small programs to do tiny miny things, so I consider myself less of a programmer. But still I am in between a layman and a programmer, and can write a few bits of code. This time, after several months when I came back to C#, it was the urge to create an Urdu Glossary which can work with OmegaT. OmegaT is an open source translation memory tool, and I use it for most of my translations. And I need dictionary constantly as well, but the dictionary I use Urdu Web Lughat which is written in C# 2 and fits my purpose very well, when I add this Lughat File instead of default file which has only a few thousand words. This file has 92661 words and expressions which usually provide me insight for the correct translation, not to mention several other Urdu lughats have been merged with original few thousand words file to create this file. Well it serves the purpose, but it creates problem as well. I have to type each word in its lemma form i.e. if it is a verb in with third form e.g. got, I’ll have to write fist form get to get the meaning. Other problems are with the application.
urdu-web-lughat
Urdu Web Lughat
As the picture shows, capability to search the desired word from Google, Wikitionary, and Urdu Wikipedia as been added to it. This is done by default Internet Explorer Engine provided for C# 2005, but it creates problem while using in higher versions of Windows e.g. Windows 7. Each time I seek a word, it will show 2 or more dialogue boxes showing this error.
lughat-error
Urdu Web Lughat Error
I think I’ve the source code and can fix the problem by simply disabling this feature. But my other problem remains, that is typing the word each time, it takes too much time. So I was seeking for a solution. The solution I figured out was simple, put the lughat file in OmegaT somehow. And that’s possible through dictionary or glossary setup of the program. I find the dictionary process of OmegaT quite complicated (it requires Star Dict format). So I think its more feasible to put a glossary file instead (which is in this format word-tab-meaning). This was easy for me. I wrote a regular expression to match the lughat file’s xml and to extract each word meaning node (Don’t tell me it would have been easy with xml parser, I do not know it so regex was best for me). So here is the code I used to convert the nodes of xml in tab separated text file with each word meaning pair on new line.
public static void test ()
        {
            string match = "\\<I\\>\\s*\\<w\\>(?<Word>[^><]+)\\</w\\>\\s*\\<m\\>(?<Meaning>[^><]+)\\</m\\>\\s*\\</I\\>";
            string text = File.ReadAllText(@"G:\Software\Dictionary\dictionary.xml");
            Console.WriteLine(text.Length);
            //Console.Read();
            MatchCollection m = Regex.Matches(text, match);
            StreamWriter sw = new StreamWriter(@"G:\Software\Dictionary\Glossary.txt", true);
            string word = "";
            string meaning = "";
            Console.WriteLine(m.Count);
            //Console.Read();
            for(int i=0; i<m.Count; i++)
            {
                word = Regex.Replace(m[i].Groups["Word"].Value, "[\\r\\n]+", " ");
                meaning = Regex.Replace(m[i].Groups["Meaning"].Value, "[\\r\\n]+", " ");
                sw.WriteLine(word+"\t"+meaning);
                Console.WriteLine(word);
            }
            sw.Close();
        }
I know it could be improved a lot, but it did the work and did it pretty soon. I put the glossary file in OmegaT project folder as it was required (/project/glossary/Glossary.txt) and that’s done.
OmegaT-with-UrduGlossary1
OmegaT with Glossary 1
I was able to see the word meaning for each sentence in the glossary box in lower right box. It was quite a help for me and reduced my time. But then came the other problem: I still had to go to dictionary and type the lemma forms of verbs and plural nouns, so there was no meaning available for worked, working, works but only for the 1st  form i.e. work. This was quite frustrating for me because the actual problem was still there. So I decided to add the other forms of the words which had more than one forms. I decided to add new lines in the glossary for each form of verb, and add lines for plural forms of nouns as well. The idea was simple enough, but to accomplish it I had to grab a lemma list. Fortunately, being a corpus linguistics student, I know one out on internet. E_Lemma.txt has been created for Word Smith Tools, but I used it for my purpose. The code I used to extract lemmas of each word, and add them to new glossary file is below.
public static void Main(string[] args)
        {
            string[] lines = File.ReadAllLines(@"G:\Software\Dictionary\Glossary.txt");
            string[] lemmas = File.ReadAllLines(@"F:\Corpus Related\e_lemma.txt");
            string word = "";
            string meaning = "";
            string lemma = "";
            StreamWriter sw = new StreamWriter(@"G:\Software\Dictionary\Glossary2.txt", true);
            int count = 1;
            foreach(string line in lines)
            {
                Console.WriteLine(count+" of "+lines.Length);
                word = Regex.Split(line, "\t")[0].Trim();
                meaning = Regex.Split(line, "\t")[1].Trim();
                lemma = giveLemma(word, lemmas);
                if(lemma!="")
                {
                    foreach(string lemma1 in lemma.Split(' '))
                    {
                        sw.WriteLine(lemma1+"\t"+meaning);
                        Console.WriteLine(lemma1+"\t"+meaning);
                    }       
                }
                else
                {
                    sw.WriteLine(word+"\t"+meaning);
                    Console.WriteLine(word+"\t"+meaning);
                }
                count++;
            }
            sw.Close();
        }
        public static string giveLemma (string word, string[] lemmas)
        {
            string toReturn = "";
            string lemma1 = "";
            string lemma2 = "";
            foreach(string lemma in lemmas)
            {
                lemma1 = Regex.Split(lemma, "->")[0].Trim();
                lemma2 = Regex.Split(lemma, "->")[1].Trim();
                if(word==lemma1)
                {
                    toReturn += lemma1 + " " + Regex.Replace(lemma2, ",", " ");
                }
            }
            return toReturn;
        }
As it can be seen, the task is pretty simple.
  • Get each line from previously made glossary file.
  • Split the word and meaning.
  • Pass the word to another function, along with the lemma list (got from e_lemma.txt file) and return all possible forms of a verb or a noun.
  • At the end write a new line for “word-tab-meaning” pair for each lemma form of verb or noun.
  • And if there is no lemma, simply write the original word meaning pair.
The task was simple but the code was quite inefficient, so it took a long time to do this task. It took almost 1.5 hour to do it. But it was done and worked like a charm. See Smile
OmegaT-with-UrduGlossary2
OmegaT with Glossary 2
So a glossary for Urdu Translators working with OmegaT is available. And of course it can be downloaded from here.

Tuesday, September 20, 2011

Discourse Analysis of English Fantasy Novels

Well, its good to be back. Back from a long journey with Richard Cyfer and his lover Kahlan Amnell. Winking smile  You know, it’s hard for me to be away for long from such stories. In last few years I’ve found these English high fantasy novels quite attractive, more precisely kind of seductive for me. I can’t stop reading stories like Harry Potter, Wheel of Time, Codex Alera, and now it is Sword of Truth. I was away from internet, actually coming online just to complete translation that I’ve to deliver to Khawar on daily basis, otherwise I was in winter sleep with handsfree in my ears listening SoT 1: Wizard’s First Rule.
WizardsFirstRule
Wizard's First Rule
SowrdofTruth
The Sword of Truth
Richard-and-Kahlan-Sword-of-Truth
Richard Cyfer and Kahlan Amnell
SoTSeries
SoT Series
The story is quite pleasant. It has all the elements I need in a story. It is mysterious and full of weird things. The author has made his imagination wild, as wild as he could and grabbed the things which get attention of a reader like me, bind me to the book and urge to complete it. The story is full of suspense, breath taking suspense that you dare not stop listening. It is full of magic, strange worlds, strange powers, a sizeable villain and of course, the hero and heroin. You see, everything is in place, the story is a master piece of author’s imagination, a full fledged fantasy novel (series actually) with all the ingredients a fantasy novel can have.
The hero is a rare person, a unique character who is descendent of an ancient wizard family, he is meant to rule, born with power i.e. the gift. The heroin is unique of her kind, she is a confessor, from an ancient magic bearing lot of women who could use their power to capture the mind of anyone with a touch only. She is last left of her kind, others are killed. Ohh yeah, there is a reasonably good villain as well. As all villains do mostly, his father was villain so he is raised to be a villain, two steps ahead of his father in cruelty. And there are good supporting characters. The hero’s old friend, the great old wizard, the boundary warden, a warrior, and other minor characters. The hero and heroin can never be one because of the power she possess, she if she touches him he will loose his personality and become a pet to her. This really creates a sympathy for them. Well, they manage to be together at last, after all heroes are meant to find ways to meet their beloveds (it’s a universal truth Open-mouthed smile).
I really like such novels but after listening (not reading but listening, I like audiobooks for English) at least 3 series and over 20 books, I think I can figure out a common pattern under each such story. They might have a technical name for them, but I’ve observed and then formed a theory to explain the structure of these stories (the fantasy ones I read so far). Apart from the strange and weird worlds they create, they have lots of things common. Perhaps that’s needed because story needs something to move on, a motive, so the motive is provided through a certain pattern. Well we are going to discuss that pattern, or in more precise terms lets have a look on the overall Discourse of such novels (Harry Potter, Codex Alera, Wheel of Time, Sword of Truth).
  • The names e.g. Wheel of Time, Sword of Truth an like, they seem to follow same pattern (although not true for all).
  • The story starts with the world being tore apart by evil forces. They are getting strong, the end of time is near.
  • The world of the story is totally strange and weird. In cases like Harry Potter, it’s built upon ordinary familiar world as a hidden part, otherwise its totally unearthly with commonality of basics of life (characters are humans, there are trees and animals etc.) but other things are different, additions by the wild imagination of the author. All main characters are human (as far are these 4 series are concerned) with addition of other magical, unearthly creatures.
  • The world has a Creator, but he doesn’t interfere with the matters of humans. So they have to save the world on their own. But he usually provides the the ingredients , to be precise the hero of the story.
  • The hero is—as said earlier in the discussion of SoT—a person who is gifted with special powers. He is ordinary person in the beginning. He doesn’t know how to use the powers, mostly he denies to be the world saver, he runs away but the evil forces give him hard time, try to kill him, they tease him so much that he finally becomes an angry cat from a running mouse. Winking smile So he fights back, he learns to use his powers, and becomes lion from angry cat and plans for the final fight. ( I am tired of these final fights, but as you can see this is the discourse structure of such novels, they cannot deviate, so final fights are must for a hero).
  • The heroin, how can a novel be without a heroin Smile. So there is always at least 1 heroin or otherwise as much as the hero thinks he should have Open-mouthed smile (refer to Wheel of Time, the hero has 3 heroines and he loves them all simultaneously). I am quite a jealous of all heroes Winking smile. The heroines are not ordinary females, they’ve an important part in the novel, they possess a unique power which aid the hero several times in the story. They fight side by side with the hero in battle with the evil. One might say they share battle and bed simultaneously, and this adds to the soft side of story, the urge to read on. Well, that’s a debatable thing whether heroines should have such liberties Smile.
  • The villain is a wicked person or thing (non-human entity) who want to rule the world. So he taps the thousands of years old dark powers, he try to get the powers, to be a ruler and to become immortal. During his struggle he fears the hero and tries to kill him or lure him to his side, and thus the story starts, the old conflict of good and bad starts which will end at the end.
  • The story goes on for several books. Each book is a new struggle for the hero and heroine. The hero especially has a hard time, but he develops and gets mature, he becomes wiser and masters more powers, prepares for the final fight with the villain. During the progress of story he might loose some people (minor characters) but heroine should be with him till end (otherwise at least I would not read such a story, that’s why if there is a suspicion of any kind I have a habit to confirm that the royal pair is alright, safe and sound at the end of novel, hope so you understood how do I do this Winking smile).
  • The last novel of the series is the climax. The hero and villain are in hand to hand combat. They fight, use powers of that world, try to kill each other. As you know hero is a person with not so complete knowledge, the villain is master of powers but hero is rather raw as compared to him. But the hero manages to defeat him because villain is a damn fool full of pride who misses trivial things. Thus the hero wins and the world, which is usually a mess now, starts recovering under the holy command of the hero and, of course, the heroine.
  • Another commonality is the presence of one or more supporting characters which help the hero learn to use powers. They may be permanent or temporary, friends or foes, they help him learn somehow. As he is unique and rare, so he manages to learn quickly enough which can save his guts and the world.
Well, perhaps this is not a Discourse Analysis. But it is an analysis, the purpose was to seek a common structure of such stories. I don’t know if I was able to get the goal, but this much is sure that you would enjoy this post. And if you have something to add, most welcome, comments are always welcome.

Friday, September 16, 2011

Killer Topics for Blogging

Bloggers are writers, but unlike traditional writers they are not supposed to be writing only when they have “mode”. If you are in the market, if you want to survive and if you want your readers to continue coming on your blog, you’ve to keep on pushing yourself. Blog posts get old in hours so you have to build new. Posts are read and forgotten, and then they demand more. Same as today people eat, and then demand more to eat. So the experts create “stimuli” for the land to produce quickly and efficiently i.e. fertilizers, they create medicine for cattle and chicken to “produce” faster whether it is milk or eggs or meat. So bloggers are like a commercially breaded commodity, they are supposed to produce, and keep on producing. This process of pushing themselves hard, writing more frequently even if one has no desire to write, extracting every bit of creativeness from the mind creates a hollow effect in the mind. Blogger does not spend much time in writing as much he spends on thinking what to write. The problem is not to create a post, problem is to create a topic around which the post will be woven. Don’t worry, I am with you in this barren land of blogging. When it is “blossom” or “spring” on me, I keep on writing, the topics keep on popping up in my mind and I keep on flowing on the fertile waters of this season. But the “spring” is not always like this. There are times, as there are times for Pakistan now rains are killing then drought will be killing, so there are times when “spring” ends, the springs of water become dry, rains stop pouring down, the sky is hot and bitter, and mind is barren. At these times a blogger feels helpless, or let me admit, I feel helpless, lonely, empty handed, drifting in a void, having a hollowness within me and visiting my blog’s admin page time and again, clicking on New Post button, sometimes opening it writing a few words and closing the opened tab, other times closing the browser just after clicking on new post, shutting down or putting away the PC, looking for a refuge from this emptiness, to seek something, anything to write about. Well, these are hard times for a blogger or perhaps a writer, he wants to write but he does not know what to write. So folks after this long, sad preface which most probably was not able to make a similar effect around you Winking smile, I would like to share a few ideas to write blogs posts on.

  • Surf the waves. Write on the HOT TOPICS. Write about what people are crazy about this time. Write on an update, a new OS, a new gadget, a new phenomenon, a new website, a new service. But make sure its hot for a wide variety of people, its not that you are having a hot thing behind your house and you start writing about it. Open-mouthed smile
  • Review a new gadget, OS, Linux Distribution, Smart Phone, Mobile Application or a Programming Language.
  • Write about a problem you encountered, and managed to solve.
  • Write your reactions what you see around you.
  • Write about your life experiences, reflections, professional life and about your city, province, country.
  • Read, read and lots of read then react and analyse what you have read.
  • And if you can’t do it, go to Google and search killer topics for blogging Winking smile

So if you were hoping for a magic, this isn’t anything like that, there is no shortcut to success. It’s a long way full of hardness, one has to suffer for a good creation same as a mother suffers for her baby. Posts are like children, and children are not purchased ready made, they are part of your soul, parted from you not so easily. If you do not write this way, then you are not a true writer, hence not an original blogger. Enjoy Blogging!

Tuesday, September 13, 2011

Why I don't like Unity [Ubuntu]

Well people have written pages long posts about the pros and cons of Unity, the Shuttleworth born Ubuntu GUI which replaced classic Gnome. People like it, I admit. People use it, love it but the case is that I do not like it. I was never comfortable with Unity and I, sorry to say, had to quit Ubuntu due to this Unity thing. I am an occasional user of Linux, but I used to have 1 Linux system standby with Windows one. For a long time, I've never tried to install Ubuntu. On every new version I download and write the CD, boot and see how desktop looks like and then reject it. Thanks to Linux Mint somehow I've a reasonable desktop. But I do not like it either, the hybrid nature of this distro, half Ubuntu half customisation often look distasteful to me. I DO NOT like Unity. Because: (a few points only :-) )
  • It thinks that every person in the world is left handed.
  • It changes the routine and standard desktop usage. I can't go every time on left to close or open a window. I've built a habit to have close, min, max button on right side for 10 years now. Its hard to break the habit.
  • It thinks that everyone is a Mac user. By God I've never seed a Mac running system in my whole life (well, a iPad 2.0 is another thing I happened to see one ;-) )
  • The launcher is pathetic when it comes to customization. For God sake give some room, give some choice, everyone does not want that God Damn launcher on left side.
  • It was meant for netbooks and now Ubuntu is promoting this "thing" as Microsoft is promoting new version of Windows, the 8th one. These hours could be used to enhance kernel integration, driver development and for Gnome enhancements. Even if they had created customization options, perhaps it could be acceptable.
Well little bit emotional. :-/. But I really don't like Unity. I hope in next version there is an option to revert back to classical Gnome, or I am switching to KDE even if it is not well supported. :-(

Sunday, September 11, 2011

How to Improve Your English Pronunciation

Correct pronunciation is considered essential for language learners. It is true that 100% native like pronunciation is not possible for a non native speaker but one should try for maximum accuracy. A language is best learnt from its native speakers. So for the sake of good English pronunciation, the best sources are the native speakers of English. English has an advantage that a hell lot of supporting material is available, along with multimedia resources that can be used easily to make your English language abilities better.
The pronunciation and listening or in other words speaking and listening are interconnected. One cannot speak if s/he hasn’t listened. Listening is input for you, listening is the base on which the building of your speaking abilities is built. So good listening can not only improve your comprehension abilities but it ultimately helps you improve your pronunciation and speaking skills. If you are a good computer and internet user and spend your some time online, there are a lot of resources available online which can help you improve your pronunciation. Here I am going to discuss a few resources that I, being an English student and Language Teacher, found and got benefit from.
  • Use free dictionary to get meaning and pronunciation of an English word. Click on speaker icon present next to the word.
  • Use Google Translate to get English to Urdu (or your language) translation as well as pronunciation of English word.
  • Listen to podcasts.
  • Listen documentaries and other clips posted on Youtube.com. It will not give you pronunciation of specific word but your general listening and speaking will improve.
  • Watch English movies. Torrentz.com is a good place to get pirated versions of English movies. Older movies (2 to 3 years old) usually have good quality as well as a subtitles file with them. This can help a lot initially to understand the words spoken by native speakers, and thus improve your pronunciation.
  • There are not only movies available, but there are TV Series also available. A TV series is good as compared to movie in various ways, in my point of view. It has a long story, a TV series can last for several years, viewer can have better understanding of story, context and characters. A TV series is usually in Standard English (while movies sometimes get characters which do not speak in Standard Accent). So you may select a TV series of your own choice and get it downloaded, and watch an episode whenever you get time. You’ll feel that you’ve developed an interest, love the story and characters, and understand what the characters say. I love to watch Science Fiction series like Star Trek The Next Generation, Star Trek Deep Space Nine, Stargate SG1. And it has helped me a lot in improving the pronunciation as well as listening comprehension.
  • Listen Audio Books. If you love to read books, then do not read but listen. There are audio books available for every popular novel or story of today, and  you can get them from torrentz.com. I love to listen fantasy stories like Wheel of Time, Harry Potter, Codex Alera. This not only gives you very good pronunciation and listening practice but also improves your expression and vocabulary.
  • The traditional sources: use Oxford Advanced Learner’s Dictionary or Cambridge Advanced Learner’s Dictionary. The CDs can be purchased from market or installation files can be downloaded from torrent websites. OALD is my favourite for pronunciation of different Standard Englishes. Currently it provides British and American English pronunciation which can help a beginner to distinguish the pronunciation differences.
  • Real communication has no alternate. If you happen to have a friend in North America, Australia, Canada or England and s/he speaks English. Do contact her/him and ask for voice call on Skype or Google Talk. A spontaneous interaction with native speakers will increase your listening and speaking abilities alike. And you may get a very close net friend as well. Smile
So these were a few tips to improve pronunciation and listening skills. I would write a few tips for vocabulary improvement and other areas of language development in up coming posts. Stay tuned!