)>}]
شركة التطبيقات المتكاملة لتصميم وبرمجة البرمجيات الخاصة ش.ش.و.
Integrated Applications Programming Company
Home » Code Library » Language (Ia.Cl.Models)

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