This commit is contained in:
2025-03-09 22:06:33 +07:00
parent ce1af8b382
commit fa33531d5f

View File

@@ -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 # 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 for keyword in keywords
detected = detect_keyword(keyword, text) detected = detect_keyword(keyword, text)
if detected !== nothing
push!(kw, detected) push!(kw, detected)
else
error("Keyword $keyword not found in text.")
end
end end
od1, od2 = 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} function detect_keyword(keyword::String, text::String)::Union{Nothing, String}
# Define the keyword variations to search for # 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 # Check if any of the keyword variations are in the text
for variation in keyword_variations for variation in keyword_variations