# Python code error, can you help me please?

**URL:** <https://support.prodi.gy/t/python-code-error-can-you-help-me-please/6299>\
**Category:** Uncategorized\
**Tags:** off-topic\
**Created:** [January 29, 2023, 3:24pm UTC](https://support.prodi.gy/t/python-code-error-can-you-help-me-please/6299 "2023-01-29T15:24:38Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrix951](https://avatars.discourse-cdn.com/v4/letter/a/da6949/32.png) [@Andrix951](https://support.prodi.gy/u/Andrix951)\
**Post date:** [January 29, 2023, 3:24pm UTC](https://support.prodi.gy/t/python-code-error-can-you-help-me-please/6299/1 "2023-01-29T15:24:38Z")

</div>

the code of the error is this, string 12:

import random  
import json  
import pickle  
import numpy as np

import nltk  
from nltk.stem import WordNetLemmatizer

from tensorflow.keras.models import load\_model

lemmatizer = WordNetLemmatizer()  
intents = json.loads(open('scratch.json.json').read())

words = pickle.load(open('word.pkl', 'rb'))  
classes = pickle.load(open('classes.pkl', 'rb'))  
model = load\_model('chatbot\_model.model')

def clean\_up\_sentence(sentence):  
sentence\_words = nltk.word\_tokenize(sentence)  
sentence\_words = [lemmatizer.lemmatize(word) for word in sentence\_words]  
return sentence\_words

def bag\_of\_words(sentence):  
sentence\_words = clean\_up\_sentence(sentence)  
bag = [o] \* len(words)  
for w in sentence\_words:  
for i, word in enumerate(words):  
if word == w:  
bag[i] = 1  
return np.array(bag)

def predict\_class(sentence):  
bow = bag\_of\_words(sentence)  
res = model.predict(np.array([bow]))[0]  
ERROR\_TRASHOLD = 0.25  
results = [[i, r] for i, r in enumerate(red) if r \> ERROR\_TRASHOLD]

```
results.key(key=lambda x: x[1], reverse=True)
return_list = []
for r in results:
    return_list.append({'intent': classes[r[0]], 'probability': str(r[1])})
return return_list

```

---

<div class="post-metadata">

**Author:** ![ryanwesslen](https://sea2.discourse-cdn.com/flex020/user_avatar/support.prodi.gy/ryanwesslen/32/2969_2.png) [@ryanwesslen](https://support.prodi.gy/u/ryanwesslen)\
**Post date:** [January 30, 2023, 12:23pm UTC](https://support.prodi.gy/t/python-code-error-can-you-help-me-please/6299/2 "2023-01-30T12:23:29Z")

</div>

hi @Andrix951,

Thanks for your message and welcome to the Prodigy community 👋

Your code uses `nltk` and `tensorflow`; but this is a forum for [Prodigy](https://prodi.gy/). We don't offer support for third-party tools. I recommend you post on either of those tools' support forums ([nltk](https://github.com/nltk/nltk/issues) or [tensorflow](https://github.com/tensorflow/tensorflow/issues)).
