cf2c0d8068
This commit introduces a new property for capturing footnotes in both the EventOccurrenceParseResult and EventOccurrenceParserResult classes. The EventOccurrenceParser has been updated to handle footnotes, which are identified by lines starting with "*" or as parenthetical notes. The logic for processing these footnotes has been integrated into the parsing flow, ensuring that they are correctly associated with their respective event definitions. Additionally, the EventOccurrenceParserService has been modified to copy footnotes from the parser result, enhancing the overall event parsing functionality.
144 lines
4.7 KiB
C#
144 lines
4.7 KiB
C#
using Core.Entities;
|
|
|
|
namespace Core.Models;
|
|
|
|
/// <summary>
|
|
/// Result of parsing event occurrence text data.
|
|
/// Contains parsed occurrences, errors, and warnings.
|
|
/// </summary>
|
|
public class EventOccurrenceParseResult
|
|
{
|
|
/// <summary>
|
|
/// Dictionary of parsed event occurrences, keyed by EventDefinition.
|
|
/// For special events (GeneralSchedule, MeetTheCandidates, ChapterOfficerMeeting, VotingDelegateMeeting, SocialGathering),
|
|
/// the EventDefinition key will be the static instance.
|
|
/// </summary>
|
|
public IDictionary<EventDefinition, List<EventOccurrence>> Occurrences { get; set; } = new Dictionary<EventDefinition, List<EventOccurrence>>();
|
|
|
|
/// <summary>
|
|
/// List of parsing errors (critical issues that prevented parsing).
|
|
/// </summary>
|
|
public List<string> Errors { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// List of parsing warnings (non-critical issues that occurred during parsing).
|
|
/// </summary>
|
|
public List<string> Warnings { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// List of detailed parsing issues with line numbers and specific problem descriptions.
|
|
/// </summary>
|
|
public List<ParsingIssue> Issues { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// List of high school (HS) section headers that were encountered but skipped
|
|
/// because they don't match the chapter's school level setting.
|
|
/// </summary>
|
|
public List<string> SkippedHSSectionHeaders { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// List of middle school (MS) section headers that were encountered but skipped
|
|
/// because they don't match the chapter's school level setting.
|
|
/// </summary>
|
|
public List<string> SkippedMSSectionHeaders { get; set; } = new();
|
|
|
|
/// <summary>
|
|
/// Number of Middle School (MS) event occurrences that were skipped due to school level filtering.
|
|
/// </summary>
|
|
public int SkippedMSEventCount { get; set; }
|
|
|
|
/// <summary>
|
|
/// Number of High School (HS) event occurrences that were skipped due to school level filtering.
|
|
/// </summary>
|
|
public int SkippedHSEventCount { get; set; }
|
|
|
|
/// <summary>
|
|
/// Footnotes captured for each event definition. Footnotes are lines that start with "*" or are parenthetical notes.
|
|
/// Multiple footnotes are concatenated into a single string. These provide additional context or information about the event occurrences.
|
|
/// </summary>
|
|
public IDictionary<EventDefinition, string> Footnotes { get; set; } = new Dictionary<EventDefinition, string>();
|
|
|
|
/// <summary>
|
|
/// Total number of event occurrences successfully parsed.
|
|
/// </summary>
|
|
public int TotalParsed => Occurrences.Values.Sum(list => list.Count);
|
|
|
|
/// <summary>
|
|
/// Indicates whether parsing was successful (no errors).
|
|
/// </summary>
|
|
public bool IsSuccess => Errors.Count == 0;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Represents a detailed parsing issue encountered during event occurrence parsing.
|
|
/// </summary>
|
|
public class ParsingIssue
|
|
{
|
|
/// <summary>
|
|
/// The line number where the issue occurred (1-based).
|
|
/// </summary>
|
|
public int LineNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// The column number where the issue occurred (1-based, 0 if not available).
|
|
/// </summary>
|
|
public int ColumnNumber { get; set; }
|
|
|
|
/// <summary>
|
|
/// The actual line content where the issue occurred.
|
|
/// </summary>
|
|
public string LineContent { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// The type of parsing issue.
|
|
/// </summary>
|
|
public ParsingIssueType IssueType { get; set; }
|
|
|
|
/// <summary>
|
|
/// Human-readable description of the issue.
|
|
/// </summary>
|
|
public string Message { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// What was expected at the error location (e.g., "month name", "MS or HS", "time value").
|
|
/// </summary>
|
|
public string Expected { get; set; } = string.Empty;
|
|
|
|
/// <summary>
|
|
/// What was actually found at the error location.
|
|
/// </summary>
|
|
public string Found { get; set; } = string.Empty;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Types of parsing issues that can occur during event occurrence parsing.
|
|
/// </summary>
|
|
public enum ParsingIssueType
|
|
{
|
|
/// <summary>
|
|
/// Line doesn't match the expected format pattern.
|
|
/// </summary>
|
|
UnmatchedLine,
|
|
|
|
/// <summary>
|
|
/// Line matches format but event definition cannot be determined.
|
|
/// </summary>
|
|
MissingEventDefinition,
|
|
|
|
/// <summary>
|
|
/// Time parsing failed (regex doesn't match or parse errors).
|
|
/// </summary>
|
|
TimeParseFailure,
|
|
|
|
/// <summary>
|
|
/// Date parsing failed (invalid day of month, etc.).
|
|
/// </summary>
|
|
DateParseFailure,
|
|
|
|
/// <summary>
|
|
/// Invalid format or other parsing issue.
|
|
/// </summary>
|
|
InvalidFormat
|
|
}
|
|
|