<code>
<import json
import pickle
import random
from codecs import StreamReaderWriter
from typing import Any, Union
import numpy as np
import nltk
from nltk.stem import WordNetLemmatizer
from tensorflow.keras.models import Sequential
from tensorflow.keras.layers import Dense, Activation, Dropout
from tensorflow.keras.optimizers import SGD
lemmatizer = WordNetLemmatizer
import codecs
intents: Union[StreamReaderWriter, Any]
with codecs.open('intents.json', encoding='utf-8') as intents:
# intents = json.loads(open('intents.json').read())
# for line in f:
# print(line)
words = []
classes = []
documents = []
ignore_letters = ['?', '!', '.', ',']
for intent in intents['intents']:
for pattern in intent['patterns']:
word_list = nltk.word_tokenize(pattern)
words.append(word_list)
documents.append((word_list, intent['tag']))
if intent['tag'] not in classes:
classes.append(intent['tag'])
words = [lemmatizer.lemmatize(word) for word in words if word not in ignore_letters]
words = sorted(set(words))
print(words)
</code>