mirror of
https://github.com/MindWorkAI/AI-Studio.git
synced 2026-12-03 14:22:01 +00:00
Co-authored-by: Thorsten Sommer <SommerEngineering@users.noreply.github.com>
25 lines
1.9 KiB
C#
25 lines
1.9 KiB
C#
namespace AIStudio.Tools.DocumentSegments;
|
|
|
|
/// <summary>
|
|
/// A segment of a document which is text itself: where its words lie in the source, and which markup each of
|
|
/// its tags stands for.
|
|
/// </summary>
|
|
/// <param name="Start">Where the segment starts in the source.</param>
|
|
/// <param name="End">Where the segment ends in the source, exclusive.</param>
|
|
/// <param name="Segment">The segment, as a model gets it.</param>
|
|
/// <param name="Openings">The markup which the opening tag of each pair stands for, e.g., "[" of a Markdown link.</param>
|
|
/// <param name="Closings">The markup which the closing tag of each pair stands for, e.g., "](https://example.org)".</param>
|
|
/// <param name="Placeholders">The markup which each tag of its own stands for, e.g., a code span.</param>
|
|
/// <param name="FormatWords">Makes the words of this segment fit the format in place of what the writer gets, e.g., within an optional argument of LaTeX, which a closing bracket would end; null for the writer's. Like the writer's, it gets one run of words between two tags at a time, so its start may be the start of a line.</param>
|
|
/// <param name="OptionalPlaceholders">The tags of their own which the writer leaves out when the model dropped them, e.g., a line break of Markdown, which would show as a backslash after the words; null for none.</param>
|
|
/// <param name="FormatNewText">Makes the whole new text of this segment fit the format, once its words and the markup of its tags are written, e.g., quotes around the new value of an attribute of a web page which had none; null to leave it as it is.</param>
|
|
public sealed record TextSegment(
|
|
int Start,
|
|
int End,
|
|
DocumentSegment Segment,
|
|
IReadOnlyDictionary<int, string> Openings,
|
|
IReadOnlyDictionary<int, string> Closings,
|
|
IReadOnlyDictionary<int, string> Placeholders,
|
|
Func<string, string>? FormatWords = null,
|
|
IReadOnlySet<int>? OptionalPlaceholders = null,
|
|
Func<string, string>? FormatNewText = null); |