Мой Код
Код: Выделить всё
import random
import json
import pickle
import numpy as np
import os
import nltk
from nltk.stem import WordNetLemmatizer
from tensorflow.python.keras.models import Sequential
from tensorflow.python.keras.layers import Dense, Activation, Dropout
#from tensorflow.keras.optimizers import SGD
lemmatizer = WordNetLemmatizer
for root, dirs, files in os.walk(os.getcwd()):
print(f"Directory: {root}")
print(f"Subdirectories: {dirs}")
print(f"Files: {files}")
print("-" * 40)
#intents = json.load(open(r'C:').read())
f = open('intents.json')
intents = json.load(f)
words = []
classes = []
documents = []
ignoreLetters = ['?', '!','.',',']
for intent in intents['intents']:
for pattern in intent['patterns']:
wordList = nltk.word_tokenize(pattern)
words.append(wordList)
documents.append((wordList), intent['tag'])
if intent['tag'] not in classes:
classes.append(intent['tag'])
#print(documents)
Код: Выделить всё
['NueralNetwork']
Directory: c:\Users\-\OneDrive\Desktop\AIVA
Subdirectories: ['NueralNetwork']
Files: []
----------------------------------------
Directory: c:\Users\-\OneDrive\Desktop\AIVA\NueralNetwork
Subdirectories: []
Files: ['intents.json', 'training.py']
----------------------------------------
Traceback (most recent call last):
File "c:\Users\-\OneDrive\Desktop\AIVA\NueralNetwork\training.py", line 22, in
f = open('NeuralNetwork/intents.json') # Correct path to the file
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
FileNotFoundError: [Errno 2] No such file or directory: 'NeuralNetwork/intents.json'
игнорировать
(помогите использовать файл Python для доступа к файлу JSON в том же каталоге, чтобы мой код мог работать)
Спасибо! п>
Подробнее здесь: https://stackoverflow.com/questions/790 ... -find-file