package poem

default allow := false

allow if {
    text := lower(input.output.poem)
    words := regex.find_n(`[\p{L}\p{M}\p{N}_]+`, text, -1)
    count([word | some word in words; word == "roses"]) == 3
    count([word | some word in words; word == "calm"]) == 1
    count(split(text, "e")) - 1 == 12
}

# Explicitly exported guidance; never an alternative authorization decision.
feedback := [{
    "code": "poem_counts",
    "scope": ["poem"],
    "message": "The complete poem must use roses exactly three times, calm exactly once, and the letter e exactly twelve times, ignoring case. Count roses and calm as whole words. Keep the poem smooth, rhythmic, and natural.",
}]
