divan/RMuseum/Services/Implementation/ImportedFromDesktopDiwan/GPersianTextSync.cs
Anas Rashid e8f2306422 Rename Ganjoor -> Diwan throughout the code
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>
2026-10-04 23:49:01 +02:00

118 lines
3.0 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

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"},
};
}
}