From cee4a3ef6aba480b54ae32b427ce4579832e5d69 Mon Sep 17 00:00:00 2001 From: Alban Gruin Date: Mon, 4 Oct 2021 12:37:53 +0200 Subject: course: fix parsing issues The constructors Location and Summary were inverted, causing confusion in the loc_and_sum_to_location and loc_and_sum_to_summary functions. For instance, if no location was found, the summary would be empty (even though it was found), and the location would be the name of the event. This fixes these names and functions to work properly. Signed-off-by: Alban Gruin --- src/course.ml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/src/course.ml b/src/course.ml index 4b9c914..5ce2564 100644 --- a/src/course.ml +++ b/src/course.ml @@ -49,20 +49,20 @@ let replace_entities str = type loc_and_sum = | Nothing | Groups of string list - | Location of string list * string - | Summary of string list * string * string + | Summary of string list * string + | Location of string list * string * string let loc_and_sum_to_groups = function | Nothing -> [] - | Groups groups | Location (groups, _) | Summary (groups, _, _) -> groups + | Groups groups | Summary (groups, _) | Location (groups, _, _) -> groups let loc_and_sum_to_location = function - | Nothing | Groups _ -> "" - | Location (_, location) | Summary (_, location, _) -> location + | Nothing | Groups _ | Summary _ -> "" + | Location (_, _, location) -> location let loc_and_sum_to_summary category = function - | Nothing | Groups _ | Location _ -> category - | Summary (_, _, summary) -> + | Nothing | Groups _ -> category + | Summary (_, summary) | Location (_, summary, _) -> let summary = match Astring.String.cut ~sep:" - " summary with | None -> summary | Some (_, str) -> str in @@ -90,9 +90,9 @@ let location_and_summary str = let parts = Astring.String.cuts ~empty:false ~sep str in List.fold_right (fun str -> function | Nothing -> check_groups str - | Groups groups -> Location (groups, replace_entities str) - | Location (groups, summary) -> Summary (groups, replace_entities str, summary) - | Summary _ as res -> res) + | Groups groups -> Summary (groups, replace_entities str) + | Summary (groups, summary) -> Location (groups, summary, replace_entities str) + | Location _ as res -> res) parts Nothing let date = -- cgit v1.2.1