def __init__(self, model_path="model/ch-corpus-3sg.bin", rule_path="RuleMatcher/rule/", stopword="jieba_dict/stopword.txt", jieba_dic="jieba_dict/dict.txt.big", jieba_user_dic="jieba_dict/userdict.txt"): print("[Console] Building a console...") print("*********************************") try: cur_dir = os.getcwd() curPath = os.path.dirname(__file__) os.chdir(curPath) # jieba custom setting. self.init_jieba(jieba_dic, jieba_user_dic) self.stopword = self.load_stopword(stopword) # build the rulebase. self.rb = rulebase.RuleBase() print("[Console] Loading vector model...") self.rb.load_model(model_path) print("[Console] Vector model has loaded.") print("[Console] Loading pre-defined rules.") self.rb.load_rules_from_dic(rule_path) print("[Console] Rules have loaded.") print("*********************************") print("[Console] Initialized successfully :>") os.chdir(cur_dir) except Exception as e: print("[Console] Opps! Initialized Error.") print(repr(e)) exit()
def __init__(self, console): self.console = console self.is_close = False self.memory = None self.attribute_list = None self.current_domain = None self.ret = None self.rb = rulebase.RuleBase()
def __init__(self, model_path="model/word2vec.model", rule_path="RuleMatcher/rule/", stopword="jieba_dict/stopword.txt", jieba_dic="jieba_dict/dict.txt.big", jieba_user_dic="jieba_dict/userdict.txt"): print("[Console] Building a console...") cur_dir = os.getcwd() curPath = os.path.dirname(__file__) os.chdir(curPath) # jieba custom setting. self.init_jieba(jieba_dic, jieba_user_dic) self.stopword = self.load_stopword(stopword) # build the rulebase. self.rb = rulebase.RuleBase() print("[Console] Loading the word embedding model...") try: self.rb.load_model(model_path) except FileNotFoundError as e: print("[Console] 請確定詞向量模型有正確配置") print(e) exit() except Exception as e: print("[Gensim]") print(e) exit() print("[Console] Loading pre-defined rules.") self.rb.load_rules_from_dic(rule_path) print("[Console] Initialized successfully :>") os.chdir(cur_dir)
def __init__(self, model_path="model/ch-corpus-3sg.bin", rule_path="RuleMatcher/rule/", stopword="jieba_dict/stopword.txt", jieba_dic="jieba_dict/dict.txt.big", jieba_user_dic="jieba_dict/userdict.txt"): print("[Console] Building a console...") print("*********************************") try: # jieba custom setting. self.init_jieba(jieba_dic, jieba_user_dic) self.stopword = self.load_stopword(stopword) # build the rulebase. self.rb = rulebase.RuleBase() self.rb.load_model(model_path) self.rb.load_rules_from_dic(rule_path) print("*********************************") print("[Console] Initialized successfully :>") except Exception as e: print("[Console] Opps! Initialized Error.") print(repr(e)) exit()