且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

英语到印地语的转换

更新时间:2023-02-26 12:36:02

以字符串。例如,从某个文本文件中填充它。值将是音译( http://en.wikipedia.org/wiki/Transliteration [ ^ ])一些英文字符的字符串。这样,你将有一个使用这个数组的函数。



但请想一想:为什么不使用标准的IPA( http://en.wikipedia.org/wiki/International_Phonetic_Alphabet [ ^ ])?据我所知,它很好地涵盖了英语和印地语(我知道一些语言不能很好地覆盖,但印度语应该这样做。)



好​​的,这是由你决定。返回我们的功能:



Create a look-up table in the form of array of string. Populate it from some text file, for example. The value will be the transliteration (http://en.wikipedia.org/wiki/Transliteration[^]) string of some English character. This way, you will have a function using this array.

But think about it: why not using the standard IPA (http://en.wikipedia.org/wiki/International_Phonetic_Alphabet[^])? As far as I know it covers both English and Hindi well (I know some languages it does not cover well, but with Hindi it should do).

OK, it's up to you. Back to our function:

string[] TransliterationTable = new string[26]; //I assume lo- and hi-case letters are transliterated in the same way

//...

//Populate TransliterationTable from file...

//...

// instance method of the same class
// where TransliterationTable is declared:
string Transliterate(char English) {
   // pre-condition to guarantee: all English chars should be in the table,
   // other code points should not be used in call:
   bool upperCase = char.IsUpper(English);
   English = English.ToUpper();
   int index = (char)English - 0x41; //minus capital English 'A'
   string result = TransliterationTable[index];
   if (upperCase) //assume transliterations are in lower
      result = result.ToUpper;
   return TransliterationTable[index]; 
}

//one more in this class:
string Transliterate(string English) {
   System.Text.StringBuilder sb = new System.Text.StringBuilder();
   foreach(char eng in English)
       sb.Append(this.Transliterate(eng));
   return sb.ToString();
}





完成!



- SA


我想你想要创建一个音译逻辑。

首先,一些字的映射是通过使用数组完成的。例如:अ映射为
$ b $bआ映射为a /

1 )之后你必须实现一些逻辑来检查aa是否在辅音之后它应该转换为matra。
I think you want to create a transliteration logic.
For this first some mapping of word is to be done by using array.
for example:अ is mapped with a
आ is mapped with aa
क is mapped with ka
1)after that you have to implement some logic to check if aa comes after consonant than it should convert it to matra.


使用字母的等效字符,你需要写一些代码结合辅音和元音。使用Unicode编码。
Use the character equivalent for the letters and you need to write some code for combining a consonant and a vowel. Use Unicode encoding.