-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathnlu_model.py
30 lines (25 loc) · 1.06 KB
/
nlu_model.py
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
29
30
from rasa_nlu.training_data import load_data
from rasa_nlu.config import RasaNLUModelConfig
from rasa_nlu.model import Trainer
from rasa_nlu.model import Metadata, Interpreter
from rasa_nlu import config
from rasa_nlu.components import ComponentBuilder
import load_lookuppy
import rasa_nlu
filename = './data/locationlist.txt'
load_lookuppy.cities_func(filename)
filename = './data/cuisinelist.txt'
load_lookuppy.cuisines_func(filename)
builder = ComponentBuilder(use_cache=True)
def train_nlu(data, config_file, model_dir):
print('******* Rasa NLU Version - ',rasa_nlu.__version__,' *******')
training_data = load_data(data)
trainer = Trainer(config.load(config_file), builder)
trainer.train(training_data)
model_directory = trainer.persist(model_dir, fixed_model_name = 'restaurantnlu')
def run_nlu():
interpreter = Interpreter.load('./models/nlu/default/restaurantnlu', builder)
print(interpreter.parse("south indian restaurants in agra costs less than 500"))
if __name__ == '__main__':
train_nlu('./data/data.json', 'config_spacy.json', './models/nlu')
# run_nlu()