-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfilehelper.py
More file actions
28 lines (24 loc) · 843 Bytes
/
filehelper.py
File metadata and controls
28 lines (24 loc) · 843 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import json
import pickle
class FileHelper:
@staticmethod
def intents_load():
"""Loads the data from a JSON file
"""
data = ""
with open('data/intents.json') as f:
data = json.load(f)
return data
@staticmethod
def training_data_save(words, classes, train_x, train_y):
"""Saves the training data to a file
"""
training_file = open("data/training", "wb")
pickle.dump({'words': words, 'classes': classes, 'train_x': train_x, 'train_y': train_y}, training_file)
@staticmethod
def training_data_load():
"""Loads the training data from a file
"""
training_file = open("data/training", "rb")
data = pickle.load(training_file)
return data['words'], data['classes'], data['train_x'], data['train_y']