alignment/transcript_parser
Parse raw transcript text into structured Turns.
Transcript format (generic D:/P: speaker prefix):
D: What brings you in today?
P: I've been feeling nauseated for about nine days.
D: When did this start?
Lines begin with “D: “ (doctor) or “P: “ (patient). Turns are separated by blank lines. Files may use \r\n line endings.
Continuation lines: a non-blank line without a D:/P: prefix that immediately follows a speaker line is merged into the current turn’s text. This handles transcripts where long utterances wrap onto the next line (e.g. “I thought it might be a\nchest infection…”).
Pure module — no I/O. Caller reads the file and hands the string over.
Values
pub fn parse_speaker_line(
line: String,
) -> option.Option(#(dialogue_types.Role, String))
Detect and extract the speaker role and text from one line.
Returns None if the line doesn’t match “D: …” or “P: …”.
pub fn parse_transcript(raw: String) -> List(dialogue_types.Turn)
Parse a raw transcript string into a list of Turns in order. Returns an empty list if no recognized speaker lines are found.