コード例 #1
0
"""

# from sprinkle.models.VoiceCommand import User
from kochat.app import KochatApi
from kochat.app import KochatApi
from kochat.data import Dataset
from kochat.loss import CRFLoss, CosFace, CenterLoss, COCOLoss, CrossEntropyLoss
from kochat.model import intent, embed, entity
from kochat.proc import DistanceClassifier, GensimEmbedder, EntityRecognizer, SoftmaxClassifier

from konlpy.tag import Okt as Mecab

from sprinkle.scenarios.scenarios import call, schedule

dataset = Dataset(ood=True)
emb = GensimEmbedder(model=embed.FastText())

clf = DistanceClassifier(
    model=intent.CNN(dataset.intent_dict),
    loss=CenterLoss(dataset.intent_dict),
)

rcn = EntityRecognizer(
    model=entity.LSTM(dataset.entity_dict),
    loss=CRFLoss(dataset.entity_dict)
)

kochat = KochatApi(
    dataset=dataset,
    embed_processor=(emb, False),
    intent_classifier=(clf, False),
コード例 #2
0
ファイル: application.py プロジェクト: aiacademy131/deepbot
from kochat.app.scenario_manager import ScenarioManager
from kochat.loss import CRFLoss, CosFace, CenterLoss, COCOLoss, CrossEntropyLoss
from kochat.model import intent, embed, entity
from kochat.proc import DistanceClassifier, GensimEmbedder, EntityRecognizer, SoftmaxClassifier

from demo.scenrios import restaurant, travel, dust, weather
# from scenrios import restaurant, travel, dust, weather
# 에러 나면 이걸로 실행해보세요!

from flask import Flask

# 데이터 관리
dataset = Dataset()

# 임베딩
embed_processor = GensimEmbedder(model=embed.FastText())

# 인텐트 분류
intent_classifier = DistanceClassifier(
    model=intent.CNN(dataset.intent_dict),
    loss=CenterLoss(dataset.intent_dict),
)

# 개체명 인식
entity_recognizer = EntityRecognizer(model=entity.LSTM(dataset.entity_dict),
                                     loss=CRFLoss(dataset.entity_dict))

# 시나리오
scenario_manager = ScenarioManager([weather, dust, travel, restaurant])

# 학습 여부