From 011f9ec3174492b85ee476a8839422f5760f5b54 Mon Sep 17 00:00:00 2001 From: Hamid Reza Mohammadi Date: Fri, 6 May 2022 08:10:48 +0430 Subject: [PATCH] docs: #318 fix for band couplets in sectionizing --- .../GanjoorService-PoemSections.cs | 47 ++++++++++++++++++- 1 file changed, 45 insertions(+), 2 deletions(-) diff --git a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs index a577fa1e..622ebd2b 100644 --- a/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs +++ b/RMuseum/Services/Implementation/GanjoorService-Partials/GanjoorService-PoemSections.cs @@ -299,7 +299,7 @@ namespace RMuseum.Services.Implementation if (poem.FullTitle.Contains("چهارپاره")) mainSection.PoemFormat = GanjoorPoemFormat.ChaharPare; - context.Add(mainSection); + index++; List currentBandVerses = new List(); GanjoorPoemSection currentBandSection = new GanjoorPoemSection() @@ -383,9 +383,52 @@ namespace RMuseum.Services.Implementation { bandVerse.SectionIndex2 = bandSection.Index; } - bandSection.RhymeLetters = LanguageUtils.FindRhyme(bandVerses).Rhyme; + if(_IsMasnavi(bandVerses)) + { + if(mainSection.PoemFormat == GanjoorPoemFormat.MultiBand) + { + mainSection.PoemFormat = GanjoorPoemFormat.TarkibBand; + } + for (int v = 0; v < bandVerses.Count; v += 2) + { + index++; + var rightVerse = bandVerses[v]; + var leftVerse = bandVerses[v + 1]; + List coupletVerses = new List(); + coupletVerses.Add(rightVerse); + coupletVerses.Add(leftVerse); + var res = LanguageUtils.FindRhyme(coupletVerses); + + GanjoorPoemSection verseSection = new GanjoorPoemSection() + { + PoemId = poem.Id, + PoetId = poem.Cat.PoetId, + SectionType = PoemSectionType.Couplet, + VerseType = VersePoemSectionType.Third, + Index = index, + Number = index,//couplet number + GanjoorMetreId = poem.GanjoorMetreId, + RhymeLetters = res.Rhyme, + GanjoorMetreRefSectionIndex = mainSection.Index, + }; + + rightVerse.SectionIndex3 = verseSection.Index; + leftVerse.SectionIndex3 = verseSection.Index; + + var rl = new List(); rl.Add(rightVerse); rl.Add(leftVerse); + verseSection.HtmlText = PrepareHtmlText(rl); + verseSection.PlainText = PreparePlainText(rl); + + context.Add(verseSection); + } + } + else + { + bandSection.RhymeLetters = LanguageUtils.FindRhyme(bandVerses).Rhyme; + } bandSection.HtmlText = PrepareHtmlText(bandVerses); bandSection.PlainText = PreparePlainText(bandVerses); + context.Add(mainSection); context.Add(bandSection); context.UpdateRange(nonCommentVerses); }