diff --git a/RMuseum/Services/Implementation/GanjoorPoemFormatConvertor.cs b/RMuseum/Services/Implementation/GanjoorPoemFormatConvertor.cs index 3d5cb573..71e3c3e5 100644 --- a/RMuseum/Services/Implementation/GanjoorPoemFormatConvertor.cs +++ b/RMuseum/Services/Implementation/GanjoorPoemFormatConvertor.cs @@ -65,6 +65,8 @@ namespace RMuseum.Services.Implementation return "چند بندی"; case GanjoorPoemFormat.BahreTavil: return "بحر طویل"; + case GanjoorPoemFormat.Unknown: + return "نامشخص"; } return ""; } diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-Stats.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-Stats.cs index 72638c6f..c01b54c0 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-Stats.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-Stats.cs @@ -28,6 +28,13 @@ namespace RMuseum.Services.Implementation public int Count { get; set; } } + internal class PoemFormatCoupletCount + { + public GanjoorPoemFormat Format { get; set; } + + public int Count { get; set; } + } + /// /// IGanjoorService implementation /// @@ -329,6 +336,45 @@ namespace RMuseum.Services.Implementation languagesCoupletsCountsUnprocessed.Sort((a, b) => b.Count - a.Count); + + await jobProgressServiceEF.UpdateJob(job.Id, 1, "Counting Poem Formats"); + var formatsResult = await (from v in context.GanjoorVerses.AsNoTracking().Include(v => v.Poem).ThenInclude(p => p.Cat).ThenInclude(c => c.Poet) + from s in context.GanjoorPoemSections + where v.PoemId == s.PoemId && v.SectionIndex1 == s.Index && s.SectionType == PoemSectionType.WholePoem + && + v.Poem.Cat.Poet.Published + && + (v.VersePosition == VersePosition.Right || v.VersePosition == VersePosition.CenteredVerse1) + group s.PoemFormat by s.PoemFormat into g + select new { PoemFormat = g.Key, Count = g.Count() }).ToListAsync(); + + + List formatCoupletsCountsUnprocessed = new List + { + new PoemFormatCoupletCount() + { + Format = GanjoorPoemFormat.Unknown, + Count = 0 + } + }; + foreach (var item in formatsResult) + { + if (item.PoemFormat == null || item.PoemFormat == GanjoorPoemFormat.Unknown) + { + var fa = formatCoupletsCountsUnprocessed.Where(l => l.Format == GanjoorPoemFormat.Unknown).Single(); + fa.Count += item.Count; + } + else + formatCoupletsCountsUnprocessed.Add(new PoemFormatCoupletCount() + { + Format = (GanjoorPoemFormat)item.PoemFormat, + Count = item.Count + }); + } + + formatCoupletsCountsUnprocessed.Sort((a, b) => b.Count - a.Count); + + await jobProgressServiceEF.UpdateJob(job.Id, 1, "Counting whole sections"); @@ -444,6 +490,32 @@ namespace RMuseum.Services.Implementation } htmlText += $"{Environment.NewLine}"; + htmlText += $"

آمار ابیات برچسب‌گذاری شده با قالب شعری در گنجور به شرح زیر است:

{Environment.NewLine}"; + + htmlText += $"{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}" + + $"{Environment.NewLine}"; + + for (int i = 0; i < formatCoupletsCountsUnprocessed.Count; i++) + { + if (i % 2 == 0) + htmlText += $"{Environment.NewLine}"; + else + htmlText += $"{Environment.NewLine}"; + + htmlText += $"{Environment.NewLine}"; + htmlText += $"{Environment.NewLine}"; + htmlText += $"{Environment.NewLine}"; + htmlText += $"{Environment.NewLine}"; + + htmlText += $"{Environment.NewLine}"; + } + htmlText += $"
ردیفقالب شعریتعداد ابیاتدرصد از کل
{(i + 1).ToPersianNumbers()}{GanjoorPoemFormatConvertor.GetString(formatCoupletsCountsUnprocessed[i].Format)}{LanguageUtils.FormatMoney(formatCoupletsCountsUnprocessed[i].Count)}{(formatCoupletsCountsUnprocessed[i].Count * 100.0 / sumPoetsCouplets).ToString("N2", new CultureInfo("fa-IR")).ToPersianNumbers()}
{Environment.NewLine}"; + var rhythms = await context.GanjoorMetres.ToListAsync();