Ejemplo n.º 1
0
    def __init__(self):
        if Handle.dialog is None:
            dic = DictManager()
            dic.load_dict('../../data/test/name.dic')
            nlu = NLU(dic)
            nlu.setPreprocessor('zhBook')
            nlu.appendTagger(GreedyTagger())
            tagger = RuleTagger()
            ruleFile = '../../data/test/RuleEngine/rule0'
            tagger.loadRules(ruleFile)
            nlu.appendTagger(tagger)
            nlu.setPreprocessor('govTitle')
            nlu.appendRewriter(RemoveTokRewriter())

            nlr = NLR()
            nlr.load_template('../../data/reply-template')

            semantic = SemanticBase()
            semantic.loadSemanticRules(
                '../../data/test/Semantics/wx-test-semantics.json')

            indexer = GovTitleExtracter()
            indexer.getIndexId(dic)
            indexer.loadIndex('../../tools/gov/gov-index')
            indexer.loadContent('../../tools/gov/gov_q')

            dialog = DialogManager()
            dialog.addModule("NLU", nlu)
            dialog.addModule("NLR", nlr)
            dialog.addModule("SEMANTIC", semantic)
            dialog.addModule("GOV", indexer)
            dialog.loadHandler('../../data/state-def-wx.json')
            Handle.dialog = dialog
        else:
            print('dialog already inited')
                        default='Welcome',
                        help='current taskId')
    parser.add_argument('--w',
                        type=str,
                        default='',
                        help='whiteboard variables')
    parser.add_argument(
        '--ss',
        type=str,
        default='../data/test/Semantics/wx-test-semantics.json',
        help='semantics file')
    parser.add_argument('--ii', type=str, help='test dialog file')

    args = parser.parse_args()
    dic = DictManager()
    dic.load_dict(args.d)
    nlu = NLU(dic)
    nlu.appendTagger(GreedyTagger())
    tagger = RuleTagger()
    ruleFile = '../data/test/RuleEngine/rule0'
    tagger.loadRules(ruleFile)
    nlu.appendTagger(tagger)
    nlu.setPreprocessor('govTitle')
    nlu.appendRewriter(RemoveTokRewriter())

    nlr = NLR()
    nlr.load_template(args.t)

    semantic = SemanticBase()
    semantic.loadSemanticRules(args.ss)