本文整理汇总了Python中rasa_nlu.config.RasaNLUConfig方法的典型用法代码示例。如果您正苦于以下问题:Python config.RasaNLUConfig方法的具体用法?Python config.RasaNLUConfig怎么用?Python config.RasaNLUConfig使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类rasa_nlu.config
的用法示例。
在下文中一共展示了config.RasaNLUConfig方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: parse
# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import RasaNLUConfig [as 别名]
def parse(self, message):
interpreter = Interpreter.load(nlu_model_path, RasaNLUConfig("../mom/nlu_model_config.json"))
intent = interpreter.parse(message)
return intent
# return {
# "text": message,
# "intent": {"name": intent, "confidence": 1.0},
# "entities": []
# }
示例2: train
# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import RasaNLUConfig [as 别名]
def train():
training_data = load_data('../mom/data/nlu.json')
trainer = Trainer(RasaNLUConfig("../mom/nlu_model_config.json"))
trainer.train(training_data)
model_directory = trainer.persist('../models') # Returns the directory the model is stored in
return model_directory
示例3: predict
# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import RasaNLUConfig [as 别名]
def predict(model_directory):
from rasa_nlu.model import Metadata, Interpreter
# where `model_directory points to the folder the model is persisted in
interpreter = Interpreter.load(model_directory, RasaNLUConfig("../mom/nlu_model_config.json"))
print (interpreter.parse("salad"))
# model_directory = train()
# print (model_directory)
示例4: parse
# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import RasaNLUConfig [as 别名]
def parse(self, message):
interpreter = Interpreter.load(nlu_model_path, RasaNLUConfig("../mom/nlu_model_config.json"))
intent = interpreter.parse(message)
return intent
示例5: train_babi_nlu
# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import RasaNLUConfig [as 别名]
def train_babi_nlu():
training_data = load_data('examples/babi/data/franken_data.json')
trainer = Trainer(RasaNLUConfig("examples/babi/data/config_nlu.json"))
trainer.train(training_data)
model_directory = trainer.persist('examples/babi/models/nlu/',
fixed_model_name=model_name)
return model_directory
示例6: parse
# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import RasaNLUConfig [as 别名]
def parse(self, text):
"""Parses a text message.
Returns a nlu value if the parsing of the text failed."""
if self.lazy_init and self.interpreter is None:
from rasa_nlu.model import Interpreter
from rasa_nlu.config import RasaNLUConfig
self.interpreter = Interpreter.load(self.metadata,
RasaNLUConfig(self.config_file,
os.environ))
return self.interpreter.parse(text)
示例7: train
# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import RasaNLUConfig [as 别名]
def train(self, training_data, config, **kwargs):
# type: (TrainingData, RasaNLUConfig, **Any) -> None
if config['language'] != 'zh':
raise Exception("tokenizer_yaha is only used for Chinese. Check your configure json file.")
for example in training_data.training_examples:
example.set("tokens", self.tokenize(example.text))
示例8: __init__
# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import RasaNLUConfig [as 别名]
def __init__(self):
self.rasa_config = RasaNLUConfig(self.config_file)
self.trainer = Trainer(self.rasa_config, self.builder)
示例9: __init__
# 需要导入模块: from rasa_nlu import config [as 别名]
# 或者: from rasa_nlu.config import RasaNLUConfig [as 别名]
def __init__(self, data_provider, config_file, data_file, model_dir):
logging.basicConfig(level=logging.INFO, format='%(asctime)s %(message)s')
# store unparsed messages, so later we can train bot
self.unparsed_messages = []
self.data_provider = data_provider
self.data_file = data_file
self.model_dir = model_dir
self.rasa_config = RasaNLUConfig(config_file)