def test_train_w2v(self): cfg = read_configuration("./conf/train.w2v.json") cmp = init_component(cfg) cmp.train({}) cmp.save() assert os.path.exists("./tmp/emb/w2v.text8.bin") cmp.shutdown()
def test_ner_infer(self): cfg = read_configuration("./conf/infer.ner.json") cmp = init_component(cfg) smem = {"text": "west of the town"} cmp.forward(smem) assert "tags" in smem cmp.shutdown()
def test_hcn_infer(self): cfg = read_configuration("./conf/infer.hcn.json") cmp = init_component(cfg) smem = {"text": "cheap restaurant in Moscow"} cmp.forward(smem) assert "action" in smem cmp.shutdown()
def test_hcn_train(self): cfg = read_configuration("./conf/train.hcn.json") cmp = init_component(cfg) cmp.train({}) cmp.save() tc = cmp.get_trained_component() assert isinstance(tc, HcnComponent) cmp.shutdown()
def test_ner_train(self): cfg = read_configuration("./conf/train.ner.json") cmp = init_component(cfg) cmp.train({}) cmp.save() assert os.path.exists("./tmp/models/ner.index") assert os.path.exists("./tmp/models/ner.meta") assert os.path.exists("./tmp/models/checkpoint") cmp.shutdown()
def test_chars_vocab_train(self): cfg = read_configuration("./conf/train.vocab.chars.json") cmp = init_component(cfg) cmp.train({}) cmp.save() assert os.path.exists("./tmp/vocabs/ner.chars.vocab.txt") tc = cmp.get_trained_component() assert isinstance(tc, VocabComponent) assert 26 == len(tc.vocab._t2i)
def test_bow_infer(self): cfg = read_configuration("./conf/infer.bow.json") cmp = init_component(cfg) smem = {"text": "cheap restaurant"} cmp.forward(smem) assert "bow" in smem for i, v in enumerate(smem["bow"]): if i == 5 or i == 36: assert v == 1 else: assert v == 0 cmp.shutdown()
def test_init_component(self): cfg = read_configuration("./conf/train.ner.json") cmp = init_component(cfg) assert isinstance(cmp, TrainPipeline)
def test_read_config(self): cfg = read_configuration("./conf/provider.ner.dstc2.json") assert cfg["batch_size"] == 10