From a6c9cee15bd36912c5197efde938a134dc7039cb Mon Sep 17 00:00:00 2001 From: Praveen Arimbrathodiyil Date: Wed, 24 Oct 2007 19:23:31 +0530 Subject: project got a name - sulekha! --- input-methods/lipimatoo/BUILD | 1 - input-methods/lipimatoo/HACK | 2 - input-methods/lipimatoo/lipimatoo.c | 129 ---------- input-methods/lipimatoo/transliteration.c | 383 ------------------------------ input-methods/lipimatoo/transliteration.h | 31 --- input-methods/sulekha/BUILD | 1 + input-methods/sulekha/HACK | 2 + input-methods/sulekha/sulekha.c | 129 ++++++++++ input-methods/sulekha/transliteration.c | 383 ++++++++++++++++++++++++++++++ input-methods/sulekha/transliteration.h | 31 +++ 10 files changed, 546 insertions(+), 546 deletions(-) delete mode 100644 input-methods/lipimatoo/BUILD delete mode 100644 input-methods/lipimatoo/HACK delete mode 100644 input-methods/lipimatoo/lipimatoo.c delete mode 100644 input-methods/lipimatoo/transliteration.c delete mode 100644 input-methods/lipimatoo/transliteration.h create mode 100644 input-methods/sulekha/BUILD create mode 100644 input-methods/sulekha/HACK create mode 100644 input-methods/sulekha/sulekha.c create mode 100644 input-methods/sulekha/transliteration.c create mode 100644 input-methods/sulekha/transliteration.h diff --git a/input-methods/lipimatoo/BUILD b/input-methods/lipimatoo/BUILD deleted file mode 100644 index b887178..0000000 --- a/input-methods/lipimatoo/BUILD +++ /dev/null @@ -1 +0,0 @@ -gcc -Wall -g lipimatoo.c -o lipimatoo `gtk-config --cflags` `gtk-config --libs` diff --git a/input-methods/lipimatoo/HACK b/input-methods/lipimatoo/HACK deleted file mode 100644 index 993d43f..0000000 --- a/input-methods/lipimatoo/HACK +++ /dev/null @@ -1,2 +0,0 @@ - -* fix unicode rendering issue diff --git a/input-methods/lipimatoo/lipimatoo.c b/input-methods/lipimatoo/lipimatoo.c deleted file mode 100644 index 907aa39..0000000 --- a/input-methods/lipimatoo/lipimatoo.c +++ /dev/null @@ -1,129 +0,0 @@ -/* - *File name: lipimatoo.c - * - * Copyright (C) 2007-2008 - * Praveen Arimbrathodiyil , - * Swathanthra Malayalam Computing. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - - -*/ - -#include -#include -#include -#include -#include -#include -#include "transliteration.c" -/*-- This function allows the program to exit properly when the window is closed --*/ -gint destroyapp (GtkWidget *widget, gpointer gdata) -{ - g_print ("Quitting...\n"); - gtk_main_quit(); - return (FALSE); -} - -static gint -key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) -{ - gchar *buffer,*mal; - gint position; - static gint start_position=0; -/* if (event->length > 0) - printf("The key event's string is `%s'\n", event->string); - - printf("The name of this keysym is `%s'\n", - gdk_keyval_name(event->keyval)); -*/ - switch (event->keyval) - { - - case GDK_space: - printf("Space pressed\n"); - position = gtk_text_get_point(GTK_TEXT(widget)); - printf("text from %d to %d\n",start_position,position); - - buffer = gtk_editable_get_chars (GTK_EDITABLE( widget ),start_position,position); - start_position+=position+1; - g_print("%s\n",buffer); - - mal = transliterate_ml(buffer,0,strlen(buffer)); - g_print("%s\n",mal); - - gtk_text_insert(GTK_TEXT(widget), NULL, NULL, NULL, mal, strlen(mal)); - printf("start_position is %d strlen\(mal\) is %d\n",start_position,strlen(mal)); - start_position+=strlen(mal); - break; - default: - break; - } - - -} - -int main (int argc, char *argv[]) -{ - /*-- Declare the GTK Widgets used in the program --*/ - GtkWidget *window; - GtkWidget *text; - - - /*-- Initialize GTK --*/ - gtk_init (&argc, &argv); - - /*-- Create the new window --*/ - window = gtk_window_new(GTK_WINDOW_TOPLEVEL); - - /*-- Create a text area --*/ - text = gtk_text_new(NULL, NULL); - - /*-- Set text area to be editable --*/ - gtk_text_set_editable(GTK_TEXT (text), TRUE); - - /*-- Connect the window to the destroyapp function --*/ - gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroyapp), NULL); - - /*-- Add the text area to the window --*/ - gtk_container_add(GTK_CONTAINER(window), text); - - /*-- Add some text to the window --*/ - -//gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buffer, strlen(buffer)); - -gtk_signal_connect(GTK_OBJECT (text), "key_press_event", - (GtkSignalFunc) key_press_cb, NULL); - /*-- Set window border to zero so that text area takes up the whole window --*/ - gtk_container_border_width (GTK_CONTAINER (window), 0); - - /*-- Set the window to be 640 x 200 pixels --*/ - gtk_window_set_default_size (GTK_WINDOW(window), 640, 200); - - /*-- Set the window title --*/ - gtk_window_set_title(GTK_WINDOW (window), "Googliterate"); - - /*-- Display the widgets --*/ - gtk_widget_show(text); - gtk_widget_show(window); - - /*-- Start the GTK event loop --*/ - gtk_main(); - - /*-- Return 0 if exit is successful --*/ - return 0; -} - diff --git a/input-methods/lipimatoo/transliteration.c b/input-methods/lipimatoo/transliteration.c deleted file mode 100644 index 71ac413..0000000 --- a/input-methods/lipimatoo/transliteration.c +++ /dev/null @@ -1,383 +0,0 @@ -/* transliteration.c - * - * Copyright (C) 2007-2008 - * Santhosh Thottingal, - * Swathanthra Malayalam Computing. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - -#include -#include -#include -#include "transliteration.h" -/* -Transliterate the a dhvani phonetic string to malayalam. -Algorithm: -1)For all vowels, if it is at the 0th position print as it is -2)If the vowel is in between/end of the string print the sign of the vowel except for A -3)For all consonants print the malayalam character -4)If a phonetic character is not identified print '?' -5)Octal C escaped strings are used for printing the Unicode Malayalam string -*/ - - -char * -transliterate_ml (char *phonetic_string, int start, int end) -{ - char *ml_string; - int length = 0; - int i = start; - length = end - start; - ml_string = (char *) malloc (length * 4 * sizeof (char)); - while (i < end) - { - - switch (phonetic_string[i]) - { - //Vowels - case 'a': - if (i == 0) //first letter, use swaram as such - { // as in amaram - - if (i < end && phonetic_string[i + 1] == 'a') - { // as in aana - strcat (ml_string, "\340\264\206"); //aa letter - i++; - } - else if (i < end && phonetic_string[i + 1] == 'i') - { // as in airaavatham - strcat (ml_string, "\340\264\202"); //ai letter - i++; - } - else if (i < end && phonetic_string[i + 1] == 'u') - { // as in airaavatham - strcat (ml_string, "\340\264\224"); //au aushadham - i++; - } - else - { - strcat (ml_string, "\340\264\205"); //a letter - } - } - else - { //swara chihnam - if (i < end && phonetic_string[i + 1] == 'a') //aa sign - { // as in kaazhcha - strcat (ml_string, "\340\264\276"); - i++; - } - else if (i < end && phonetic_string[i + 1] == 'i') - { // as in kaitha - strcat (ml_string, "\340\265\210"); //ai sign - i++; - } - else if (i < end && phonetic_string[i + 1] == 'u') - { // as in kauravar - strcat (ml_string, "\340\265\227"); //au sign - i++; - } - } - break; - - case 'A': - (i == 0) ? strcat (ml_string, "\340\264\206") : strcat (ml_string, - "\340\264\276"); - break; - case 'i': - if (i == 0) - { - if (i < end - && ((phonetic_string[i + 1] == 'i') - || (phonetic_string[i + 1] == 'e'))) - { //ii/ee letter - strcat (ml_string, "\340\264\210"); - i++; - } - else - { - strcat (ml_string, "\340\264\207"); // i/e letter - } - } - else - { - if (i < end && ((phonetic_string[i + 1] == 'i') || (phonetic_string[i + 1] == 'e'))) //ii/ee sign - { - strcat (ml_string, "\340\265\200"); - i++; - } - else - { - strcat (ml_string, "\340\264\277"); // i/e sign - } - } - break; - case 'I': - (i == 0) ? strcat (ml_string, "\340\264\210") : strcat (ml_string, - "\340\265\200"); - break; - case 'u': - if (i == 0) - { - if (i < end - && ((phonetic_string[i + 1] == 'o') - || (phonetic_string[i + 1] == 'u'))) - { //ii/ee letter - strcat (ml_string, "\340\264\212"); - i++; - } - else - { - strcat (ml_string, "\340\264\211"); // u letter - } - } - else - { - if (i < end && ((phonetic_string[i + 1] == 'u') || (phonetic_string[i + 1] == 'o'))) //ii/ee sign - { - strcat (ml_string, "\340\265\202"); //uu sign - i++; - } - else - { - strcat (ml_string, "\340\265\201"); // u sign - } - } - break; - case 'U': - (i == 0) ? strcat (ml_string, "\340\264\212") : strcat (ml_string, - "\340\265\202"); - break; - case '^': - (i == 0) ? strcat (ml_string, "\340\264\213") : strcat (ml_string, - "\340\265\203"); - break; - case 'e': - if (i == 0) - { - if (i < end - && ((phonetic_string[i + 1] == 'e') - || (phonetic_string[i + 1] == 'a'))) - { //ii/ee letter - strcat (ml_string, "\340\264\217"); - i++; - } - else - { - strcat (ml_string, "\340\264\207"); // e letter - } - } - else - { - if (i < end && ((phonetic_string[i + 1] == 'e') )) //e/ee sign - { - strcat (ml_string, "\340\265\200"); //ee sign - i++; - } - else - { - strcat (ml_string, "\340\265\206"); // u sign - } - } - break; - case 'E': - (i == 0) ? strcat (ml_string, "\340\264\217") : strcat (ml_string, - "\340\265\207"); - break; -// case '@': //ai -// (i == 0) ? strcat (ml_string, "\340\264\220") : strcat (ml_string, -// "\340\265\210"); -// break; - case 'o': - if (i == 0) - { - if (i < end - && ((phonetic_string[i + 1] == 'o'))) - { //oo letter - strcat (ml_string, "\340\264\222"); - i++; - } - else - { - strcat (ml_string, " \340\264\223"); // o letter - } - } - else - { - if (i < end && ((phonetic_string[i + 1] == 'o') )) //oo sign - { - strcat (ml_string, "\340\265\213"); //oo sign - i++; - } - else - { - strcat (ml_string, "\340\265\212"); // o sign - } - } - break; - case 'O': - (i == 0) ? strcat (ml_string, "\340\264\223") : strcat (ml_string, - "\340\265\213"); - break; - case '`': - (i == 0) ? strcat (ml_string, "\340\264\224") : strcat (ml_string, - "\340\265\227"); - break; - case '.': //am - strcat (ml_string, "\340\264\202"); - break; - case '~': //chandrakkala - strcat (ml_string, "\340\265\215"); - break; - case ':': //Ah - strcat (ml_string, "\340\264\203"); - break; - //Consonants - case 'k': - strcat (ml_string, "\340\264\225"); - - if (i < end && (phonetic_string[i + 1] == phonetic_string[i])) - { //koottaxaram - put a virama - strcat (ml_string, "\340\265\215"); - } - break; - case 'K': - strcat (ml_string, "\340\264\226"); - break; - case 'g': - strcat (ml_string, "\340\264\227"); - break; - case '-': - strcat (ml_string, "\340\264\231"); - break; - case 'G': - strcat (ml_string, "\340\264\230"); - break; - case 'c': - strcat (ml_string, "\340\264\232"); - break; - case 'C': - strcat (ml_string, "\340\264\233"); - break; - case 'j': - strcat (ml_string, "\340\264\234"); - break; - case 'J': - strcat (ml_string, "\340\264\235"); - break; - case '#': - strcat (ml_string, "\340\264\236"); - break; - case 't': - strcat (ml_string, "\340\264\237"); - break; - case 'T': - strcat (ml_string, "\340\264\240"); - break; - case 'd': - strcat (ml_string, "\340\264\241"); - break; - case 'D': - strcat (ml_string, "\340\264\242"); - break; - case 'N': - strcat (ml_string, "\340\264\243"); - break; - case 'x': - strcat (ml_string, "\340\264\244"); - break; - case 'X': - strcat (ml_string, "\340\264\245"); - break; - case 'w': - strcat (ml_string, "\340\264\246"); - break; - case 'W': - strcat (ml_string, "\340\264\247"); - break; - case 'n': - strcat (ml_string, "\340\264\250"); - break; - case 'p': - strcat (ml_string, "\340\264\252"); - break; - case 'f': - strcat (ml_string, "\340\264\253"); - break; - case 'b': - strcat (ml_string, "\340\264\254"); - break; - case 'B': - strcat (ml_string, "\340\264\255"); - break; - case 'm': - if (i == end - 1 && phonetic_string[i] != phonetic_string[i-1] ) //end of word. most probably it is an anuswaram - { - strcat (ml_string, "\340\264\202"); - - } - else - { - strcat (ml_string, "\340\264\256"); - } - - if (i < end && (phonetic_string[i + 1] == phonetic_string[i])) - { //koottaxaram - put a virama - strcat (ml_string, "\340\265\215"); - } - break; - case 'y': - strcat (ml_string, "\340\264\257"); - break; - case 'r': - strcat (ml_string, "\340\264\260"); - break; - case 'l': - strcat (ml_string, "\340\264\262"); - break; - case 'v': - strcat (ml_string, "\340\264\265"); - break; - case '$': - strcat (ml_string, "\340\264\266"); - break; - case 's': - strcat (ml_string, "\340\264\270"); - break; - case 'S': - strcat (ml_string, "\340\264\267"); - break; - case 'h': - strcat (ml_string, "\340\264\271"); - break; - case 'L': - strcat (ml_string, "\340\264\263"); - break; - case 'z': - strcat (ml_string, "\340\264\264"); - break; - case 'R': - strcat (ml_string, "\340\264\261"); - break; - default: - strcat (ml_string, "?"); //Not recognized - break; - } - - i++; - } -//printf(":%s:\n",ml_string); - return ml_string; -} diff --git a/input-methods/lipimatoo/transliteration.h b/input-methods/lipimatoo/transliteration.h deleted file mode 100644 index 3d101da..0000000 --- a/input-methods/lipimatoo/transliteration.h +++ /dev/null @@ -1,31 +0,0 @@ -/* transliteration.h - * - * Copyright (C) 2007-2008 - * Santhosh Thottingal, - * Swathanthra Malayalam Computing. - * - * This program is free software; you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation; either version 2 of the License, or (at - * your option) any later version. - * - * This program is distributed in the hope that it will be useful, but - * WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. - * See the GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program; if not, write to the Free Software - * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. - */ - /*----------------------- FUNCTIONS ----------------------------*/ -/* -Transliterate the a dhvani phonetic string to malayalam. -Algorithm: -1)For all vowels, if it is at the 0th position print as it is -2)If the vowel is in between/end of the string print the sign of the vowel except for A -3)For all consonants print the malayalam character -4)If a phonetic character is not identified print '?' -5)Octal C escaped strings are used for printing the Unicode Malayalam string -*/ -char *transliterate_ml (char *, int, int); diff --git a/input-methods/sulekha/BUILD b/input-methods/sulekha/BUILD new file mode 100644 index 0000000..b887178 --- /dev/null +++ b/input-methods/sulekha/BUILD @@ -0,0 +1 @@ +gcc -Wall -g lipimatoo.c -o lipimatoo `gtk-config --cflags` `gtk-config --libs` diff --git a/input-methods/sulekha/HACK b/input-methods/sulekha/HACK new file mode 100644 index 0000000..993d43f --- /dev/null +++ b/input-methods/sulekha/HACK @@ -0,0 +1,2 @@ + +* fix unicode rendering issue diff --git a/input-methods/sulekha/sulekha.c b/input-methods/sulekha/sulekha.c new file mode 100644 index 0000000..9f25cf0 --- /dev/null +++ b/input-methods/sulekha/sulekha.c @@ -0,0 +1,129 @@ +/* + *File name: sulekha.c + * + * Copyright (C) 2007-2008 + * Praveen Arimbrathodiyil , + * Swathanthra Malayalam Computing. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + + +*/ + +#include +#include +#include +#include +#include +#include +#include "transliteration.c" +/*-- This function allows the program to exit properly when the window is closed --*/ +gint destroyapp (GtkWidget *widget, gpointer gdata) +{ + g_print ("Quitting...\n"); + gtk_main_quit(); + return (FALSE); +} + +static gint +key_press_cb(GtkWidget* widget, GdkEventKey* event, gpointer data) +{ + gchar *buffer,*mal; + gint position; + static gint start_position=0; +/* if (event->length > 0) + printf("The key event's string is `%s'\n", event->string); + + printf("The name of this keysym is `%s'\n", + gdk_keyval_name(event->keyval)); +*/ + switch (event->keyval) + { + + case GDK_space: + printf("Space pressed\n"); + position = gtk_text_get_point(GTK_TEXT(widget)); + printf("text from %d to %d\n",start_position,position); + + buffer = gtk_editable_get_chars (GTK_EDITABLE( widget ),start_position,position); + start_position+=position+1; + g_print("%s\n",buffer); + + mal = transliterate_ml(buffer,0,strlen(buffer)); + g_print("%s\n",mal); + + gtk_text_insert(GTK_TEXT(widget), NULL, NULL, NULL, mal, strlen(mal)); + printf("start_position is %d strlen\(mal\) is %d\n",start_position,strlen(mal)); + start_position+=strlen(mal); + break; + default: + break; + } + + +} + +int main (int argc, char *argv[]) +{ + /*-- Declare the GTK Widgets used in the program --*/ + GtkWidget *window; + GtkWidget *text; + + + /*-- Initialize GTK --*/ + gtk_init (&argc, &argv); + + /*-- Create the new window --*/ + window = gtk_window_new(GTK_WINDOW_TOPLEVEL); + + /*-- Create a text area --*/ + text = gtk_text_new(NULL, NULL); + + /*-- Set text area to be editable --*/ + gtk_text_set_editable(GTK_TEXT (text), TRUE); + + /*-- Connect the window to the destroyapp function --*/ + gtk_signal_connect(GTK_OBJECT(window), "delete_event", GTK_SIGNAL_FUNC(destroyapp), NULL); + + /*-- Add the text area to the window --*/ + gtk_container_add(GTK_CONTAINER(window), text); + + /*-- Add some text to the window --*/ + +//gtk_text_insert(GTK_TEXT(text), NULL, NULL, NULL, buffer, strlen(buffer)); + +gtk_signal_connect(GTK_OBJECT (text), "key_press_event", + (GtkSignalFunc) key_press_cb, NULL); + /*-- Set window border to zero so that text area takes up the whole window --*/ + gtk_container_border_width (GTK_CONTAINER (window), 0); + + /*-- Set the window to be 640 x 200 pixels --*/ + gtk_window_set_default_size (GTK_WINDOW(window), 640, 200); + + /*-- Set the window title --*/ + gtk_window_set_title(GTK_WINDOW (window), "Googliterate"); + + /*-- Display the widgets --*/ + gtk_widget_show(text); + gtk_widget_show(window); + + /*-- Start the GTK event loop --*/ + gtk_main(); + + /*-- Return 0 if exit is successful --*/ + return 0; +} + diff --git a/input-methods/sulekha/transliteration.c b/input-methods/sulekha/transliteration.c new file mode 100644 index 0000000..71ac413 --- /dev/null +++ b/input-methods/sulekha/transliteration.c @@ -0,0 +1,383 @@ +/* transliteration.c + * + * Copyright (C) 2007-2008 + * Santhosh Thottingal, + * Swathanthra Malayalam Computing. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + +#include +#include +#include +#include "transliteration.h" +/* +Transliterate the a dhvani phonetic string to malayalam. +Algorithm: +1)For all vowels, if it is at the 0th position print as it is +2)If the vowel is in between/end of the string print the sign of the vowel except for A +3)For all consonants print the malayalam character +4)If a phonetic character is not identified print '?' +5)Octal C escaped strings are used for printing the Unicode Malayalam string +*/ + + +char * +transliterate_ml (char *phonetic_string, int start, int end) +{ + char *ml_string; + int length = 0; + int i = start; + length = end - start; + ml_string = (char *) malloc (length * 4 * sizeof (char)); + while (i < end) + { + + switch (phonetic_string[i]) + { + //Vowels + case 'a': + if (i == 0) //first letter, use swaram as such + { // as in amaram + + if (i < end && phonetic_string[i + 1] == 'a') + { // as in aana + strcat (ml_string, "\340\264\206"); //aa letter + i++; + } + else if (i < end && phonetic_string[i + 1] == 'i') + { // as in airaavatham + strcat (ml_string, "\340\264\202"); //ai letter + i++; + } + else if (i < end && phonetic_string[i + 1] == 'u') + { // as in airaavatham + strcat (ml_string, "\340\264\224"); //au aushadham + i++; + } + else + { + strcat (ml_string, "\340\264\205"); //a letter + } + } + else + { //swara chihnam + if (i < end && phonetic_string[i + 1] == 'a') //aa sign + { // as in kaazhcha + strcat (ml_string, "\340\264\276"); + i++; + } + else if (i < end && phonetic_string[i + 1] == 'i') + { // as in kaitha + strcat (ml_string, "\340\265\210"); //ai sign + i++; + } + else if (i < end && phonetic_string[i + 1] == 'u') + { // as in kauravar + strcat (ml_string, "\340\265\227"); //au sign + i++; + } + } + break; + + case 'A': + (i == 0) ? strcat (ml_string, "\340\264\206") : strcat (ml_string, + "\340\264\276"); + break; + case 'i': + if (i == 0) + { + if (i < end + && ((phonetic_string[i + 1] == 'i') + || (phonetic_string[i + 1] == 'e'))) + { //ii/ee letter + strcat (ml_string, "\340\264\210"); + i++; + } + else + { + strcat (ml_string, "\340\264\207"); // i/e letter + } + } + else + { + if (i < end && ((phonetic_string[i + 1] == 'i') || (phonetic_string[i + 1] == 'e'))) //ii/ee sign + { + strcat (ml_string, "\340\265\200"); + i++; + } + else + { + strcat (ml_string, "\340\264\277"); // i/e sign + } + } + break; + case 'I': + (i == 0) ? strcat (ml_string, "\340\264\210") : strcat (ml_string, + "\340\265\200"); + break; + case 'u': + if (i == 0) + { + if (i < end + && ((phonetic_string[i + 1] == 'o') + || (phonetic_string[i + 1] == 'u'))) + { //ii/ee letter + strcat (ml_string, "\340\264\212"); + i++; + } + else + { + strcat (ml_string, "\340\264\211"); // u letter + } + } + else + { + if (i < end && ((phonetic_string[i + 1] == 'u') || (phonetic_string[i + 1] == 'o'))) //ii/ee sign + { + strcat (ml_string, "\340\265\202"); //uu sign + i++; + } + else + { + strcat (ml_string, "\340\265\201"); // u sign + } + } + break; + case 'U': + (i == 0) ? strcat (ml_string, "\340\264\212") : strcat (ml_string, + "\340\265\202"); + break; + case '^': + (i == 0) ? strcat (ml_string, "\340\264\213") : strcat (ml_string, + "\340\265\203"); + break; + case 'e': + if (i == 0) + { + if (i < end + && ((phonetic_string[i + 1] == 'e') + || (phonetic_string[i + 1] == 'a'))) + { //ii/ee letter + strcat (ml_string, "\340\264\217"); + i++; + } + else + { + strcat (ml_string, "\340\264\207"); // e letter + } + } + else + { + if (i < end && ((phonetic_string[i + 1] == 'e') )) //e/ee sign + { + strcat (ml_string, "\340\265\200"); //ee sign + i++; + } + else + { + strcat (ml_string, "\340\265\206"); // u sign + } + } + break; + case 'E': + (i == 0) ? strcat (ml_string, "\340\264\217") : strcat (ml_string, + "\340\265\207"); + break; +// case '@': //ai +// (i == 0) ? strcat (ml_string, "\340\264\220") : strcat (ml_string, +// "\340\265\210"); +// break; + case 'o': + if (i == 0) + { + if (i < end + && ((phonetic_string[i + 1] == 'o'))) + { //oo letter + strcat (ml_string, "\340\264\222"); + i++; + } + else + { + strcat (ml_string, " \340\264\223"); // o letter + } + } + else + { + if (i < end && ((phonetic_string[i + 1] == 'o') )) //oo sign + { + strcat (ml_string, "\340\265\213"); //oo sign + i++; + } + else + { + strcat (ml_string, "\340\265\212"); // o sign + } + } + break; + case 'O': + (i == 0) ? strcat (ml_string, "\340\264\223") : strcat (ml_string, + "\340\265\213"); + break; + case '`': + (i == 0) ? strcat (ml_string, "\340\264\224") : strcat (ml_string, + "\340\265\227"); + break; + case '.': //am + strcat (ml_string, "\340\264\202"); + break; + case '~': //chandrakkala + strcat (ml_string, "\340\265\215"); + break; + case ':': //Ah + strcat (ml_string, "\340\264\203"); + break; + //Consonants + case 'k': + strcat (ml_string, "\340\264\225"); + + if (i < end && (phonetic_string[i + 1] == phonetic_string[i])) + { //koottaxaram - put a virama + strcat (ml_string, "\340\265\215"); + } + break; + case 'K': + strcat (ml_string, "\340\264\226"); + break; + case 'g': + strcat (ml_string, "\340\264\227"); + break; + case '-': + strcat (ml_string, "\340\264\231"); + break; + case 'G': + strcat (ml_string, "\340\264\230"); + break; + case 'c': + strcat (ml_string, "\340\264\232"); + break; + case 'C': + strcat (ml_string, "\340\264\233"); + break; + case 'j': + strcat (ml_string, "\340\264\234"); + break; + case 'J': + strcat (ml_string, "\340\264\235"); + break; + case '#': + strcat (ml_string, "\340\264\236"); + break; + case 't': + strcat (ml_string, "\340\264\237"); + break; + case 'T': + strcat (ml_string, "\340\264\240"); + break; + case 'd': + strcat (ml_string, "\340\264\241"); + break; + case 'D': + strcat (ml_string, "\340\264\242"); + break; + case 'N': + strcat (ml_string, "\340\264\243"); + break; + case 'x': + strcat (ml_string, "\340\264\244"); + break; + case 'X': + strcat (ml_string, "\340\264\245"); + break; + case 'w': + strcat (ml_string, "\340\264\246"); + break; + case 'W': + strcat (ml_string, "\340\264\247"); + break; + case 'n': + strcat (ml_string, "\340\264\250"); + break; + case 'p': + strcat (ml_string, "\340\264\252"); + break; + case 'f': + strcat (ml_string, "\340\264\253"); + break; + case 'b': + strcat (ml_string, "\340\264\254"); + break; + case 'B': + strcat (ml_string, "\340\264\255"); + break; + case 'm': + if (i == end - 1 && phonetic_string[i] != phonetic_string[i-1] ) //end of word. most probably it is an anuswaram + { + strcat (ml_string, "\340\264\202"); + + } + else + { + strcat (ml_string, "\340\264\256"); + } + + if (i < end && (phonetic_string[i + 1] == phonetic_string[i])) + { //koottaxaram - put a virama + strcat (ml_string, "\340\265\215"); + } + break; + case 'y': + strcat (ml_string, "\340\264\257"); + break; + case 'r': + strcat (ml_string, "\340\264\260"); + break; + case 'l': + strcat (ml_string, "\340\264\262"); + break; + case 'v': + strcat (ml_string, "\340\264\265"); + break; + case '$': + strcat (ml_string, "\340\264\266"); + break; + case 's': + strcat (ml_string, "\340\264\270"); + break; + case 'S': + strcat (ml_string, "\340\264\267"); + break; + case 'h': + strcat (ml_string, "\340\264\271"); + break; + case 'L': + strcat (ml_string, "\340\264\263"); + break; + case 'z': + strcat (ml_string, "\340\264\264"); + break; + case 'R': + strcat (ml_string, "\340\264\261"); + break; + default: + strcat (ml_string, "?"); //Not recognized + break; + } + + i++; + } +//printf(":%s:\n",ml_string); + return ml_string; +} diff --git a/input-methods/sulekha/transliteration.h b/input-methods/sulekha/transliteration.h new file mode 100644 index 0000000..3d101da --- /dev/null +++ b/input-methods/sulekha/transliteration.h @@ -0,0 +1,31 @@ +/* transliteration.h + * + * Copyright (C) 2007-2008 + * Santhosh Thottingal, + * Swathanthra Malayalam Computing. + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License as published by + * the Free Software Foundation; either version 2 of the License, or (at + * your option) any later version. + * + * This program is distributed in the hope that it will be useful, but + * WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. + * See the GNU General Public License for more details. + * + * You should have received a copy of the GNU General Public License + * along with this program; if not, write to the Free Software + * Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + */ + /*----------------------- FUNCTIONS ----------------------------*/ +/* +Transliterate the a dhvani phonetic string to malayalam. +Algorithm: +1)For all vowels, if it is at the 0th position print as it is +2)If the vowel is in between/end of the string print the sign of the vowel except for A +3)For all consonants print the malayalam character +4)If a phonetic character is not identified print '?' +5)Octal C escaped strings are used for printing the Unicode Malayalam string +*/ +char *transliterate_ml (char *, int, int); -- cgit