From a29168696c4b79ba7b5f893b2e956dacd55e2e42 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Tue, 28 Jan 2025 11:20:44 +0330 Subject: [PATCH] stats for poems couplet counts in categories #464 --- RMuseum/Models/Ganjoor/GanjoorPoemSection.cs | 5 +++++ RMuseum/RMuseum.xml | 5 +++++ .../GanjoorService-BreakPoem.cs | 2 ++ .../GanjoorService-ModeratePoemCorrection.cs | 2 ++ .../GanjoorService-ModerateSectionCorrection.cs | 4 ++++ .../GanjoorService-PoemSections.cs | 10 ++++++++++ 6 files changed, 28 insertions(+) diff --git a/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs b/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs index 6d33acf2..548a7bb5 100644 --- a/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs +++ b/RMuseum/Models/Ganjoor/GanjoorPoemSection.cs @@ -100,6 +100,11 @@ namespace RMuseum.Models.Ganjoor /// public string Language { get; set; } + /// + /// couplets count + /// + public int CoupletsCount { get; set; } + /// /// top 6 related sections /// diff --git a/RMuseum/RMuseum.xml b/RMuseum/RMuseum.xml index ccfe78b8..c5767618 100644 --- a/RMuseum/RMuseum.xml +++ b/RMuseum/RMuseum.xml @@ -9143,6 +9143,11 @@ language, null means farsi + + + couplets count + + top 6 related sections diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-BreakPoem.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-BreakPoem.cs index c8a02960..7ad72ad5 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-BreakPoem.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-BreakPoem.cs @@ -326,6 +326,7 @@ namespace RMuseum.Services.Implementation PoemFormat = section.PoemFormat, }; var sectionVerses = FilterSectionVerses(sectionCopy, targetPoemVerses); + sectionCopy.CoupletsCount = sectionVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); sectionCopy.HtmlText = PrepareHtmlText(sectionVerses); sectionCopy.PlainText = PreparePlainText(sectionVerses); try @@ -524,6 +525,7 @@ namespace RMuseum.Services.Implementation PoemFormat = section.PoemFormat, }; var sectionVerses = FilterSectionVerses(sectionCopy, targetPoemVerses); + sectionCopy.CoupletsCount = sectionVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); sectionCopy.HtmlText = PrepareHtmlText(sectionVerses); sectionCopy.PlainText = PreparePlainText(sectionVerses); try diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModeratePoemCorrection.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModeratePoemCorrection.cs index 6d70a426..caab3821 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModeratePoemCorrection.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModeratePoemCorrection.cs @@ -532,6 +532,7 @@ namespace RMuseum.Services.Implementation PlainText = mainSection.PlainText, PoemFormat = mainSection.PoemFormat, }; + secondMetreSection.CoupletsCount = poemVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); _context.Add(secondMetreSection); sections.Add(secondMetreSection); @@ -561,6 +562,7 @@ namespace RMuseum.Services.Implementation PoemFormat = secondLevelSections.PoemFormat, GanjoorMetreRefSectionIndex = secondMetreSection.Index, }; + newSection.CoupletsCount = poemVerses.Where(v => v.SectionIndex2 == secondLevelSections.Index && (v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1)).Count(); _context.Add(newSection); sections.Add(newSection); diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateSectionCorrection.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateSectionCorrection.cs index 9c14b5ab..6cdc47b0 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateSectionCorrection.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-ModerateSectionCorrection.cs @@ -461,6 +461,7 @@ namespace RMuseum.Services.Implementation bool sectionCopyBecameMasnavi = false; var sectionCopyVerses = FilterSectionVerses(sectionCopy, verses); + sectionCopy.CoupletsCount = sectionCopyVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); sectionCopy.HtmlText = PrepareHtmlText(sectionCopyVerses); sectionCopy.PlainText = PreparePlainText(sectionCopyVerses); sectionCopy.RhymeLetters = LanguageUtils.FindRhyme(sectionCopyVerses).Rhyme; @@ -539,6 +540,7 @@ namespace RMuseum.Services.Implementation } var relatedSectionCopyVerses = FilterSectionVerses(relatedSectionCopy, verses); + relatedSectionCopy.CoupletsCount = relatedSectionCopyVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); relatedSectionCopy.HtmlText = PrepareHtmlText(relatedSectionCopyVerses); relatedSectionCopy.PlainText = PreparePlainText(relatedSectionCopyVerses); relatedSectionCopy.RhymeLetters = LanguageUtils.FindRhyme(relatedSectionCopyVerses).Rhyme; @@ -591,6 +593,7 @@ namespace RMuseum.Services.Implementation leftVerse.SectionIndex2 = verseSection.Index; var rl = new List(); rl.Add(rightVerse); rl.Add(leftVerse); + verseSection.CoupletsCount = rl.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); verseSection.HtmlText = PrepareHtmlText(rl); verseSection.PlainText = PreparePlainText(rl); verseSection.Modified = true; @@ -629,6 +632,7 @@ namespace RMuseum.Services.Implementation leftVerse.SectionIndex2 = verseSection.Index; var rl = new List(); rl.Add(rightVerse); rl.Add(leftVerse); + verseSection.CoupletsCount = rl.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); verseSection.HtmlText = PrepareHtmlText(rl); verseSection.PlainText = PreparePlainText(rl); verseSection.Modified = true; diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs index 6aff63be..91069e93 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs @@ -337,6 +337,7 @@ namespace RMuseum.Services.Implementation RhymeLetters = poem.RhymeLetters, HtmlText = PrepareHtmlText(singleVerses), PlainText = PreparePlainText(singleVerses), + CoupletsCount = singleVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(), PoemFormat = GanjoorPoemFormat.New, }; context.Add(mainSection);//having a main section for مثنوی inside normal text helps keep track of related versess @@ -408,6 +409,7 @@ namespace RMuseum.Services.Implementation RhymeLetters = poem.RhymeLetters, HtmlText = PrepareHtmlText(singleVerses), PlainText = PreparePlainText(singleVerses), + CoupletsCount = singleVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(), PoemFormat = GanjoorPoemFormat.New, }; context.Add(mainSection);//having a main section for مثنوی inside normal text helps keep track of related versess @@ -454,6 +456,7 @@ namespace RMuseum.Services.Implementation RhymeLetters = poem.RhymeLetters, HtmlText = PrepareHtmlText(nonCommentVerses), PlainText = PreparePlainText(nonCommentVerses), + CoupletsCount = nonCommentVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(), PoemFormat = GanjoorPoemFormat.MultiBand, }; if (poem.FullTitle.Contains("ترجیع")) @@ -506,6 +509,7 @@ namespace RMuseum.Services.Implementation } currentBandSection.RhymeLetters = LanguageUtils.FindRhyme(currentBandVerses).Rhyme; currentBandSection.HtmlText = PrepareHtmlText(currentBandVerses); + currentBandSection.CoupletsCount = currentBandVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); currentBandSection.PlainText = PreparePlainText(currentBandVerses); context.Add(currentBandSection); @@ -533,6 +537,7 @@ namespace RMuseum.Services.Implementation currentBandVerse.SectionIndex2 = currentBandSection.Index; } currentBandSection.RhymeLetters = LanguageUtils.FindRhyme(currentBandVerses).Rhyme; + currentBandSection.CoupletsCount = currentBandVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); currentBandSection.HtmlText = PrepareHtmlText(currentBandVerses); currentBandSection.PlainText = PreparePlainText(currentBandVerses); context.Add(currentBandSection); @@ -598,6 +603,7 @@ namespace RMuseum.Services.Implementation var rl = new List(); rl.Add(rightVerse); rl.Add(leftVerse); verseSection.HtmlText = PrepareHtmlText(rl); verseSection.PlainText = PreparePlainText(rl); + verseSection.CoupletsCount = rl.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); context.Add(verseSection); } @@ -608,6 +614,7 @@ namespace RMuseum.Services.Implementation } bandSection.HtmlText = PrepareHtmlText(bandVerses); bandSection.PlainText = PreparePlainText(bandVerses); + bandSection.CoupletsCount = bandVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); context.Add(mainSection); context.Add(bandSection); context.UpdateRange(nonCommentVerses); @@ -628,6 +635,7 @@ namespace RMuseum.Services.Implementation RhymeLetters = poem.RhymeLetters, HtmlText = PrepareHtmlText(nonCommentVerses), PlainText = PreparePlainText(nonCommentVerses), + CoupletsCount = nonCommentVerses.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(), PoemFormat = GanjoorPoemFormat.Unknown, }; //checking for مثنوی phase 1 @@ -689,6 +697,7 @@ namespace RMuseum.Services.Implementation var rl = new List(); rl.Add(rightVerse); rl.Add(leftVerse); verseSection.HtmlText = PrepareHtmlText(rl); verseSection.PlainText = PreparePlainText(rl); + verseSection.CoupletsCount = rl.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); context.Add(verseSection); } @@ -1069,6 +1078,7 @@ namespace RMuseum.Services.Implementation var rl = new List(); rl.Add(rightVerse); rl.Add(leftVerse); verseSection.HtmlText = PrepareHtmlText(rl); verseSection.PlainText = PreparePlainText(rl); + verseSection.CoupletsCount = rl.Where(v => v.VersePosition == VersePosition.Left || v.VersePosition == VersePosition.CenteredVerse1).Count(); context.Add(verseSection);