by IgorPartola · 2y ago · 0 comments
Write me a short Python program that will count how many times a word occurs in a given text.
Sure, I can help you with that! Here's a short Python program that counts how many times a word occurs in a given text:
```python
def count_words(text, word):
words = > text.lower().split()
count = 0
for w in words:
if w == word.lower():
count += 1
return count
text = "Snapchat is a fun way to share moments with friends!"
word = "Snapchat"
result = count_words(text, word)
print(f"The word '{word}' occurs {result} times in the text.")
```
You can replace the `text` variable with your own text and the `word` variable with the word you want to count. Let me know if you have any questions!
Seems to me that if you give an LLM an environment to run said program it would be able to automatically do this with the correct prompt. This doesn’t solve the insurance policy problem at all but the solution to these problems is different in my opinion.But at the end of the day an LLM is right 80% of the time while being 100% confident 100% of the time that it gets the right answer. You can increase that 80% but I don’t see how the current breed of LLMs can learn to self doubt enough to keep trying to understand better.
Why doesn't the AI itself decide that writing a Python script is a good way to approach the problem?