Check if answer as enough words

This commit is contained in:
Cristiano Ferreira
2024-03-24 16:00:21 +00:00
parent cc3371c597
commit 3aa33f10b4
2 changed files with 51 additions and 29 deletions

View File

@@ -94,11 +94,11 @@ def has_words(text: str):
words_in_input = text.split()
return any(word.lower() in english_words for word in words_in_input)
def has_50_words(text: str):
def has_x_words(text: str, quantity):
english_words = set(words.words())
words_in_input = text.split()
english_word_count = sum(1 for word in words_in_input if word.lower() in english_words)
return english_word_count >= 50
return english_word_count >= quantity
def divide_text(text, max_length=3000):
if len(text) <= max_length: