Projects (GanjooRazor -> DiwanRazor, GanjoorService.sln -> DiwanService.sln), files, folders, classes, namespaces, settings, API routes (/api/diwan) and DB tables (Diwan*). External addresses (ganjoor.net, github.com/ganjoor) unchanged. Migrations renamed consistently (no pending model changes); requires a fresh database. Upstream RUNNING_LOCALLY/SEMANTIC_SEARCH docs archived unmodified under docs/. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
118 lines
3.0 KiB
C#
118 lines
3.0 KiB
C#
using System.Collections.Generic;
|
||
|
||
namespace RMuseum.Services.Implementation.ImportedFromDesktopDiwan
|
||
{
|
||
/// <summary>
|
||
/// Persian specific text utility class
|
||
/// </summary>
|
||
public class GPersianTextSync
|
||
{
|
||
/// <summary>
|
||
/// convert persian text to simple pinglish
|
||
/// </summary>
|
||
/// <param name="inputStr"></param>
|
||
/// <returns></returns>
|
||
public static string Farglisize(string inputStr)
|
||
{
|
||
string outStr = "";
|
||
string s;
|
||
foreach (char c in inputStr)
|
||
if (_PinglishDic.TryGetValue(c, out s))
|
||
outStr += s;
|
||
return outStr;
|
||
}
|
||
|
||
|
||
/// <summary>
|
||
/// equaivalnet for persian characters
|
||
/// </summary>
|
||
private static Dictionary<char, string> _PinglishDic = new Dictionary<char, string>()
|
||
{
|
||
{'ا', "a"},
|
||
{'آ', "a"},
|
||
{'ب', "b"},
|
||
{'پ', "p"},
|
||
{'ت', "t"},
|
||
{'ث', "s"},
|
||
{'ج', "j"},
|
||
{'چ', "ch"},
|
||
{'ح', "h"},
|
||
{'خ', "kh"},
|
||
{'د', "d"},
|
||
{'ذ', "z"},
|
||
{'ر', "r"},
|
||
{'ز', "z"},
|
||
{'ژ', "zh"},
|
||
{'س', "s"},
|
||
{'ش', "sh"},
|
||
{'ص', "s"},
|
||
{'ض', "z"},
|
||
{'ط', "t"},
|
||
{'ظ', "z"},
|
||
{'ع', "E"},
|
||
{'غ', "gh"},
|
||
{'ف', "f"},
|
||
{'ق', "gh"},
|
||
{'ک', "k"},
|
||
{'گ', "g"},
|
||
{'ل', "l"},
|
||
{'م', "m"},
|
||
{'ن', "n"},
|
||
{'ه', "h"},
|
||
{'و', "v"},
|
||
{'ی', "i"},
|
||
{'ئ', "E"},
|
||
{'أ', "A"},
|
||
{'إ', "E"},
|
||
{' ', "-"},
|
||
};
|
||
|
||
public static string UniquelyFarglisize(string inputStr)
|
||
{
|
||
string outStr = "";
|
||
string s;
|
||
foreach (char c in inputStr)
|
||
if (_UniqueAlphaNames.TryGetValue(c, out s))
|
||
outStr += s;
|
||
return outStr;
|
||
}
|
||
|
||
|
||
private static Dictionary<char, string> _UniqueAlphaNames = new Dictionary<char, string>()
|
||
{
|
||
{'ا', "a"},
|
||
{'آ', "a"},
|
||
{'ب', "b"},
|
||
{'پ', "p"},
|
||
{'ت', "t"},
|
||
{'ث', "th"},
|
||
{'ج', "j"},
|
||
{'چ', "ch"},
|
||
{'ح', "hh"},
|
||
{'خ', "kh"},
|
||
{'د', "d"},
|
||
{'ذ', "the"},
|
||
{'ر', "r"},
|
||
{'ز', "z"},
|
||
{'س', "si"},
|
||
{'ش', "sh"},
|
||
{'ط', "tt"},
|
||
{'ظ', "zz"},
|
||
{'ص', "ss"},
|
||
{'ض', "zzz"},
|
||
{'ع', "e"},
|
||
{'غ', "gh2"},
|
||
{'ف', "f"},
|
||
{'ق', "gh"},
|
||
{'ک', "k"},
|
||
{'گ', "g"},
|
||
{'ل', "l"},
|
||
{'م', "m"},
|
||
{'ن', "n"},
|
||
{'ه', "h"},
|
||
{'و', "v"},
|
||
{'ی', "y"},
|
||
};
|
||
}
|
||
}
|