@@ -320,26 +320,44 @@ private static string DenormalizeQuotationMarks(string usfm, ParallelCorpusAnaly
320320 QuotationMarkDenormalizationFirstPass quotationMarkDenormalizationFirstPass = new ( targetQuoteConvention ) ;
321321
322322 UsfmParser . Parse ( usfm , quotationMarkDenormalizationFirstPass ) ;
323- List < QuotationMarkUpdateStrategy > bestChapterStrategies =
323+ List < ( int ChapterNumber , QuotationMarkUpdateStrategy Strategy ) > bestChapterStrategies =
324324 quotationMarkDenormalizationFirstPass . FindBestChapterStrategies ( ) ;
325325
326326 QuotationMarkDenormalizationUsfmUpdateBlockHandler quotationMarkDenormalizer =
327- new ( targetQuoteConvention , new QuotationMarkUpdateSettings ( chapterStrategies : bestChapterStrategies ) ) ;
327+ new (
328+ targetQuoteConvention ,
329+ new QuotationMarkUpdateSettings (
330+ chapterStrategies : bestChapterStrategies . Select ( tuple => tuple . Strategy ) . ToList ( )
331+ )
332+ ) ;
333+ int denormalizableChapterCount = bestChapterStrategies . Count ( tup =>
334+ tup . Strategy != QuotationMarkUpdateStrategy . Skip
335+ ) ;
328336 List < string > remarks = [ ] ;
329- if ( bestChapterStrategies . Any ( s => s != QuotationMarkUpdateStrategy . Skip ) )
337+ string quotationDenormalizationRemark ;
338+ if ( denormalizableChapterCount == bestChapterStrategies . Count )
330339 {
331- string quotationDenormalizationRemark =
340+ quotationDenormalizationRemark =
341+ "The quote style in all chapters has been automatically adjusted to match the rest of the project." ;
342+ }
343+ else if ( denormalizableChapterCount > 0 )
344+ {
345+ quotationDenormalizationRemark =
332346 "The quote style in the following chapters has been automatically adjusted to match the rest of the project: "
333- + string . Join (
334- ", " ,
347+ + GetChapterRangesString (
335348 bestChapterStrategies
336- . Select ( ( strategy , index ) => ( strategy , index ) )
337- . Where ( tuple => tuple . strategy != QuotationMarkUpdateStrategy . Skip )
338- . Select ( tuple => tuple . index + 1 )
349+ . Where ( tuple => tuple . Strategy != QuotationMarkUpdateStrategy . Skip )
350+ . Select ( tuple => tuple . ChapterNumber )
351+ . ToList ( )
339352 )
340353 + "." ;
341- remarks . Add ( quotationDenormalizationRemark ) ;
342354 }
355+ else
356+ {
357+ quotationDenormalizationRemark =
358+ "The quote style was not automatically adjusted to match the rest of your project in any chapters." ;
359+ }
360+ remarks . Add ( quotationDenormalizationRemark ) ;
343361
344362 var updater = new UpdateUsfmParserHandler ( updateBlockHandlers : [ quotationMarkDenormalizer ] , remarks : remarks ) ;
345363 UsfmParser . Parse ( usfm , updater ) ;
@@ -348,6 +366,43 @@ private static string DenormalizeQuotationMarks(string usfm, ParallelCorpusAnaly
348366 return usfm ;
349367 }
350368
369+ public static string GetChapterRangesString ( List < int > chapterNumbers )
370+ {
371+ chapterNumbers = chapterNumbers . Order ( ) . ToList ( ) ;
372+ int start = chapterNumbers [ 0 ] ;
373+ int end = chapterNumbers [ 0 ] ;
374+ List < string > chapterRangeStrings = [ ] ;
375+ foreach ( int chapterNumber in chapterNumbers [ 1 ..] )
376+ {
377+ if ( chapterNumber == end + 1 )
378+ {
379+ end = chapterNumber ;
380+ }
381+ else
382+ {
383+ if ( start == end )
384+ {
385+ chapterRangeStrings . Add ( start . ToString ( CultureInfo . InvariantCulture ) ) ;
386+ }
387+ else
388+ {
389+ chapterRangeStrings . Add ( $ "{ start } -{ end } ") ;
390+ }
391+ start = chapterNumber ;
392+ end = chapterNumber ;
393+ }
394+ }
395+ if ( start == end )
396+ {
397+ chapterRangeStrings . Add ( start . ToString ( CultureInfo . InvariantCulture ) ) ;
398+ }
399+ else
400+ {
401+ chapterRangeStrings . Add ( $ "{ start } -{ end } ") ;
402+ }
403+ return string . Join ( ", " , chapterRangeStrings ) ;
404+ }
405+
351406 /// <summary>
352407 /// Generate a natural sounding remark/comment describing marker placement.
353408 /// </summary>
0 commit comments