Professional Applications Programmers/Consultants برمجة واستشارات تطبيقات الإنترنت
Skip Navigation LinksHome » Code Library » Language

Public general use code classes and xml files that we've compiled and used over the years:

Language related support class including langauge list and codes.

   1:  using System;
   2:  using System.Web;
   3:  using System.Xml;
   4:  using System.Xml.XPath;
   5:  using System.Xml.Xsl;
   6:  using System.Configuration;
   7:  using System.IO;
   8:  using System.Text;
   9:  using System.Collections;
  10:  using System.Collections.Generic;
  11:  using System.Text.RegularExpressions;
  12:  using System.Linq;
  13:  using System.Xml.Linq;
  14:  using System.Reflection;
  15:  using System.Data.Entity.Design.PluralizationServices;
  16:  using System.Globalization;
  17:   
  18:  namespace Ia.Cl.Model
  19:  {
  20:      ////////////////////////////////////////////////////////////////////////////
  21:   
  22:      /// <summary publish="true">
  23:      /// Language related support class including langauge list and codes.
  24:      /// </summary>
  25:      /// <value> 
  26:      /// The Arabic part is built upon "The Unicode Standard, Version 5.2" with plain, accented, and koranic chars.
  27:      /// 
  28:      /// For language codes see: ISO 639-2 Language Code List - Codes for the representation of names of languages (Library of Congress)
  29:      /// See: http://www-01.sil.org/iso639-3/codes.asp?order=639_1&letter=%25
  30:      /// See: http://en.wikipedia.org/wiki/List_of_ISO_639-2_codes
  31:      /// </value>
  32:      /// <remarks> 
  33:      /// Copyright © 2001-2015 Jasem Y. Al-Shamlan (info@ia.com.kw), Internet Applications - Kuwait. All Rights Reserved.
  34:      ///
  35:      /// This library is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by
  36:      /// the Free Software Foundation, either version 3 of the License, or (at your option) any later version.
  37:      ///
  38:      /// This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of
  39:      /// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details.
  40:      /// 
  41:      /// You should have received a copy of the GNU General Public License along with this library. If not, see http://www.gnu.org/licenses.
  42:      /// 
  43:      /// Copyright notice: This notice may not be removed or altered from any source distribution.
  44:      /// </remarks>
  45:      public class Language
  46:      {
  47:          private static XDocument xDocument;
  48:          private static List<Language> languageList;
  49:   
  50:          private const string latinPlainUpper = "\u0041-\u005a"; // ABCDEFGHIJKLMNOPQRSTUVWXYZ
  51:          private const string latinPlainLower = "\u0061-\u007a"; // abcdefghijklmnopqrstuvwxyz
  52:          private const string latinAccent = "\u00c0-\u00fc"; // ÀÁÂÃÄÅÆÇÈÉÊËÌÍÎÏÐÑÒÓÔÕÖ×ØÙÚÛÜÝÞßàáâãäåæçèéêëìíîïðñòóôõö÷øùúûü
  53:   
  54:          // http://en.wikipedia.org/wiki/Cyrillic_script_in_Unicode
  55:          private const string cyrillicPlain = "\u0400–\u04ff";
  56:          private const string cyrillicSupplement = "\u0500–\u052f";
  57:          private const string cyrillicExtendedA = "\u2de0–\u2dff";
  58:          private const string cyrillicExtendedB = "\ua640–\ua69f";
  59:          private const string choneticExtensions = "\u1d2b|\u1d78";
  60:   
  61:          private const string arabicPlain = "\u0621-\u063a|\u0641-\u064a"; // ءآأؤإئابةتثجحخدذرزسشصضطظعغـفقكلمنهوىي...
  62:          private const string arabicAccent = "\u064b-\u0652"; //  ًٌٍَُِّْٕٖٜٓٔٗ٘ٙٚٛٝٞ
  63:          private const string arabicDigit = "\u0660-\u0669";
  64:          private const string arabicKoran = "\u0617-\u061a|\u06d6-\u06ed"; //  ۖۗۘۙۚۛۜ۝۞ۣ۟۠ۡۢۤۥۦۧۨ۩۪ۭ۫۬
  65:          private const string arabicPoint = "\u0670";
  66:          private const string arabicKoranExtended = "\u0671";
  67:          private const string arabicExtended = "\u0671-\u06d3";
  68:          //arabicJoined = "\ufe81-\ufefc";
  69:   
  70:          private const string hiragana = "\u3041-\u309f";
  71:          private const string katakana = "\u30a0-\u30ff";
  72:          private const string katakanaPhonecticExtensions = "\u31f0-\u31ff";
  73:          private const string katakanaHalfwidth = "\uff65-\uff9f";
  74:   
  75:          private const string cjkUnifiedIdeographs = "\u4e00-\u9fbb";
  76:          private const string cjkUnifiedIdeographsExtentionA = "\u3400-\u4dbf";
  77:          private const string cjkUnifiedIdeographsExtentionB = "\u20000-\u200ff";
  78:          private const string cjkCompatibilityIdeographs = "\f900-\uf9ff";
  79:          private const string cjkCompatibilityIdeographsSupplement = "\u2f800-\u2f8bf";
  80:   
  81:          private const string hangulSyllables = "\uac00-\ud7af";
  82:          private const string hangulJamo = "\u1100-\u11ff";
  83:          private const string hangulCompatibilityJamo = "\u3130-\u318f";
  84:          private const string hangulHalfwidth = "\uffa0-\uffdc";
  85:   
  86:          private const string latin = latinPlainLower + "|" + latinPlainUpper + "|" + latinAccent;
  87:   
  88:          private const string cyrillic = @"\w+"; //cyrillic_plain + "|" + cyrillicSupplement + "|" + cyrillicExtendedA + "|" + cyrillicExtendedB + "|" + choneticExtensions;
  89:   
  90:          private const string arabic = arabicPlain + "|" + arabicAccent + "|" + arabicDigit + "|" + arabicKoran + "|" + arabicPoint + "|" + arabicKoranExtended;
  91:          private const string arabicNonWord = arabicAccent + "|" + arabicDigit + "|" + arabicKoran + "|" + arabicPoint + "|" + arabicKoranExtended;
  92:          private const string kana = hiragana + "|" + katakana + "|" + katakanaPhonecticExtensions + "|" + katakanaHalfwidth;
  93:          private const string hangul = hangulSyllables + "|" + hangulJamo + "|" + hangulCompatibilityJamo + "|" + hangulHalfwidth;
  94:   
  95:          //word = latin + "|" + arabic + "|" + kana + "|" + hangul;
  96:          //ideograph = cjk_unified_ideographs + "|" + cjk_unified_ideographs_extention_a + "|" + cjk_unified_ideographs_extention_b + "|" + cjk_compatibility_ideographs + "|" + cjk_compatibility_ideographs_supplement;
  97:   
  98:          /// <summary/>
  99:          public string Id { get; set; }
 100:   
 101:          /// <summary/>
 102:          public string Symbol { get; set; }
 103:   
 104:          /// <summary/>
 105:          public string Name { get; set; }
 106:   
 107:          /// <summary/>
 108:          public string EnglishName { get; set; }
 109:   
 110:          /// <summary/>
 111:          public string ArabicName { get; set; }
 112:   
 113:          /// <summary/>
 114:          public string Iso6391 { get; set; }
 115:   
 116:          /// <summary/>
 117:          public string Iso63925 { get; set; }
 118:   
 119:          /// <summary/>
 120:          public string Iso6393 { get; set; }
 121:   
 122:          ////////////////////////////////////////////////////////////////////////////
 123:   
 124:          /// <summary>
 125:          /// 
 126:          /// </summary>
 127:          public Language()
 128:          {
 129:          }
 130:   
 131:          ////////////////////////////////////////////////////////////////////////////
 132:   
 133:          /// <summary>
 134:          /// 
 135:          /// </summary>
 136:          public Language(string iso_639_1)
 137:          {
 138:              Language language;
 139:   
 140:              language = LanguageByIso6391(iso_639_1);
 141:   
 142:              this.Id = language.Id;
 143:              this.Name = language.Name;
 144:              this.Symbol = language.Symbol;
 145:              this.EnglishName = language.EnglishName;
 146:              this.ArabicName = language.ArabicName;
 147:          }
 148:   
 149:          ////////////////////////////////////////////////////////////////////////////
 150:   
 151:          /// <summary>
 152:          /// 
 153:          /// </summary>
 154:          public static ArrayList ListOfAllArabicWords
 155:          {
 156:              get
 157:              {
 158:                  string u;
 159:                  ArrayList wordArrayList;
 160:                  Assembly _assembly;
 161:                  //StreamReader streamReader;
 162:   
 163:                  wordArrayList = null;
 164:                  _assembly = Assembly.GetExecutingAssembly();
 165:   
 166:                  try
 167:                  {
 168:                      using (var streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Cl.data.language.List of all Arabic words.txt")))
 169:                      {
 170:                          wordArrayList = new ArrayList(100000);
 171:   
 172:                          if (streamReader.Peek() != -1)
 173:                          {
 174:                              while (!streamReader.EndOfStream)
 175:                              {
 176:                                  u = streamReader.ReadLine();
 177:                                  if (u.Length > 0) wordArrayList.Add(u.Trim());
 178:                              }
 179:                          }
 180:                      }
 181:                  }
 182:                  catch (Exception)
 183:                  {
 184:                      wordArrayList = null;
 185:                  }
 186:                  finally
 187:                  {
 188:                  }
 189:   
 190:                  return wordArrayList;
 191:              }
 192:          }
 193:   
 194:          ////////////////////////////////////////////////////////////////////////////
 195:   
 196:          /// <summary>
 197:          ///
 198:          /// </summary>
 199:          public static Language LanguageByIso6391(string iso_639_1)
 200:          {
 201:              Language language;
 202:   
 203:              language = (from q in XDocument.Elements("languageList").Elements("iso").Elements("language")
 204:                          where q.Attribute("iso_639_1").Value == iso_639_1
 205:                          select new Language
 206:                          {
 207:                              Id = q.Attribute("iso_639_1").Value,
 208:                              Symbol = q.Attribute("iso_639_1").Value,
 209:                              Name = q.Attribute("name").Value,
 210:                              EnglishName = q.Attribute("englishName").Value,
 211:                              ArabicName = q.Attribute("arabicName").Value
 212:                          }
 213:              ).First<Language>();
 214:   
 215:              return language;
 216:          }
 217:   
 218:          ////////////////////////////////////////////////////////////////////////////
 219:   
 220:          /// <summary>
 221:          ///
 222:          /// </summary>
 223:          public static string Ideograph(string language)
 224:          {
 225:              string s;
 226:   
 227:              s = "";
 228:   
 229:              if (language == "en") s = "";
 230:              else if (language == "es") s = "";
 231:              else if (language == "fr") s = "";
 232:              else if (language == "de") s = "";
 233:              else if (language == "nl") s = "";
 234:              else if (language == "ja") s = cjkUnifiedIdeographs + "|" + cjkUnifiedIdeographsExtentionA + "|" + cjkUnifiedIdeographsExtentionB + "|" + cjkCompatibilityIdeographs + "|" + cjkCompatibilityIdeographsSupplement;
 235:              else if (language == "ko") s = cjkUnifiedIdeographs + "|" + cjkUnifiedIdeographsExtentionA + "|" + cjkUnifiedIdeographsExtentionB + "|" + cjkCompatibilityIdeographs + "|" + cjkCompatibilityIdeographsSupplement;
 236:              else if (language == "zh_traditional") s = cjkUnifiedIdeographs + "|" + cjkUnifiedIdeographsExtentionA + "|" + cjkUnifiedIdeographsExtentionB + "|" + cjkCompatibilityIdeographs + "|" + cjkCompatibilityIdeographsSupplement;
 237:              else if (language == "zh_simplified") s = cjkUnifiedIdeographs + "|" + cjkUnifiedIdeographsExtentionA + "|" + cjkUnifiedIdeographsExtentionB + "|" + cjkCompatibilityIdeographs + "|" + cjkCompatibilityIdeographsSupplement;
 238:              else if (language == "ar") s = "";
 239:   
 240:              return s;
 241:          }
 242:   
 243:          ////////////////////////////////////////////////////////////////////////////
 244:   
 245:          /// <summary>
 246:          ///
 247:          /// </summary>
 248:          public static string WordCharacters(string language)
 249:          {
 250:              string s;
 251:   
 252:              s = "";
 253:   
 254:              if (language == "en") s = latin;
 255:              else if (language == "es") s = latin;
 256:              else if (language == "fr") s = latin;
 257:              else if (language == "de") s = latin;
 258:              else if (language == "nl") s = latin;
 259:              else if (language == "ru") s = cyrillic;
 260:              else if (language == "ja") s = kana;
 261:              else if (language == "ko") s = hangul;
 262:              else if (language == "zh_traditional") s = null;
 263:              else if (language == "zh_simplified") s = null;
 264:              else if (language == "ar") s = arabic;
 265:   
 266:              return s;
 267:          }
 268:   
 269:          ////////////////////////////////////////////////////////////////////////////
 270:   
 271:          /// <summary>
 272:          ///
 273:          /// </summary>
 274:          public static string WordsRegularExpression(string language)
 275:          {
 276:              string s;
 277:   
 278:              if (language == "ja") s = "[" + hiragana + "]+|[" + katakana + "]+|[" + katakanaPhonecticExtensions + "]+|[" + katakanaHalfwidth + "]+";
 279:              else
 280:              {
 281:                  s = "[" + WordCharacters(language) + "]+";
 282:              }
 283:   
 284:              return s;
 285:          }
 286:   
 287:          ////////////////////////////////////////////////////////////////////////////
 288:   
 289:          /// <summary>
 290:          ///
 291:          /// </summary>
 292:          public static string BasicWord(string language)
 293:          {
 294:              string s;
 295:   
 296:              s = "";
 297:   
 298:              if (language == "en") s = latinPlainLower;
 299:              else if (language == "es") s = latinPlainLower;
 300:              else if (language == "fr") s = latinPlainLower;
 301:              else if (language == "de") s = latinPlainLower;
 302:              else if (language == "nl") s = latinPlainLower;
 303:              else if (language == "ru") s = cyrillic;
 304:              else if (language == "ja") s = kana;
 305:              else if (language == "ko") s = hangul;
 306:              else if (language == "zh_traditional") s = null;
 307:              else if (language == "zh_simplified") s = null;
 308:              else if (language == "ar") s = arabicPlain;
 309:   
 310:              return s;
 311:          }
 312:   
 313:          ////////////////////////////////////////////////////////////////////////////
 314:   
 315:          /// <summary>
 316:          ///
 317:          /// </summary>
 318:          public static string BasicWordsRegularExpression(string language)
 319:          {
 320:              string s;
 321:   
 322:              if (language == "ja") s = "[" + hiragana + "]+|[" + katakana + "]+|[" + katakanaPhonecticExtensions + "]+|[" + katakanaHalfwidth + "]+";
 323:              else
 324:              {
 325:                  s = "[" + BasicWord(language) + "]+";
 326:              }
 327:   
 328:              return s;
 329:          }
 330:   
 331:          ////////////////////////////////////////////////////////////////////////////
 332:   
 333:          /// <summary>
 334:          ///
 335:          /// </summary>
 336:          public static string NonWord(string language)
 337:          {
 338:              string s;
 339:   
 340:              s = "";
 341:   
 342:              if (language == "en") s = "";
 343:              else if (language == "es") s = "";
 344:              else if (language == "fr") s = "";
 345:              else if (language == "de") s = "";
 346:              else if (language == "nl") s = "";
 347:              else if (language == "ja") s = "";
 348:              else if (language == "ko") s = "";
 349:              else if (language == "zh_traditional") s = "";
 350:              else if (language == "zh_simplified") s = "";
 351:              else if (language == "ar") s = arabicNonWord;
 352:   
 353:              return s;
 354:          }
 355:   
 356:          ////////////////////////////////////////////////////////////////////////////
 357:   
 358:          /// <summary>
 359:          ///
 360:          /// </summary>
 361:          public static string BasicForm(string word)
 362:          {
 363:              // for Western languages, this function takes in a word and returns a copy of the word with all capital letters changed to small, and all
 364:              // accent letters to standard ASCII ones. For Japanese and Korean, on the other hand, this function is not yet defined. It will just return the
 365:              // same argument unchanged, for now.
 366:   
 367:              word = word.Replace("ß", "ss");
 368:              word = word.ToLowerInvariant();
 369:   
 370:              word = word.Replace("ٱ", "ا");
 371:              word = Regex.Replace(word, "[" + global::Ia.Cl.Model.Language.NonWord("ar") + "]", "");
 372:   
 373:              word = RemoveDiacritics(word);
 374:   
 375:              return word;
 376:          }
 377:   
 378:          ////////////////////////////////////////////////////////////////////////////
 379:   
 380:          /// <summary>
 381:          /// Remove punctuation marks
 382:          /// http://stackoverflow.com/questions/18830813/how-can-i-remove-punctuation-from-input-text-in-java
 383:          /// </summary>
 384:          public static string RemovePunctuationMarks(string text)
 385:          {
 386:              text = Regex.Replace(text, "\\p{P}", "");
 387:   
 388:              return text;
 389:          }
 390:   
 391:          ////////////////////////////////////////////////////////////////////////////
 392:   
 393:          /// <summary>
 394:          ///
 395:          /// </summary>
 396:          public static string RemoveDiacritics(string text)
 397:          {
 398:              // http://stackoverflow.com/questions/249087/how-do-i-remove-diacritics-accents-from-a-string-in-net
 399:   
 400:              var normalizedString = text.Normalize(NormalizationForm.FormD);
 401:              var stringBuilder = new StringBuilder();
 402:   
 403:              foreach (var c in normalizedString)
 404:              {
 405:                  var unicodeCategory = CharUnicodeInfo.GetUnicodeCategory(c);
 406:                  if (unicodeCategory != UnicodeCategory.NonSpacingMark)
 407:                  {
 408:                      stringBuilder.Append(c);
 409:                  }
 410:              }
 411:   
 412:              return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
 413:          }
 414:   
 415:          ////////////////////////////////////////////////////////////////////////////
 416:   
 417:          /// <summary>
 418:          /// Generate an array of "similar" Arabic pronouciations of a word, like أحمد and احمد. 
 419:          /// </summary>
 420:          /// <param name="word">Word to find similars to it</param>
 421:          /// <returns>ArrayList of words that will look similar to givin word</returns>
 422:          public static ArrayList ProduceSimilarArabicWords(string word)
 423:          {
 424:              ArrayList al;
 425:              Hashtable ht;
 426:   
 427:              ht = new Hashtable(20);
 428:              al = new ArrayList(20);
 429:   
 430:              // add words to Hashtable:
 431:              ht[word] = 1;
 432:              ht[word.Replace("ـ", "")] = 1;
 433:   
 434:              ht[Regex.Replace(word, "\\bو", "و ")] = 1;
 435:              ht[Regex.Replace(word, "\\bو\\s+", "و")] = 1;
 436:   
 437:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "أ", "ا", ref ht);
 438:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "إ", "ا", ref ht);
 439:   
 440:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "ى", "ي", ref ht);
 441:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "ة", "ه", ref ht);
 442:   
 443:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "و", "ؤ", ref ht);
 444:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "عبد ", "عبد", ref ht);
 445:   
 446:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "ابو ", "ابو", ref ht);
 447:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "داود ", "داوود", ref ht);
 448:   
 449:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "آ", "ءا", ref ht);
 450:              ProduceSimilarArabicWordsAddBothVariationsToArrayList(word, "آ", "ا", ref ht);
 451:   
 452:              foreach (string u in ht.Keys) if (u.Length > 0) al.Add(u);
 453:   
 454:              return al;
 455:          }
 456:   
 457:          ////////////////////////////////////////////////////////////////////////////
 458:   
 459:          /// <summary>
 460:          ///
 461:          /// </summary>
 462:          /// <param name="word"></param>
 463:          /// <param name="variant1"></param>
 464:          /// <param name="variant2"></param>
 465:          /// <param name="ht"></param>
 466:          /// <returns></returns>
 467:          private static void ProduceSimilarArabicWordsAddBothVariationsToArrayList(string word, string variant1, string variant2, ref Hashtable ht)
 468:          {
 469:              ht[word.Replace(variant1, variant2)] = 1;
 470:              ht[word.Replace(variant2, variant1)] = 1;
 471:          }
 472:   
 473:          ////////////////////////////////////////////////////////////////////////////
 474:   
 475:          /// <summary>
 476:          /// Convert Arabic numerals ١٢٣٤٥٦٧٨٩٠ to Latin 1234567890
 477:          /// </summary>
 478:          /// <param name="s">Arabic number in string format</param>
 479:          /// <returns>Latin equivalent</returns>
 480:          public static string ConvertArabicNumbersToLatin(string s)
 481:          {
 482:              s = s.Replace("١", "1");
 483:              s = s.Replace("٢", "2");
 484:              s = s.Replace("٣", "3");
 485:              s = s.Replace("٤", "4");
 486:              s = s.Replace("٥", "5");
 487:              s = s.Replace("٦", "6");
 488:              s = s.Replace("٧", "7");
 489:              s = s.Replace("٨", "8");
 490:              s = s.Replace("٩", "9");
 491:              s = s.Replace("٠", "0");
 492:   
 493:              return s;
 494:          }
 495:   
 496:          ////////////////////////////////////////////////////////////////////////////
 497:   
 498:          /// <summary>
 499:          /// Convert Latin numerals 1234567890 to Arabic ١٢٣٤٥٦٧٨٩٠
 500:          /// </summary>
 501:          /// <param name="s">Latin number in string format</param>
 502:          /// <returns>Arabic equivalent</returns>
 503:          public static string ConvertLatinNumbersToArabic(string s)
 504:          {
 505:              s = s.Replace("1", "١");
 506:              s = s.Replace("2", "٢");
 507:              s = s.Replace("3", "٣");
 508:              s = s.Replace("4", "٤");
 509:              s = s.Replace("5", "٥");
 510:              s = s.Replace("6", "٦");
 511:              s = s.Replace("7", "٧");
 512:              s = s.Replace("8", "٨");
 513:              s = s.Replace("9", "٩");
 514:              s = s.Replace("0", "٠");
 515:   
 516:              return s;
 517:          }
 518:   
 519:          ////////////////////////////////////////////////////////////////////////////
 520:   
 521:          /// <summary>
 522:          /// Correct an Arabic string to the proper format of Arabic
 523:          /// </summary>
 524:          /// <param name="name">Name to be examined</param>
 525:          /// <returns>String of correct format</returns>
 526:          public static string CorrectArabicNameNounStringFormat(string name)
 527:          {
 528:              name = Regex.Replace(name, @"\s+", @" ");
 529:              name = name.Trim();
 530:   
 531:              // remove all 'ـ' chars
 532:              name = name.Replace("ـ", "");
 533:   
 534:              // last 'ه' to 'ة' (on word border)
 535:              // exceptions: 'الله' ...etc.
 536:              if (!Regex.IsMatch(name, "\\bشاه\\b")) name = Regex.Replace(name, "ه\\b", "ة");
 537:              name = name.Replace("اللة", "الله");
 538:   
 539:              // remove first 'دكتور' 'د' 'الدكتور'
 540:              name = Regex.Replace(name, "\\bدكتور\\b", "");
 541:              name = Regex.Replace(name, "\\bالدكتور\\b", "");
 542:              name = Regex.Replace(name, "\\bدكتورة\\b", "");
 543:              name = Regex.Replace(name, "\\bالدكتورة\\b", "");
 544:              name = Regex.Replace(name, "\\bد\\b", "");
 545:   
 546:              name = Regex.Replace(name, @"\bعبد\s+", "عبد");
 547:              name = Regex.Replace(name, @"\s+و\s+", " و");
 548:   
 549:              // first ''last 'ى' to 'ي' (on word border)
 550:              if (!name.Contains("يسرى")
 551:                  && !name.Contains("يحيى")
 552:                  && !name.Contains("هدى")
 553:                  && !name.Contains("سلمى")
 554:                  && !name.Contains("منى")
 555:                  && !name.Contains("منتهى")
 556:                  && !name.Contains("ليلى")
 557:                  && !name.Contains("عيسى")
 558:                  && !name.Contains("موسى")
 559:                  && !name.Contains("سلوى")
 560:                  && !name.Contains("بشرى")
 561:                  && !name.Contains("صغرى")
 562:                  && !name.Contains("صدى")
 563:                  && !name.Contains("كبرى")
 564:                  && !name.Contains("مصطفى")
 565:                  && !name.Contains("ندى")
 566:                  && !name.Contains("يسرى")
 567:                  && !name.Contains("يمنى")
 568:                  && !name.Contains("مستشفى")
 569:                  && !name.Contains("تقوى")
 570:                  && !name.Contains("ذكرى")
 571:                  && !name.Contains("بشرى")
 572:                  && !name.Contains("موسيقى")
 573:                  && !name.Contains("ذكرى")
 574:                  && !name.Contains("ضحى")
 575:                  && !name.Contains("لبنى")
 576:                  && !name.Contains("ذكرى")
 577:                  && !name.Contains("مقتدى")
 578:                  && !name.Contains("مقهى")
 579:                  && !name.Contains("ملهى")
 580:                  && !name.Contains("منتدى")
 581:                  && !name.Contains("منتهى")
 582:                  && !name.Contains("يمنى")
 583:                  && !name.Contains("مرتضى")
 584:                  ) name = Regex.Replace(name, "ى\\b", "ي");
 585:   
 586:              // 
 587:              name = Regex.Replace(name, "\\bاحمد", "أحمد");
 588:              name = Regex.Replace(name, "\\bازياء", "أزياء");
 589:              name = Regex.Replace(name, "\\bاوكسجين", "أوكسجين");
 590:              name = Regex.Replace(name, "\\bاقبال", "إقبال");
 591:              name = Regex.Replace(name, "\\bابيار", "أبيار");
 592:              name = Regex.Replace(name, "اسنان", "أسنان");
 593:              name = Regex.Replace(name, "[أ|ا]براهيم", "إبراهيم");
 594:              name = Regex.Replace(name, "[أ|ا]سماعيل", "إسماعيل");
 595:              name = Regex.Replace(name, "اجياد", "أجياد");
 596:              name = Regex.Replace(name, "\\bامل\\b", "أمل");
 597:              name = Regex.Replace(name, "\\bايوب\\b", "أيوب");
 598:              name = Regex.Replace(name, "\\bايهاب\\b", "إيهاب");
 599:              name = Regex.Replace(name, "\\bايمن\\b", "أيمن");
 600:              name = Regex.Replace(name, "\\bايمان\\b", "إيمان");
 601:              name = Regex.Replace(name, "\\bاياد\\b", "أياد");
 602:              name = Regex.Replace(name, "\\bانيسة\\b", "أنيسة");
 603:              name = Regex.Replace(name, "\\bانيس\\b", "أنيس");
 604:              name = Regex.Replace(name, "\\bانور\\b", "أنور");
 605:              name = Regex.Replace(name, "\\bانوار\\b", "أنوار");
 606:              name = Regex.Replace(name, "\\bامينة\\b", "أمينة");
 607:              name = Regex.Replace(name, "\\bامين\\b", "أمين");
 608:              name = Regex.Replace(name, "\\bاميمة\\b", "أميمة");
 609:              name = Regex.Replace(name, "\\bامير\\b", "أمير");
 610:              name = Regex.Replace(name, "\\bاميرة\\b", "أميرة");
 611:              name = Regex.Replace(name, "\\bامنة\\b", "آمنة");
 612:              name = Regex.Replace(name, "\\bامثال\\b", "أمثال");
 613:              name = Regex.Replace(name, "\\bاماني\\b", "أماني");
 614:              name = Regex.Replace(name, "\\bامان\\b", "أمان");
 615:              name = Regex.Replace(name, "\\bامال\\b", "آمال");
 616:              name = Regex.Replace(name, "\\bام\\b", "أم");
 617:              name = Regex.Replace(name, "\\bالهام\\b", "إلهام");
 618:   
 619:              // 'أل to 'ال'
 620:              name = Regex.Replace(name, "\\bأل", "ال");
 621:   
 622:              // 'اا' at begining to 'ا'
 623:              name = name.Replace("\\bاا", "ا");
 624:   
 625:              // reduce any 3 concecutive similar arabic letters to only 2
 626:              name = name.Replace(@"(\d)\1\1", @"\1\1");
 627:   
 628:              name = Regex.Replace(name, @"\s+", @" ");
 629:              name = name.Trim();
 630:   
 631:              return name;
 632:          }
 633:   
 634:          ////////////////////////////////////////////////////////////////////////////
 635:   
 636:          /// <summary>
 637:          /// Remove non latin characters
 638:          /// </summary>
 639:          /// <param name="line">Line to be cleaned</param>
 640:          /// <returns>String of name cleaned</returns>
 641:          public static string RemoveNonLatinCharacters(string line)
 642:          {
 643:              line = Regex.Replace(line, "[^ " + latin + "]", "");
 644:   
 645:              return line;
 646:          }
 647:   
 648:          ////////////////////////////////////////////////////////////////////////////
 649:   
 650:          /// <summary>
 651:          /// Remove non Arabic and non Arabic-Extended letters and digits
 652:          /// </summary>
 653:          /// <param name="line">Line to filter</param>
 654:          /// <returns>Filtered line</returns>
 655:          public static string RemoveNonNativeAndNonNativeExtendedLettersAndDigitsAccordingToLanguage(string iso6393, string line)
 656:          {
 657:              if (iso6393 == "ar")
 658:              {
 659:                  line = Regex.Replace(line, "[^ " + arabicPlain + "|" + arabicDigit + "|" + arabicExtended + "]", "");
 660:              }
 661:              else
 662:              {
 663:   
 664:              }
 665:   
 666:              return line;
 667:          }
 668:   
 669:          ////////////////////////////////////////////////////////////////////////////
 670:   
 671:          /// <summary>
 672:          /// Convert single latin digits to equivalent native word digits according to language
 673:          /// </summary>
 674:          /// <param name="line">String to process</param>
 675:          /// <returns>Filtered string</returns>
 676:          public static string ConvertSingleLatinDigitsToNativeWordEquivalentAccordingToLanguage(string iso6393, string line)
 677:          {
 678:              if (iso6393 == "ar")
 679:              {
 680:                  line = ConvertArabicNumbersToLatin(line);
 681:   
 682:                  line = line.Replace("1", "واحد");
 683:                  line = line.Replace("2", "إثنين");
 684:                  line = line.Replace("3", "ثلاثة");
 685:                  line = line.Replace("4", "أربعة");
 686:                  line = line.Replace("5", "خمسة");
 687:                  line = line.Replace("6", "ستة");
 688:                  line = line.Replace("7", "سبعة");
 689:                  line = line.Replace("8", "ثمانية");
 690:                  line = line.Replace("9", "تسعة");
 691:                  line = line.Replace("0", "صفر");
 692:              }
 693:              else
 694:              {
 695:   
 696:              }
 697:   
 698:              return line;
 699:          }
 700:   
 701:          ////////////////////////////////////////////////////////////////////////////
 702:   
 703:          /// <summary>
 704:          /// Removes the latin transliterations of subject references of native words according to language. For example "الصيد" could be transliterated to "al sayid", and we want to remove the "al" from the transliteration.
 705:          /// </summary>
 706:          /// <param name="iso6393"></param>
 707:          /// <param name="line">Line to be probed and cleaned</param>
 708:          /// <returns>String of line cleaned</returns>
 709:          public static string RemoveLatinTransliterationsOfSubjectReferencesOfNativeWordTransliterationAccordingToLanguagee(string iso6393, string line)
 710:          {
 711:              // below: Arabic words
 712:              if (iso6393 == "ar")
 713:              {
 714:                  line = Regex.Replace(line, "\\bas\\b", "", RegexOptions.IgnoreCase);
 715:                  line = Regex.Replace(line, "\\bal\\b", "", RegexOptions.IgnoreCase);
 716:                  line = Regex.Replace(line, "\\bash\\b", "", RegexOptions.IgnoreCase);
 717:                  line = Regex.Replace(line, "\\bat\\b", "", RegexOptions.IgnoreCase);
 718:   
 719:                  line = Regex.Replace(line, "\\bad\\b", "", RegexOptions.IgnoreCase);
 720:                  line = Regex.Replace(line, "\\bar\\b", "", RegexOptions.IgnoreCase);
 721:                  line = Regex.Replace(line, "\\ban\\b", "", RegexOptions.IgnoreCase);
 722:                  line = Regex.Replace(line, "\\bath\\b", "", RegexOptions.IgnoreCase);
 723:   
 724:                  line = Regex.Replace(line, "\\baz\\b", "", RegexOptions.IgnoreCase);
 725:                  line = Regex.Replace(line, "\\baz̧( |\\b)", "", RegexOptions.IgnoreCase); // different than above
 726:              }
 727:              else
 728:              {
 729:   
 730:              }
 731:   
 732:              return line;
 733:          }
 734:   
 735:          ////////////////////////////////////////////////////////////////////////////
 736:   
 737:          /// <summary>
 738:          /// Produce Arabic Text of Latin Transliterations of Arabic Word Definit Article
 739:          /// </summary>
 740:          /// <param name="name">Latin Transliteration of Arabic word</param>
 741:          /// <returns>Arabic text</returns>
 742:          public static string ProduceArabicTextOfLatinTransliterationsOfArabicWordDefinitArticle(string name)
 743:          {
 744:              name = Regex.Replace(name, "\\bas\\s*\\b", "ال", RegexOptions.IgnoreCase);
 745:              name = Regex.Replace(name, "\\bal\\s*\\b", "ال", RegexOptions.IgnoreCase);
 746:              name = Regex.Replace(name, "\\bash\\s*\\b", "ال", RegexOptions.IgnoreCase);
 747:              name = Regex.Replace(name, "\\bat\\s*\\b", "ال", RegexOptions.IgnoreCase);
 748:              name = Regex.Replace(name, "\\bad\\s*\\b", "ال", RegexOptions.IgnoreCase);
 749:              name = Regex.Replace(name, "\\bar\\s*\\b", "ال", RegexOptions.IgnoreCase);
 750:              name = Regex.Replace(name, "\\ban\\s*\\b", "ال", RegexOptions.IgnoreCase);
 751:              name = Regex.Replace(name, "\\bath\\s*\\b", "ال", RegexOptions.IgnoreCase);
 752:              name = Regex.Replace(name, "\\baz\\s*\\b", "ال", RegexOptions.IgnoreCase);
 753:   
 754:              name = Regex.Replace(name, "\\baş\\s*\\b", "ال", RegexOptions.IgnoreCase);
 755:              name = Regex.Replace(name, "\\baţ\\s*\\b", "ال", RegexOptions.IgnoreCase);
 756:              name = Regex.Replace(name, "\\baḑ\\s*\\b", "ال", RegexOptions.IgnoreCase);
 757:              name = Regex.Replace(name, "\\badh\\s*\\b", "ال", RegexOptions.IgnoreCase);
 758:   
 759:              name = Regex.Replace(name, "\\baz̧\\s*\\b", "ال", RegexOptions.IgnoreCase);
 760:              name = Regex.Replace(name, "\\baş\\s*\\b", "ال", RegexOptions.IgnoreCase);
 761:   
 762:              return name;
 763:          }
 764:   
 765:          ////////////////////////////////////////////////////////////////////////////
 766:   
 767:          /// <summary>
 768:          /// Remove space after the latin transliteration of Arabic word's definit article
 769:          /// </summary>
 770:          /// <param name="name">Latin Transliteration of Arabic word with article space</param>
 771:          /// <returns>Latin transliteration without article space</returns>
 772:          public static string RemoveSpaceAfterLatinTransliterationsOfArabicWordsDefinitArticle(string name)
 773:          {
 774:              name = Regex.Replace(name, "\\b(as|al|ash|at|ad|ar|an|ath|az|aş|aţ|aḑ|adh|az̧)\\s*\\b", "$1", RegexOptions.IgnoreCase);
 775:              // note two different z and z̧
 776:   
 777:              return name;
 778:          }
 779:   
 780:          ////////////////////////////////////////////////////////////////////////////
 781:   
 782:          /// <summary>
 783:          /// Remove the wrong space between a native definit article and its word.
 784:          /// </summary>
 785:          /// <param name="name">Native text</param>
 786:          /// <returns>Natieve text</returns>
 787:          public static string RemoveWrongSpaceBetweenNativeDefinitArticleAndItsWord(string iso6393, string name)
 788:          {
 789:              if (iso6393 == "ar")
 790:              {
 791:                  name = Regex.Replace(name, "\\b[أ|ا]ت ت", "الت", RegexOptions.IgnoreCase);
 792:                  name = Regex.Replace(name, "\\b[أ|ا]ث ث", "الث", RegexOptions.IgnoreCase);
 793:                  name = Regex.Replace(name, "\\b[أ|ا]د د", "الد", RegexOptions.IgnoreCase);
 794:                  name = Regex.Replace(name, "\\b[أ|ا]ذ ذ", "الذ", RegexOptions.IgnoreCase);
 795:                  name = Regex.Replace(name, "\\b[أ|ا]ر ر", "الر", RegexOptions.IgnoreCase);
 796:   
 797:                  name = Regex.Replace(name, "\\b[أ|ا]ز ز", "الز", RegexOptions.IgnoreCase);
 798:                  name = Regex.Replace(name, "\\b[أ|ا]س س", "الس", RegexOptions.IgnoreCase);
 799:                  name = Regex.Replace(name, "\\b[أ|ا]ش ش", "الش", RegexOptions.IgnoreCase);
 800:                  name = Regex.Replace(name, "\\b[أ|ا]ص ص", "الص", RegexOptions.IgnoreCase);
 801:                  name = Regex.Replace(name, "\\b[أ|ا]ض ض", "الض", RegexOptions.IgnoreCase);
 802:   
 803:                  name = Regex.Replace(name, "\\b[أ|ا]ط ط", "الط", RegexOptions.IgnoreCase);
 804:                  name = Regex.Replace(name, "\\b[أ|ا]ظ ظ", "الظ", RegexOptions.IgnoreCase);
 805:                  name = Regex.Replace(name, "\\b[أ|ا]ل ل", "الل", RegexOptions.IgnoreCase);
 806:                  name = Regex.Replace(name, "\\b[أ|ا]ن ن", "الن", RegexOptions.IgnoreCase);
 807:   
 808:                  name = Regex.Replace(name, "\\b[أ|ا]ل ", "ال", RegexOptions.IgnoreCase);
 809:              }
 810:              else
 811:              {
 812:   
 813:              }
 814:   
 815:              return name;
 816:          }
 817:   
 818:          ////////////////////////////////////////////////////////////////////////////
 819:   
 820:          /// <summary>
 821:          /// Produce approximate native text of latin transliterations of native words
 822:          /// </summary>
 823:          /// <param name="name">Latin transliteration of native word</param>
 824:          /// <returns>Approximate native text</returns>
 825:          public static string ProduceApproximateNativeTextOfLatinTransliterationsOfNativeWordsAccrodingToLanguage(string iso6393, string name)
 826:          {
 827:              /*
 828:               * To match:
 829:               * '’' use '\u2019'
 830:               * '‘' use '\u2018'
 831:               */
 832:   
 833:              if (iso6393 == "ar")
 834:              {
 835:                  name = name.ToLower();
 836:   
 837:                  // for some reason I can not match "'\b"
 838:                  // does not work: name = Regex.Replace(name, "i\u2018\\b", "ع");
 839:                  // works(?): name = Regex.Replace(name, "i\u2018(\\b|$)", "ع");
 840:   
 841:                  name = Regex.Replace(name, "ayyā", "يا");
 842:                  name = Regex.Replace(name, "iyah\\b", "ية");
 843:                  name = name.Replace("dhdh", "ذ");
 844:                  name = name.Replace("thth", "ث");
 845:                  name = name.Replace("shsh", "ش");
 846:                  name = Regex.Replace(name, "deid", "ديد");
 847:   
 848:                  name = Regex.Replace(name, "lay", "لي");
 849:                  name = Regex.Replace(name, "way", "وي");
 850:                  name = Regex.Replace(name, "ain", "ين");
 851:                  name = Regex.Replace(name, "llá\\b", "لا");
 852:                  name = Regex.Replace(name, "iyā", "يا");
 853:                  name = name.Replace("yya", "ي");
 854:                  name = Regex.Replace(name, "\\bAya", "أيا");
 855:   
 856:                  name = name.Replace("mm", "م");
 857:                  name = name.Replace("bb", "ب");
 858:                  name = name.Replace("dd", "د");
 859:                  name = name.Replace("ff", "ف");
 860:                  name = name.Replace("ss", "س");
 861:                  name = name.Replace("ll", "ل");
 862:                  name = name.Replace("rr", "ر");
 863:                  name = name.Replace("zz", "ز");
 864:                  name = name.Replace("nn", "ن");
 865:                  name = name.Replace("jj", "ج");
 866:                  name = name.Replace("ww", "و");
 867:                  name = name.Replace("qq", "ق");
 868:                  name = name.Replace("tt", "ت");
 869:                  name = name.Replace("ḩḩ", "ح");
 870:                  name = name.Replace("kk", "ك");
 871:                  name = name.Replace("ţţ", "ط");
 872:                  name = name.Replace("şş", "ص");
 873:                  name = name.Replace("ḑḑ", "ض"); // not same
 874:                  name = name.Replace("ḍḍ", "ض");
 875:                  name = name.Replace("ay", "ي");
 876:                  name = name.Replace("au", "و");
 877:                  name = name.Replace("āy", "اي");
 878:                  name = name.Replace("kh", "خ");
 879:                  name = name.Replace("sh", "ش");
 880:                  name = name.Replace("th", "ث");
 881:                  name = name.Replace("dh", "ض");
 882:                  name = name.Replace("gh", "غ");
 883:   
 884:                  name = Regex.Replace(name, "ah\\b", "ة");
 885:                  name = Regex.Replace(name, "āt\\b", "ات");
 886:                  name = Regex.Replace(name, "at\\b", "ات");
 887:                  name = Regex.Replace(name, "ā\u2019i", "ائ");
 888:                  name = Regex.Replace(name, "ā\u2019(\\b|$)", "اء");
 889:                  name = Regex.Replace(name, "\u2018ā(\\b|$)", "عا");
 890:                  name = Regex.Replace(name, "\u2018a", "ع");
 891:                  name = Regex.Replace(name, "\u2018u", "ع");
 892:                  name = Regex.Replace(name, "\u2018ū", "عو");
 893:                  name = Regex.Replace(name, "\u2018ī", "عي");
 894:                  name = Regex.Replace(name, "i\u2018(\\b|$)", "ع");
 895:                  name = Regex.Replace(name, "i\u2018", "ئ");
 896:                  name = Regex.Replace(name, "i\u2019", "ئ");
 897:                  name = Regex.Replace(name, "ay\u2018\\b", "يع");
 898:                  name = Regex.Replace(name, "ay\\b", "ي");
 899:                  name = Regex.Replace(name, "ei", "ي");
 900:                  name = Regex.Replace(name, "yā", "يا");
 901:                  name = Regex.Replace(name, "ya", "ي");
 902:                  name = Regex.Replace(name, "īt\\b", "يت");
 903:                  name = Regex.Replace(name, "ḩá\\b", "حا");
 904:   
 905:                  name = Regex.Replace(name, "t\\b", "ة");
 906:                  name = name.Replace("ş", "ص");
 907:                  name = name.Replace("ḑ", "ض"); // not same
 908:                  name = name.Replace("ḍ", "ض");
 909:                  name = name.Replace("ţ", "ط");
 910:                  name = name.Replace("ā", "ا");
 911:                  name = name.Replace("a’", "ا");
 912:                  name = name.Replace("ī", "ي");
 913:                  name = name.Replace("ū", "و");
 914:                  name = name.Replace("ḩ", "ح");
 915:   
 916:                  name = Regex.Replace(name, "\\ba", "أ");
 917:                  name = Regex.Replace(name, "\\bu", "أ");
 918:                  name = Regex.Replace(name, "\\bi", "أ");
 919:                  name = Regex.Replace(name, "i\\b", "ي");
 920:                  name = Regex.Replace(name, "y\\b", "ي");
 921:   
 922:                  name = name.Replace("a", "");
 923:                  name = name.Replace("b", "ب");
 924:                  name = name.Replace("t", "ت");
 925:                  //name = name.Replace("c", "");
 926:                  name = name.Replace("j", "ج");
 927:                  name = name.Replace("g", "ج");
 928:                  name = name.Replace("d", "د");
 929:                  name = name.Replace("r", "ر");
 930:                  name = name.Replace("r", "ر");
 931:                  name = name.Replace("s", "س");
 932:                  name = name.Replace("t", "ت");
 933:                  name = name.Replace("d", "د");
 934:                  name = name.Replace("e", "");
 935:                  name = name.Replace("h", "ه");
 936:                  name = name.Replace("i", "");
 937:                  name = name.Replace("j", "ج");
 938:                  name = name.Replace("p", "ب");
 939:                  name = name.Replace("f", "ف");
 940:                  name = name.Replace("q", "ق");
 941:                  name = name.Replace("k", "ك");
 942:                  name = name.Replace("l", "ل");
 943:                  name = name.Replace("m", "م");
 944:                  name = name.Replace("n", "ن");
 945:                  name = name.Replace("h", "ه");
 946:                  name = name.Replace("u", "");
 947:                  name = name.Replace("v", "ف");
 948:                  name = name.Replace("o", "");
 949:                  name = name.Replace("w", "و");
 950:                  name = name.Replace("y", "");
 951:                  name = name.Replace("w", "و");
 952:                  name = name.Replace("z̧", "ظ"); // note this is not 'z'. KEEP THIS ORDER.
 953:                  name = name.Replace("z", "ز");
 954:                  name = name.Replace("á", "اء");
 955:   
 956:                  name = Regex.Replace(name, "\\b\u2018", "ع");
 957:   
 958:                  //name = name.Replace("7", "ح");
 959:                  //name = name.Replace("3", "ع");
 960:                  //name = name.Replace("6", "ط");
 961:   
 962:                  // name = name.Replace("", "");
 963:                  // name = Regex.Replace(name, "\\b\\b", "");
 964:              }
 965:              else
 966:              {
 967:   
 968:              }
 969:   
 970:              return name;
 971:          }
 972:   
 973:          ////////////////////////////////////////////////////////////////////////////
 974:   
 975:          /// <summary>
 976:          ///
 977:          /// </summary>
 978:          public static string ProduceExactNativeTextOfSingleLatinTransliterationsOfNativeWordsAccordingToLanguage(string iso6393, string name)
 979:          {
 980:              /*
 981:               * Remove english worlds like Island, Airport, Ridge, North, Ridge, Customs, Long, South, East, Inner,
 982:               * Channel, Reef Islet...etc.
 983:               * 
 984:               * To match:
 985:               * '’' use '\u2019'
 986:               * '‘' use "\u2018'
 987:               */
 988:   
 989:              if (iso6393 == "ar")
 990:              {
 991:                  // kw
 992:                  name = Regex.Replace(name, "\\bKhalij\\b", "خليج", RegexOptions.IgnoreCase);
 993:                  // name = Regex.Replace(name, "\\bAl Kuwait\\b", "الكويت", RegexOptions.IgnoreCase);
 994:                  //name = Regex.Replace(name, "\\bDā’irī\\b", "دائري", RegexOptions.IgnoreCase);
 995:   
 996:                  name = Regex.Replace(name, "\\bSha\u2018īb\\b", "شعيب", RegexOptions.IgnoreCase);
 997:                  name = Regex.Replace(name, "\\bSha\u2018ib\\b", "شعيب", RegexOptions.IgnoreCase);
 998:                  name = Regex.Replace(name, "\\bShi\u2018b\\b", "شعب", RegexOptions.IgnoreCase);
 999:   
1000:                  name = Regex.Replace(name, "\\bAbū\\b", "أبو", RegexOptions.IgnoreCase);
1001:                  name = Regex.Replace(name, "\\bBū\\b", "أبو", RegexOptions.IgnoreCase);
1002:                  name = Regex.Replace(name, "\\bḨisū\\b", "حسو", RegexOptions.IgnoreCase);
1003:   
1004:                  name = Regex.Replace(name, "\\bSayḩ\\b", "سيح", RegexOptions.IgnoreCase);
1005:                  name = Regex.Replace(name, "\\bKharmat\\b", "خرمة", RegexOptions.IgnoreCase);
1006:   
1007:                  name = Regex.Replace(name, "\\bŢawī\\b", "طوي", RegexOptions.IgnoreCase);
1008:                  name = Regex.Replace(name, "\\bKhaţmat\\b", "خطمة", RegexOptions.IgnoreCase);
1009:                  name = Regex.Replace(name, "\\bYadd\\b", "يد", RegexOptions.IgnoreCase);
1010:                  name = Regex.Replace(name, "\\bQāriḩat\\b", "قارحات", RegexOptions.IgnoreCase);
1011:                  name = Regex.Replace(name, "\\bGhāfat\\b", "غافة", RegexOptions.IgnoreCase);
1012:                  name = Regex.Replace(name, "\\bWara\\b", "وارة", RegexOptions.IgnoreCase);
1013:                  name = Regex.Replace(name, "\\bYabbah\\b", "يبة", RegexOptions.IgnoreCase);
1014:                  name = Regex.Replace(name, "\\bBidud\\b", "بدود", RegexOptions.IgnoreCase);
1015:                  name = Regex.Replace(name, "\\bMayy\\b", "مي", RegexOptions.IgnoreCase);
1016:                  name = Regex.Replace(name, "\\bYarīrah\\b", "يريرة", RegexOptions.IgnoreCase);
1017:                  name = Regex.Replace(name, "\\bNā\u2019if\\b", "نايف", RegexOptions.IgnoreCase);
1018:                  name = Regex.Replace(name, "\\bBarqat\\b", "برقة", RegexOptions.IgnoreCase);
1019:                  name = Regex.Replace(name, "\\bHaz\u2019", "هزع", RegexOptions.IgnoreCase);
1020:                  name = Regex.Replace(name, "\\bDhi\u2019b", "ذئب", RegexOptions.IgnoreCase);
1021:                  name = Regex.Replace(name, "\\bSuyūl\\b", "سيول", RegexOptions.IgnoreCase);
1022:                  name = Regex.Replace(name, "\\bFā\u2019iyah\\b", "فائية", RegexOptions.IgnoreCase);
1023:                  name = Regex.Replace(name, "Khawr Fakkān", "خورفكان", RegexOptions.IgnoreCase);
1024:   
1025:                  name = Regex.Replace(name, "\\bMusá\\b", "موسى", RegexOptions.IgnoreCase);
1026:   
1027:                  name = Regex.Replace(name, "\\bMuhammad\\b", "محمد", RegexOptions.IgnoreCase);
1028:                  name = Regex.Replace(name, "\\bMohammad\\b", "محمد", RegexOptions.IgnoreCase);
1029:                  name = Regex.Replace(name, "\\bMuhammed\\b", "محمد", RegexOptions.IgnoreCase);
1030:                  name = Regex.Replace(name, "\\bMohammed\\b", "محمد", RegexOptions.IgnoreCase);
1031:                  name = Regex.Replace(name, "\\bAhmad\\b", "أحمد", RegexOptions.IgnoreCase);
1032:                  name = Regex.Replace(name, "\\bAhmed\\b", "أحمد", RegexOptions.IgnoreCase);
1033:   
1034:                  name = Regex.Replace(name, "\\bWādī\\b", "وادي", RegexOptions.IgnoreCase);
1035:                  name = Regex.Replace(name, "\\bWadi\\b", "وادي", RegexOptions.IgnoreCase);
1036:                  name = Regex.Replace(name, "\\bWâdi\\b", "وادي", RegexOptions.IgnoreCase);
1037:                  name = Regex.Replace(name, "\\bWād\\b", "وادي", RegexOptions.IgnoreCase);
1038:                  name = Regex.Replace(name, "\\bWudayy\\b", "ودي", RegexOptions.IgnoreCase);
1039:   
1040:                  name = Regex.Replace(name, "\\bJaww\\b", "جو", RegexOptions.IgnoreCase);
1041:                  name = Regex.Replace(name, "\\bDarb\\b", "درب", RegexOptions.IgnoreCase);
1042:                  name = Regex.Replace(name, "\\bManākh\\b", "مناخ", RegexOptions.IgnoreCase);
1043:                  name = Regex.Replace(name, "\\bJibāl\\b", "جبال", RegexOptions.IgnoreCase);
1044:                  name = Regex.Replace(name, "\\bJibal\\b", "جبال", RegexOptions.IgnoreCase);
1045:                  name = Regex.Replace(name, "\\bRawḑat\\b", "روضة", RegexOptions.IgnoreCase);
1046:   
1047:                  name = Regex.Replace(name, "\\bNufūd\\b", "نفود", RegexOptions.IgnoreCase);
1048:                  name = Regex.Replace(name, "\\bNafūd\\b", "نفود", RegexOptions.IgnoreCase);
1049:   
1050:                  name = Regex.Replace(name, "\\bMazra\u2018at\\b", "مزرعة", RegexOptions.IgnoreCase);
1051:                  name = Regex.Replace(name, "\\bFayḑat\\b", "فيضة", RegexOptions.IgnoreCase);
1052:                  name = Regex.Replace(name, "\\bKhashm\\b", "خشم", RegexOptions.IgnoreCase);
1053:   
1054:                  name = Regex.Replace(name, "\\bĀbār\\b", "آبار", RegexOptions.IgnoreCase);
1055:                  name = Regex.Replace(name, "\\bBi\u2019r\\b", "بئر", RegexOptions.IgnoreCase);
1056:                  name = Regex.Replace(name, "\\bBi\u2018r\\b", "بئر", RegexOptions.IgnoreCase);
1057:   
1058:                  name = Regex.Replace(name, "\\bQalīb\\b", "قليب", RegexOptions.IgnoreCase);
1059:                  name = Regex.Replace(name, "\\bQulayyib\\b", "قليب", RegexOptions.IgnoreCase);
1060:                  name = Regex.Replace(name, "\\bQulbān\\b", "قلبان", RegexOptions.IgnoreCase);
1061:   
1062:                  name = Regex.Replace(name, "\\bḐulay\u2018\\b", "ضليع", RegexOptions.IgnoreCase);
1063:                  name = Regex.Replace(name, "\\bḐulū\u2018\\b", "ضلوع", RegexOptions.IgnoreCase);
1064:   
1065:                  name = Regex.Replace(name, "\\bḨaşāt\\b", "حصاة", RegexOptions.IgnoreCase);
1066:   
1067:                  name = Regex.Replace(name, "\\bJabal\\b", "جبل", RegexOptions.IgnoreCase);
1068:                  name = Regex.Replace(name, "\\bJubayl\\b", "جبيل", RegexOptions.IgnoreCase);
1069:   
1070:   
1071:                  name = Regex.Replace(name, "\\bHijrat\\b", "هجرة", RegexOptions.IgnoreCase);
1072:                  name = Regex.Replace(name, "\\bḤazm\\b", "حزم", RegexOptions.IgnoreCase);
1073:                  name = Regex.Replace(name, "\\bḨazm\\b", "حزم", RegexOptions.IgnoreCase);
1074:                  name = Regex.Replace(name, "\\bḨuzūm\\b", "حزوم", RegexOptions.IgnoreCase);
1075:   
1076:                  name = Regex.Replace(name, "\\bKhabrā\u2019\\b", "خبراء", RegexOptions.IgnoreCase);
1077:                  name = Regex.Replace(name, "\\bKhubayrā\u2019\\b", "خبيراء", RegexOptions.IgnoreCase);
1078:                  name = Regex.Replace(name, "\\bKhabrat\\b", "خبرة", RegexOptions.IgnoreCase);
1079:   
1080:                  name = Regex.Replace(name, "\\bFāj\\b", "فج", RegexOptions.IgnoreCase);
1081:                  name = Regex.Replace(name, "\\bSabkhat\\b", "صبخة", RegexOptions.IgnoreCase);
1082:                  name = Regex.Replace(name, "\\bQā\u2018\\b", "قاع", RegexOptions.IgnoreCase);
1083:                  name = Regex.Replace(name, "\\bḨalāt\\b", "حالة", RegexOptions.IgnoreCase);
1084:   
1085:                  name = Regex.Replace(name, "\u2018Irq\\b", "عرق", RegexOptions.IgnoreCase); // like that
1086:                  name = Regex.Replace(name, "\u2018Ays\\b", "عيس", RegexOptions.IgnoreCase); // like that
1087:                  name = Regex.Replace(name, "\u2018Ayb\\b", "عيب", RegexOptions.IgnoreCase); // like that
1088:   
1089:                  name = Regex.Replace(name, "\\bFiyāḑ\\b", "فياض", RegexOptions.IgnoreCase);
1090:                  name = Regex.Replace(name, "\\bHaḑb\\b", "هدب", RegexOptions.IgnoreCase);
1091:                  name = Regex.Replace(name, "\\bḨarrat\\b", "حرة", RegexOptions.IgnoreCase);
1092:   
1093:                  name = Regex.Replace(name, "\\bKhawr\\b", "خور", RegexOptions.IgnoreCase);
1094:                  name = Regex.Replace(name, "\\bAin\\b", "عين", RegexOptions.IgnoreCase);
1095:                  name = Regex.Replace(name, "\\b\u2018Ayn\\b", "عين", RegexOptions.IgnoreCase);
1096:                  name = Regex.Replace(name, "\\bḨijl\\b", "حجل", RegexOptions.IgnoreCase);
1097:   
1098:                  name = Regex.Replace(name, "\\bḨattá\\b", "حتا", RegexOptions.IgnoreCase);
1099:   
1100:                  name = Regex.Replace(name, "\\bShiqqat\\b", "شقة", RegexOptions.IgnoreCase);
1101:                  name = Regex.Replace(name, "\\b\u2018Urūq\\b", "عروق", RegexOptions.IgnoreCase);
1102:   
1103:                  name = Regex.Replace(name, "\\bQalamat\\b", "قلمة", RegexOptions.IgnoreCase);
1104:                  name = Regex.Replace(name, "\\bQulumat\\b", "قلمة", RegexOptions.IgnoreCase);
1105:   
1106:                  name = Regex.Replace(name, "\\bHadh\\b", "حد", RegexOptions.IgnoreCase);
1107:                  name = Regex.Replace(name, "\\bUmm\\b", "أم", RegexOptions.IgnoreCase);
1108:                  name = Regex.Replace(name, "\\bUmmahāt\\b", "أمهات", RegexOptions.IgnoreCase);
1109:   
1110:                  name = Regex.Replace(name, "\\bRimāl\\b", "رمال", RegexOptions.IgnoreCase);
1111:                  name = Regex.Replace(name, "\\bRamlat\\b", "رملة", RegexOptions.IgnoreCase);
1112:   
1113:                  name = Regex.Replace(name, "\\bKhayţ\\b", "خيط", RegexOptions.IgnoreCase);
1114:   
1115:                  name = Regex.Replace(name, "\\b\u2018Irq\\b", "عرق", RegexOptions.IgnoreCase);
1116:                  name = Regex.Replace(name, "\\b\u2018Urayq\\b", "عريق", RegexOptions.IgnoreCase);
1117:   
1118:                  name = Regex.Replace(name, "\\b\u2018Alam\\b", "علم", RegexOptions.IgnoreCase);
1119:                  name = Regex.Replace(name, "\\bJazīrat\\b", "جزيرة", RegexOptions.IgnoreCase);
1120:                  name = Regex.Replace(name, "\\bJezîret\\b", "جزيرة", RegexOptions.IgnoreCase);
1121:   
1122:                  name = Regex.Replace(name, "\\bJāl\\b", "جال", RegexOptions.IgnoreCase);
1123:   
1124:                  name = Regex.Replace(name, "\\bRās\\b", "رأس", RegexOptions.IgnoreCase);
1125:                  name = Regex.Replace(name, "\\bRa\u2019s", "رأس", RegexOptions.IgnoreCase); // like this
1126:   
1127:                  name = Regex.Replace(name, "\\bQal\u2018at\\b", "قلعة", RegexOptions.IgnoreCase);
1128:                  name = Regex.Replace(name, "\\bSharm\\b", "شرم", RegexOptions.IgnoreCase);
1129:                  name = Regex.Replace(name, "\\bQit\u2018at\\b", "قطعة", RegexOptions.IgnoreCase);
1130:                  name = Regex.Replace(name, "\\bTell\\b", "تل", RegexOptions.IgnoreCase);
1131:                  name = Regex.Replace(name, "\\bTall\\b", "تل", RegexOptions.IgnoreCase);
1132:                  name = Regex.Replace(name, "\\bTulūl\\b", "تلول", RegexOptions.IgnoreCase);
1133:   
1134:                  name = Regex.Replace(name, "\\bZibārat\\b", "زبارة", RegexOptions.IgnoreCase);
1135:   
1136:                  name = Regex.Replace(name, "\\bMiqnāt\\b", "مقناة", RegexOptions.IgnoreCase);
1137:                  name = Regex.Replace(name, "\\bQārat\\b", "قارة", RegexOptions.IgnoreCase);
1138:   
1139:                  name = Regex.Replace(name, "\\bMadīnat\\b", "مدينة", RegexOptions.IgnoreCase);
1140:                  name = Regex.Replace(name, "\\bMaqbarat\\b", "مقبرة", RegexOptions.IgnoreCase);
1141:                  name = Regex.Replace(name, "\\bRuḩayyat\\b", "رحية", RegexOptions.IgnoreCase);
1142:                  name = Regex.Replace(name, "\\bDawḩat\\b", "دوحة", RegexOptions.IgnoreCase);
1143:                  name = Regex.Replace(name, "\\bQaşr\\b", "قصر", RegexOptions.IgnoreCase);
1144:                  name = Regex.Replace(name, "\\bNuhaydayn\\b", "نهيدين", RegexOptions.IgnoreCase);
1145:                  name = Regex.Replace(name, "\\bBaţn\\b", "بطن", RegexOptions.IgnoreCase);
1146:                  name = Regex.Replace(name, "\\bKhullat\\b", "خلات", RegexOptions.IgnoreCase);
1147:                  name = Regex.Replace(name, "\\bGhars\\b", "غرس", RegexOptions.IgnoreCase);
1148:   
1149:                  name = Regex.Replace(name, "\\bMuqayrāt\\b", "مقيرات", RegexOptions.IgnoreCase);
1150:                  name = Regex.Replace(name, "\\bGhadīr\\b", "غدير", RegexOptions.IgnoreCase);
1151:                  name = Regex.Replace(name, "\\b\u2018Uwaynat\\b", "عوينات", RegexOptions.IgnoreCase);
1152:                  name = Regex.Replace(name, "\\b\u2018Uqlat\\b", "عقلة", RegexOptions.IgnoreCase);
1153:                  name = Regex.Replace(name, "\\bḨālat\\b", "حالة", RegexOptions.IgnoreCase);
1154:                  name = Regex.Replace(name, "\\bKhalīj\\b", "خليج", RegexOptions.IgnoreCase);
1155:   
1156:                  name = Regex.Replace(name, "\\bDaḩl\\b", "دحل", RegexOptions.IgnoreCase);
1157:                  name = Regex.Replace(name, "\\bDaḩal\\b", "دحل", RegexOptions.IgnoreCase);
1158:                  name = Regex.Replace(name, "\\bDaḩlat\\b", "دحلة", RegexOptions.IgnoreCase);
1159:   
1160:                  name = Regex.Replace(name, "\\bDil\u2018ān\\b", "دلعان", RegexOptions.IgnoreCase);
1161:                  name = Regex.Replace(name, "\\bBanī\\b", "بني", RegexOptions.IgnoreCase);
1162:                  name = Regex.Replace(name, "\\bQurūn\\b", "قرون", RegexOptions.IgnoreCase);
1163:                  name = Regex.Replace(name, "\\bMīnā\u2019\\b", "ميناء", RegexOptions.IgnoreCase);
1164:                  name = Regex.Replace(name, "\\bKhuyūţ\\b", "خيوط", RegexOptions.IgnoreCase);
1165:                  name = Regex.Replace(name, "\\bḐil\u2018ān\\b", "دلعان", RegexOptions.IgnoreCase);
1166:   
1167:                  name = Regex.Replace(name, "\\bRijm\\b", "رجم", RegexOptions.IgnoreCase);
1168:                  name = Regex.Replace(name, "\\bRujm\\b", "رجم", RegexOptions.IgnoreCase);
1169:                  name = Regex.Replace(name, "\\bRujūm\\b", "رجوم", RegexOptions.IgnoreCase);
1170:   
1171:                  name = Regex.Replace(name, "\\bHaḑabat\\b", "حدبة", RegexOptions.IgnoreCase);
1172:                  name = Regex.Replace(name, "\\bAbraq\\b", "أبرق", RegexOptions.IgnoreCase);
1173:                  name = Regex.Replace(name, "\\bSayḩ\\b", "سيح", RegexOptions.IgnoreCase);
1174:                  name = Regex.Replace(name, "\\Sāqiyat\\b", "ساقية", RegexOptions.IgnoreCase);
1175:                  name = Regex.Replace(name, "\\bQurayy\\b", "قري", RegexOptions.IgnoreCase);
1176:                  name = Regex.Replace(name, "\\bSuḩūl\\b", "سهول", RegexOptions.IgnoreCase);
1177:                  name = Regex.Replace(name, "\\bQuwīd\\b", "قويد", RegexOptions.IgnoreCase);
1178:   
1179:                  name = Regex.Replace(name, "\\bMishāsh\\b", "مشاش", RegexOptions.IgnoreCase);
1180:                  name = Regex.Replace(name, "\\bMushāsh\\b", "مشاش", RegexOptions.IgnoreCase);
1181:   
1182:                  name = Regex.Replace(name, "\\bKhubb\\b", "خب", RegexOptions.IgnoreCase);
1183:                  name = Regex.Replace(name, "\\bKhabb\\b", "خب", RegexOptions.IgnoreCase);
1184:   
1185:                  name = Regex.Replace(name, "\\bŞayhad\\b", "صيهد", RegexOptions.IgnoreCase);
1186:   
1187:                  name = Regex.Replace(name, "\\bSumr\\b", "سمر", RegexOptions.IgnoreCase);
1188:                  name = Regex.Replace(name, "\\bSamrat\\b", "سمرة", RegexOptions.IgnoreCase);
1189:                  name = Regex.Replace(name, "\\bSamrā\u2019\\b", "سمراء", RegexOptions.IgnoreCase);
1190:   
1191:                  name = Regex.Replace(name, "\\bQuşmat\\b", "قصمة", RegexOptions.IgnoreCase);
1192:                  name = Regex.Replace(name, "\\bKhafs\\b", "خفس", RegexOptions.IgnoreCase);
1193:                  name = Regex.Replace(name, "\\bJawb\\b", "جوب", RegexOptions.IgnoreCase);
1194:                  name = Regex.Replace(name, "\\b\u2018Alāt\\b", "علة", RegexOptions.IgnoreCase);
1195:                  name = Regex.Replace(name, "\\bQawz\\b", "قوز", RegexOptions.IgnoreCase);
1196:                  name = Regex.Replace(name, "\\bRijlat\\b", "رجلة", RegexOptions.IgnoreCase);
1197:                  name = Regex.Replace(name, "\\bŞafrā\u2019\\b", "صفراء", RegexOptions.IgnoreCase);
1198:                  name = Regex.Replace(name, "\\bQarn\\b", "قرن", RegexOptions.IgnoreCase);
1199:                  name = Regex.Replace(name, "\\bDibdibat\\b", "دبدبة", RegexOptions.IgnoreCase);
1200:                  name = Regex.Replace(name, "\\bThulmat\\b", "ثلمة", RegexOptions.IgnoreCase);
1201:                  name = Regex.Replace(name, "\\bBarqā\u2019\\b", "برقاء", RegexOptions.IgnoreCase);
1202:                  name = Regex.Replace(name, "\\bGhār\\b", "غار", RegexOptions.IgnoreCase);
1203:                  name = Regex.Replace(name, "\\bJisrat\\b", "جسرة", RegexOptions.IgnoreCase);
1204:                  name = Regex.Replace(name, "\\bMadārat\\b", "مدارة", RegexOptions.IgnoreCase);
1205:                  name = Regex.Replace(name, "\\bSāddat\\b", "صعدة", RegexOptions.IgnoreCase);
1206:                  name = Regex.Replace(name, "\\bŢu\u2018ūs\\b", "طعوس", RegexOptions.IgnoreCase);
1207:                  name = Regex.Replace(name, "\\bNāziyat\\b", "نازية", RegexOptions.IgnoreCase);
1208:                  name = Regex.Replace(name, "\\bQi\u2018r\\b", "قعر", RegexOptions.IgnoreCase);
1209:                  name = Regex.Replace(name, "\\bḨabl\\b", "حبل", RegexOptions.IgnoreCase);
1210:                  name = Regex.Replace(name, "\\bBinīyat\\b", "بنية", RegexOptions.IgnoreCase);
1211:                  name = Regex.Replace(name, "\\bSahlat\\b", "سحلة", RegexOptions.IgnoreCase);
1212:                  name = Regex.Replace(name, "\\bŢa\u2018aysāt\\b", "طعيسة", RegexOptions.IgnoreCase);
1213:                  name = Regex.Replace(name, "\\bQaţ\u2018at\\b", "قطعة", RegexOptions.IgnoreCase);
1214:                  name = Regex.Replace(name, "\\bJadhmā\u2019\\b", "جدماء", RegexOptions.IgnoreCase);
1215:   
1216:                  name = Regex.Replace(name, "\\bHashm\\b", "هشم", RegexOptions.IgnoreCase);
1217:                  name = Regex.Replace(name, "\\bJar\u2018ā\\b", "جرعاء", RegexOptions.IgnoreCase);
1218:                  name = Regex.Replace(name, "\\bQūr\\b", "قور", RegexOptions.IgnoreCase);
1219:                  name = Regex.Replace(name, "\\bḨammat\\b", "حمة", RegexOptions.IgnoreCase);
1220:                  name = Regex.Replace(name, "\\bShāţi\u2019\\b", "شاطيء", RegexOptions.IgnoreCase);
1221:                  name = Regex.Replace(name, "\\bŢi\u2018s\\b", "طعس", RegexOptions.IgnoreCase);
1222:                  name = Regex.Replace(name, "\\bḨamrūr\\b", "حمرور", RegexOptions.IgnoreCase);
1223:                  name = Regex.Replace(name, "\\bLābat\\b", "لابة", RegexOptions.IgnoreCase);
1224:                  name = Regex.Replace(name, "\\bDuwaykhilat\\b", "دويخيلات", RegexOptions.IgnoreCase);
1225:                  name = Regex.Replace(name, "\\bMarsá\\b", "مرسى", RegexOptions.IgnoreCase);
1226:                  name = Regex.Replace(name, "\\bDi\u2018b\\b", "دعب", RegexOptions.IgnoreCase);
1227:                  name = Regex.Replace(name, "\\b\u2018Idd\\b", "عد", RegexOptions.IgnoreCase);
1228:                  name = Regex.Replace(name, "\\b\u2018Ulaym\\b", "عليم", RegexOptions.IgnoreCase);
1229:                  name = Regex.Replace(name, "\\bFasht\\b", "فشت", RegexOptions.IgnoreCase);
1230:                  name = Regex.Replace(name, "\\bUfīḩim\\b", "عفحم", RegexOptions.IgnoreCase);
1231:                  name = Regex.Replace(name, "\\bMazāri\u2018\\b", "مزارع", RegexOptions.IgnoreCase);
1232:                  name = Regex.Replace(name, "\\bŢawīl\\b", "طويل", RegexOptions.IgnoreCase);
1233:                  name = Regex.Replace(name, "\\bWark\\b", "ورك", RegexOptions.IgnoreCase);
1234:                  name = Regex.Replace(name, "\\bMaḩfūr\\b", "محفور", RegexOptions.IgnoreCase);
1235:   
1236:                  name = Regex.Replace(name, "\\b\u2018Abl\\b", "عبل", RegexOptions.IgnoreCase);
1237:                  name = Regex.Replace(name, "\\bBinī\\b", "بني", RegexOptions.IgnoreCase);
1238:                  name = Regex.Replace(name, "\\bḨuşaydat\\b", "حصيدة", RegexOptions.IgnoreCase);
1239:                  name = Regex.Replace(name, "\\bNuqrat\\b", "نقرة", RegexOptions.IgnoreCase);
1240:                  name = Regex.Replace(name, "\\bRumḩayn\\b", "رمحين", RegexOptions.IgnoreCase);
1241:                  name = Regex.Replace(name, "\\bFarshat\\b", "فرشت", RegexOptions.IgnoreCase);
1242:                  name = Regex.Replace(name, "\\bNaqā\\b", "نقا", RegexOptions.IgnoreCase);
1243:                  name = Regex.Replace(name, "\\bNuşaylāt\\b", "نصيلات", RegexOptions.IgnoreCase);
1244:                  name = Regex.Replace(name, "\\bSudd\\b", "سد", RegexOptions.IgnoreCase);
1245:                  name = Regex.Replace(name, "\\b\u2018Aqabat\\b", "عقبة", RegexOptions.IgnoreCase);
1246:                  name = Regex.Replace(name, "\\bS\u2019irat\\b", "سعرة", RegexOptions.IgnoreCase);
1247:                  name = Regex.Replace(name, "\\bTawal\\b", "طوال", RegexOptions.IgnoreCase);
1248:                  name = Regex.Replace(name, "\\bBaḩr\\b", "بحر", RegexOptions.IgnoreCase);
1249:                  name = Regex.Replace(name, "\\bNajfat\\b", "نجفة", RegexOptions.IgnoreCase);
1250:                  name = Regex.Replace(name, "\\bRaḑmat\\b", "ردمة", RegexOptions.IgnoreCase);
1251:                  name = Regex.Replace(name, "\\bŢiwāl\\b", "طوال", RegexOptions.IgnoreCase);
1252:                  name = Regex.Replace(name, "\\bSahl\\b", "سهل", RegexOptions.IgnoreCase);
1253:                  name = Regex.Replace(name, "\\bQīzān\\b", "قيزان", RegexOptions.IgnoreCase);
1254:                  name = Regex.Replace(name, "\\bHadhlūl\\b", "هدلول", RegexOptions.IgnoreCase);
1255:   
1256:                  name = Regex.Replace(name, "\\bIbn\\b", "إبن", RegexOptions.IgnoreCase);
1257:                  name = Regex.Replace(name, "\\bMīnā’\\b", "ميناء", RegexOptions.IgnoreCase);
1258:                  name = Regex.Replace(name, "\\bMūsá\\b", "موسى", RegexOptions.IgnoreCase);
1259:   
1260:                  name = name.Replace("‘Iyāl", "عيال");
1261:              }
1262:              else
1263:              {
1264:   
1265:              }
1266:   
1267:              return name;
1268:          }
1269:   
1270:          ////////////////////////////////////////////////////////////////////////////
1271:   
1272:          /// <summary>
1273:          /// From a country code this will return the main language used in this country.
1274:          /// </summary>
1275:          /// <param name="countryCode">Country code (iso2)</param>
1276:          /// <returns>Language Code (ISO 639-2)</returns>
1277:          public static string ReturnLanguageCodeUsedInCountryFromCountyCode(string countryCode)
1278:          {
1279:              // Incomplete
1280:   
1281:              string languageCode;
1282:   
1283:              countryCode = countryCode.ToLower();
1284:   
1285:              switch (countryCode)
1286:              {
1287:                  // Korea
1288:                  case "kr":
1289:                  case "kp": languageCode = "ko"; break;
1290:   
1291:                  // Japan
1292:                  case "jp": languageCode = "ja"; break;
1293:   
1294:                  // Arab countries
1295:                  case "dz":
1296:                  case "bh":
1297:                  case "eg":
1298:                  case "iq":
1299:                  case "jo":
1300:                  case "kw":
1301:                  case "lb":
1302:                  case "ly":
1303:                  case "mr":
1304:                  case "ma":
1305:                  case "om":
1306:                  case "ps":
1307:                  case "qa":
1308:                  case "sa":
1309:                  case "so":
1310:                  case "sd":
1311:                  case "sy":
1312:                  case "tn":
1313:                  case "ae":
1314:                  case "ye": languageCode = "ar"; break;
1315:   
1316:                  // Iran, Afghanistan, Tajikistan
1317:                  case "ir":
1318:                  case "af":
1319:                  case "tj": languageCode = "fa"; break; // Persian
1320:   
1321:                  // English
1322:                  default: languageCode = "en"; break; // English
1323:              }
1324:   
1325:              return languageCode;
1326:          }
1327:   
1328:          ////////////////////////////////////////////////////////////////////////////
1329:   
1330:          /// <summary>
1331:          /// Return the first language used by this user
1332:          /// <param name="userLanguages">This should be HttpContext.Current.Request from webpages</param>
1333:          /// </summary>
1334:          public static string ReturnUserLanguage(HttpRequest userLanguages)
1335:          {
1336:              string language;
1337:              string[] languages = HttpContext.Current.Request.UserLanguages;
1338:   
1339:              if (languages == null || languages.Length == 0)
1340:              {
1341:                  language = null;
1342:              }
1343:              else
1344:              {
1345:                  try
1346:                  {
1347:                      language = languages[0].ToLowerInvariant().Trim();
1348:                      language = language.Substring(0, 2);
1349:                  }
1350:                  catch (ArgumentException)
1351:                  {
1352:                      language = null;
1353:                  }
1354:              }
1355:   
1356:              return language;
1357:          }
1358:   
1359:          ////////////////////////////////////////////////////////////////////////////
1360:   
1361:          /// <summary>
1362:          /// Remove the small Koranic jawaz and sili characters because they cause the displayed text to render unstable
1363:          /// </summary>
1364:          /// <param name="line"></param>
1365:          /// <returns>cleaned line</returns>
1366:          public static string RemoveSmallKoranicJawazAndSiliCharacters(string line)
1367:          {
1368:              // 
1369:              // remove ۚ and ۖ
1370:   
1371:              // remove the small character as it makes text unstable
1372:              line = line.Replace(" ۚ", ""); // small ج
1373:              line = line.Replace(" ۖ", ""); // small  صلى
1374:   
1375:              return line;
1376:          }
1377:   
1378:          ////////////////////////////////////////////////////////////////////////////
1379:   
1380:          /// <summary>
1381:          ///
1382:          /// </summary>
1383:          /// <param name="line"></param>
1384:          /// <returns>cleaned line</returns>
1385:          public static string SlightlyChangeSomeSentencesToPreventSystemFromGeneratingSingleCharacters(string line)
1386:          {
1387:              // slightly change sentences to prevent system single characters
1388:              //s = s.Replace("الله", "اللـه");
1389:              //s = s.Replace("ريال", "ريـال");
1390:              //s = s.Replace("محمد", "مـحمد");
1391:              //s = s.Replace("جل جلاله", "جل جلالـه");
1392:              line = line.Replace("صلى الله عليه وسلم", "صـلى الله عليه وسلم");
1393:   
1394:              return line;
1395:          }
1396:   
1397:          ////////////////////////////////////////////////////////////////////////////
1398:   
1399:          /// <summary>
1400:          ///
1401:          /// </summary>
1402:          public static string Pluralize(string word)
1403:          {
1404:              string s;
1405:   
1406:              s = PluralizationService.CreateService(CultureInfo.CurrentCulture).Pluralize(word);
1407:   
1408:              return s;
1409:          }
1410:   
1411:          ////////////////////////////////////////////////////////////////////////////
1412:   
1413:          /// <summary>
1414:          ///
1415:          /// </summary>
1416:          public static string FirstCharacterToUpper(string input)
1417:          {
1418:              string s;
1419:   
1420:              if (!string.IsNullOrEmpty(input)) s = input.First().ToString().ToUpper() + String.Join("", input.Skip(1));
1421:              else s = input;
1422:   
1423:              return s;
1424:          }
1425:          
1426:          ////////////////////////////////////////////////////////////////////////////
1427:   
1428:          /// <summary>
1429:          /// Checks if a word contains a German diacritic letter.
1430:          /// <see cref="http://en.wikipedia.org/wiki/German_alphabet"/>
1431:          /// </summary>
1432:          /// <remarks> 
1433:          /// German uses letter-diacritic combinations (Ä/ä, Ö/ö, Ü/ü) using the umlaut and one ligature (ß (called eszett (sz) or scharfes S, sharp s)), but they do not constitute distinct letters in the alphabet.
1434:          /// </remarks>
1435:          /// </summary>
1436:          public static bool ContainsGermanDiacriticLetter(string line)
1437:          {
1438:              bool lineContainsGermanDiacriticLetter;
1439:   
1440:              if (line != null)
1441:              {
1442:                  lineContainsGermanDiacriticLetter = Regex.IsMatch(line, "[ÄäÖöÜüß]");
1443:              }
1444:              else lineContainsGermanDiacriticLetter = false;
1445:   
1446:              return lineContainsGermanDiacriticLetter;
1447:          }
1448:   
1449:          ////////////////////////////////////////////////////////////////////////////
1450:   
1451:          /// <summary>
1452:          ///
1453:          /// </summary>
1454:          public static List<Language> List
1455:          {
1456:              get
1457:              {
1458:                  if (languageList == null || languageList.Count == 0)
1459:                  {
1460:                      //  <language iso_639_1="aa" iso_639_2_5="aar" iso_639_3="aar" name="" englishName="Afar" arabicName="" scope="" type=""/> 
1461:                      languageList = (from q in XDocument.Elements("languageList").Elements("iso").Elements("language")
1462:                                      where q.Attribute("iso_639_1").Value != "" && q.Attribute("iso_639_2_5").Value != "" && q.Attribute("iso_639_3").Value != ""
1463:                                      select new Language
1464:                                      {
1465:                                          Symbol = q.Attribute("iso_639_1").Value,
1466:                                          Iso6391 = q.Attribute("iso_639_1").Value,
1467:                                          Iso63925 = q.Attribute("iso_639_2_5").Value,
1468:                                          Iso6393 = q.Attribute("iso_639_3").Value,
1469:                                          Name = q.Attribute("name").Value,
1470:                                          EnglishName = q.Attribute("englishName").Value,
1471:                                          ArabicName = q.Attribute("arabicName").Value
1472:                                      }
1473:                      ).ToList<Language>();
1474:                  }
1475:   
1476:                  return languageList;
1477:              }
1478:          }
1479:   
1480:          ////////////////////////////////////////////////////////////////////////////
1481:   
1482:          /// <summary>
1483:          /// 
1484:          /// How to embed and access resources by using Visual C# http://support.microsoft.com/kb/319292/en-us
1485:          /// 
1486:          /// 1. Change the "Build Action" property of your XML file from "Content" to "Embedded Resource".
1487:          /// 2. Add "using System.Reflection".
1488:          /// 3. See sample below.
1489:          /// 
1490:          /// </summary>
1491:   
1492:          private static XDocument XDocument
1493:          {
1494:              get
1495:              {
1496:                  Assembly _assembly;
1497:                  StreamReader streamReader;
1498:   
1499:                  xDocument = null;
1500:                  _assembly = Assembly.GetExecutingAssembly();
1501:                  streamReader = new StreamReader(_assembly.GetManifestResourceStream("Ia.Cl.model.language.xml"));
1502:   
1503:                  try
1504:                  {
1505:                      if (streamReader.Peek() != -1)
1506:                      {
1507:                          xDocument = System.Xml.Linq.XDocument.Load(streamReader);
1508:                      }
1509:                  }
1510:                  catch (Exception)
1511:                  {
1512:                  }
1513:                  finally
1514:                  {
1515:                  }
1516:   
1517:                  return xDocument;
1518:              }
1519:          }
1520:   
1521:          ////////////////////////////////////////////////////////////////////////////
1522:          ////////////////////////////////////////////////////////////////////////////
1523:      }
1524:   
1525:      ////////////////////////////////////////////////////////////////////////////
1526:      ////////////////////////////////////////////////////////////////////////////
1527:  }