refactoring

This commit is contained in:
Hamid Reza Mohammadi 2021-06-10 10:15:41 +04:30
parent 4024f1e692
commit 386f5b8237
4 changed files with 34 additions and 32 deletions

View File

@ -107,7 +107,7 @@ namespace GanjooRazor.Pages
LoggedIn = !string.IsNullOrEmpty(Request.Cookies["Token"]);
Query = Request.Query["s"].ApplyCorrectYeKe().Trim();
Query = GanjoorService.MakeTextSearchable(Query); //replace zwnj with space
Query = LanguageUtils.MakeTextSearchable(Query); //replace zwnj with space
PoetId = string.IsNullOrEmpty(Request.Query["author"]) ? 0 : int.Parse(Request.Query["author"]);
CatId = string.IsNullOrEmpty(Request.Query["cat"]) ? 0 : int.Parse(Request.Query["cat"]);

View File

@ -8654,13 +8654,6 @@
<param name="imageId"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.MakeTextSearchable(System.String)">
<summary>
make text searchable
</summary>
<param name="text"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.GanjoorService.PreparePlainText(System.Collections.Generic.List{RMuseum.Models.Ganjoor.GanjoorVerse})">
<summary>
make plain text
@ -8768,6 +8761,13 @@
<param name="additional"></param>
<returns></returns>
</member>
<member name="M:RMuseum.Services.Implementation.LanguageUtils.MakeTextSearchable(System.String)">
<summary>
make text searchable
</summary>
<param name="text"></param>
<returns></returns>
</member>
<member name="T:RMuseum.Services.Implementation.MusicCatalogueService">
<summary>
Music Catalgue Service Implementation

View File

@ -2601,29 +2601,7 @@ namespace RMuseum.Services.Implementation
}
}
/// <summary>
/// make text searchable
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static string MakeTextSearchable(string text)
{
return text.Replace("‌", " ")//replace zwnj with space
.Replace("ّ", "")//tashdid
.Replace("َ", "")//a
.Replace("ِ", "")//e
.Replace("ُ", "")//o
.Replace("ً", "")//an
.Replace("ٍ", "")//en
.Replace("ٌ", "")//on
.Replace(".", "")//dot
.Replace("،", "")//virgool
.Replace("!", "")
.Replace("؟", "")
.Replace("ٔ", "")
.Replace(":", "")
;
}
/// <summary>
/// make plain text
@ -2635,7 +2613,7 @@ namespace RMuseum.Services.Implementation
string plainText = "";
foreach (GanjoorVerse verse in verses)
{
plainText += $"{MakeTextSearchable(verse.Text)}{Environment.NewLine}";//replace zwnj with space
plainText += $"{LanguageUtils.MakeTextSearchable(verse.Text)}{Environment.NewLine}";//replace zwnj with space
}
return plainText.Trim();
}

View File

@ -30,5 +30,29 @@
return (c + "");
return "";
}
/// <summary>
/// make text searchable
/// </summary>
/// <param name="text"></param>
/// <returns></returns>
public static string MakeTextSearchable(string text)
{
return text.Replace("‌", " ")//replace zwnj with space
.Replace("ّ", "")//tashdid
.Replace("َ", "")//a
.Replace("ِ", "")//e
.Replace("ُ", "")//o
.Replace("ً", "")//an
.Replace("ٍ", "")//en
.Replace("ٌ", "")//on
.Replace(".", "")//dot
.Replace("،", "")//virgool
.Replace("!", "")
.Replace("؟", "")
.Replace("ٔ", "")
.Replace(":", "")
;
}
}
}