From 72ba9ac98f729835b4edf44b0e3b303ff0332215 Mon Sep 17 00:00:00 2001 From: Steve White Date: Sun, 26 Jan 2025 14:23:24 -0600 Subject: [PATCH] Armored decision parsing more --- .gitignore | 1 + paperprocessor.go | 14 +++++++------- 2 files changed, 8 insertions(+), 7 deletions(-) create mode 100644 .gitignore diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..1377554 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +*.swp diff --git a/paperprocessor.go b/paperprocessor.go index c906dce..90308df 100644 --- a/paperprocessor.go +++ b/paperprocessor.go @@ -8,7 +8,6 @@ import ( "net/http" "strings" "time" - "unicode" ) // Paper represents a single academic paper @@ -200,13 +199,14 @@ Abstract: %s`, criteria, paper.Title, paper.Abstract) // Clean and normalize decision rawDecision := strings.TrimSpace(decisionLine) - // Remove "DECISION:" prefix if present and trim non-alphabetic characters - cleanDecision := strings.TrimPrefix(rawDecision, "DECISION:") - cleanDecision = strings.TrimFunc(cleanDecision, func(r rune) bool { - return !unicode.IsLetter(r) && !unicode.IsNumber(r) - }) + // Handle common prefixes and clean the decision text + cleanDecision := rawDecision + for _, prefix := range []string{"DECISION:", "Decision:"} { + cleanDecision = strings.TrimPrefix(cleanDecision, prefix) + } + cleanDecision = strings.TrimSpace(cleanDecision) - // Normalize case and check for valid decision + // Normalize case upperDecision := strings.ToUpper(cleanDecision) var decision string switch {