Phase 20R.2
This commit is contained in:
parent
f728168173
commit
a2d9cb7c0a
@ -154,6 +154,7 @@ public sealed class StoryIntelligenceSavedRun
|
|||||||
public decimal? ChapterNumber { get; init; }
|
public decimal? ChapterNumber { get; init; }
|
||||||
public string Status { get; init; } = string.Empty;
|
public string Status { get; init; } = string.Empty;
|
||||||
public string SourceType { get; init; } = string.Empty;
|
public string SourceType { get; init; } = string.Empty;
|
||||||
|
public string? SourceText { get; init; }
|
||||||
public string? SourceFileName { get; init; }
|
public string? SourceFileName { get; init; }
|
||||||
public long? SourceFileSizeBytes { get; init; }
|
public long? SourceFileSizeBytes { get; init; }
|
||||||
public int? SourceWordCount { get; init; }
|
public int? SourceWordCount { get; init; }
|
||||||
|
|||||||
@ -5,8 +5,8 @@ namespace PlotLine.Services;
|
|||||||
public static class StoryIntelligenceParagraphs
|
public static class StoryIntelligenceParagraphs
|
||||||
{
|
{
|
||||||
public static IReadOnlyList<string> Split(string? chapterText)
|
public static IReadOnlyList<string> Split(string? chapterText)
|
||||||
=> (chapterText ?? string.Empty)
|
=> NormalizeLineEndings(chapterText)
|
||||||
.Split(["\r\n\r\n", "\n\n", "\r\r"], StringSplitOptions.RemoveEmptyEntries)
|
.Split('\n', StringSplitOptions.RemoveEmptyEntries)
|
||||||
.Select(paragraph => paragraph.Trim())
|
.Select(paragraph => paragraph.Trim())
|
||||||
.Where(paragraph => !string.IsNullOrWhiteSpace(paragraph))
|
.Where(paragraph => !string.IsNullOrWhiteSpace(paragraph))
|
||||||
.ToList();
|
.ToList();
|
||||||
@ -30,4 +30,13 @@ public static class StoryIntelligenceParagraphs
|
|||||||
|
|
||||||
return builder.ToString();
|
return builder.ToString();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string NormalizeLineEndings(string? value)
|
||||||
|
=> (value ?? string.Empty)
|
||||||
|
.Replace("\r\n", "\n", StringComparison.Ordinal)
|
||||||
|
.Replace('\r', '\n')
|
||||||
|
.Replace('\v', '\n')
|
||||||
|
.Replace('\f', '\n')
|
||||||
|
.Replace('\u2028', '\n')
|
||||||
|
.Replace('\u2029', '\n');
|
||||||
}
|
}
|
||||||
|
|||||||
@ -61,6 +61,7 @@ BEGIN
|
|||||||
r.ChapterNumber,
|
r.ChapterNumber,
|
||||||
r.Status,
|
r.Status,
|
||||||
r.SourceType,
|
r.SourceType,
|
||||||
|
r.SourceText,
|
||||||
r.SourceFileName,
|
r.SourceFileName,
|
||||||
r.SourceFileSizeBytes,
|
r.SourceFileSizeBytes,
|
||||||
r.SourceWordCount,
|
r.SourceWordCount,
|
||||||
|
|||||||
@ -95,6 +95,10 @@ else
|
|||||||
<dd>@Display(run.SourceCharacterCount)</dd>
|
<dd>@Display(run.SourceCharacterCount)</dd>
|
||||||
<dt>Submitted paragraph count</dt>
|
<dt>Submitted paragraph count</dt>
|
||||||
<dd>@Display(run.SourceParagraphCount)</dd>
|
<dd>@Display(run.SourceParagraphCount)</dd>
|
||||||
|
<dt>First five numbered paragraphs</dt>
|
||||||
|
<dd><pre class="mb-0">@FirstNumberedParagraphs(run)</pre></dd>
|
||||||
|
<dt>Last paragraph number</dt>
|
||||||
|
<dd>@Display(LastParagraphNumber(run))</dd>
|
||||||
<dt>Source chapter count</dt>
|
<dt>Source chapter count</dt>
|
||||||
<dd>@Display(run.SourceChapterCount)</dd>
|
<dd>@Display(run.SourceChapterCount)</dd>
|
||||||
<dt>Detected document features</dt>
|
<dt>Detected document features</dt>
|
||||||
@ -274,6 +278,25 @@ else
|
|||||||
: $"Chapter ID {chapterId.Value:N0}"
|
: $"Chapter ID {chapterId.Value:N0}"
|
||||||
: "None";
|
: "None";
|
||||||
|
|
||||||
|
private static string FirstNumberedParagraphs(StoryIntelligenceSavedRun run)
|
||||||
|
{
|
||||||
|
var paragraphs = StoryIntelligenceParagraphs.Split(run.SourceText);
|
||||||
|
if (paragraphs.Count == 0)
|
||||||
|
{
|
||||||
|
return "None";
|
||||||
|
}
|
||||||
|
|
||||||
|
return string.Join(
|
||||||
|
Environment.NewLine + Environment.NewLine,
|
||||||
|
paragraphs.Take(5).Select((paragraph, index) => $"[{index + 1}] {PreviewParagraph(paragraph)}"));
|
||||||
|
}
|
||||||
|
|
||||||
|
private static int? LastParagraphNumber(StoryIntelligenceSavedRun run)
|
||||||
|
{
|
||||||
|
var paragraphs = StoryIntelligenceParagraphs.Split(run.SourceText);
|
||||||
|
return paragraphs.Count == 0 ? null : paragraphs.Count;
|
||||||
|
}
|
||||||
|
|
||||||
private static string ChapterStructureStatus(StoryIntelligenceSavedChapterResult? chapter, StoryIntelligenceSavedRun run)
|
private static string ChapterStructureStatus(StoryIntelligenceSavedChapterResult? chapter, StoryIntelligenceSavedRun run)
|
||||||
{
|
{
|
||||||
if (chapter is not null)
|
if (chapter is not null)
|
||||||
@ -368,4 +391,10 @@ else
|
|||||||
return [];
|
return [];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static string PreviewParagraph(string value)
|
||||||
|
{
|
||||||
|
var cleaned = value.ReplaceLineEndings(" ").Trim();
|
||||||
|
return cleaned.Length <= 220 ? cleaned : $"{cleaned[..220]}...";
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user