Count the number of words in a given text string. :param text: Input text :return: Number of words found
(text)
| 647 | return len(enc.encode(text)) |
| 648 | |
| 649 | def count_words(text): |
| 650 | """ |
| 651 | Count the number of words in a given text string. |
| 652 | :param text: Input text |
| 653 | :return: Number of words found |
| 654 | """ |
| 655 | # Use a regex to find word-like sequences |
| 656 | words = re.findall(r"\w+", text) |
| 657 | return len(words) |
| 658 | |
| 659 | |
| 660 | def count_words_in_image(image_path): |
no outgoing calls
no test coverage detected