From fa33531d5f6e014879a31b6ddaa4be88ace64bad Mon Sep 17 00:00:00 2001 From: tonaerospace Date: Sun, 9 Mar 2025 22:06:33 +0700 Subject: [PATCH] update --- src/util.jl | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/util.jl b/src/util.jl index 6ec8b51..4359d4c 100644 --- a/src/util.jl +++ b/src/util.jl @@ -287,7 +287,11 @@ function textToDict(text::String, keywords::Vector{String}; # use for loop and detect_keyword function to get the exact variation of each keyword in the text then push to kw list for keyword in keywords detected = detect_keyword(keyword, text) - push!(kw, detected) + if detected !== nothing + push!(kw, detected) + else + error("Keyword $keyword not found in text.") + end end od1, od2 = @@ -793,7 +797,7 @@ Detects if a keyword exists in the text in different case variations (lowercase, """ function detect_keyword(keyword::String, text::String)::Union{Nothing, String} # Define the keyword variations to search for - keyword_variations = [keyword, uppercasefirst(keyword), uppercase(keyword)] + keyword_variations = [keyword, uppercasefirst(keyword), uppercase(keyword), lowercase(keyword)] # Check if any of the keyword variations are in the text for variation in keyword_variations