def __init__(self, lang): data_dir = pres.resource_filename('gramtool', 'data') data = lambda *args: os.path.join(data_dir, *args) # noqa grammar_file = data('grammar.yaml') rules_file = data(lang, 'grammar') hunspell_dic_file = data(lang, 'hunspell.dic') hunspell_aff_file = data(lang, 'hunspell.aff') self.tree = get_grammar_tree(grammar_file) self.rules = get_grammar_rules(self.tree, rules_file) self.hunspell = get_hunspell_dict(hunspell_aff_file, hunspell_dic_file) self.grammar = Grammar(self.hunspell, self.tree, self.rules)
def __init__(self, lang): data_dir = pres.resource_filename('gramtool', 'data') data = lambda *args: os.path.join(data_dir, *args) # noqa grammar_file = data('grammar.yaml') rules_file = data(lang, 'grammar') hunspell_dic_file = data(lang, 'hunspell.dic') hunspell_aff_file = data(lang, 'hunspell.aff') self.tree = get_grammar_tree(grammar_file) self.rules = get_grammar_rules(self.tree, rules_file) self.hunspell = get_hunspell_dict(hunspell_aff_file, hunspell_dic_file) self.grammar = Grammar(self.hunspell, self.tree, self.rules)
def __init__(self, lang): path = '..', '..', '..', 'data' data_dir = os.path.abspath(os.path.join(__file__, *path)) data = lambda *args: os.path.join(data_dir, *args) grammar_file = data('grammar.yaml') rules_file = data(lang, 'grammar') hunspell_dic_file = data(lang, 'hunspell.dic') hunspell_aff_file = data(lang, 'hunspell.aff') self.tree = get_grammar_tree(grammar_file) self.rules = get_grammar_rules(self.tree, rules_file) self.hunspell = get_hunspell_dict(hunspell_aff_file, hunspell_dic_file) self.grammar = Grammar(self.hunspell, self.tree, self.rules)
def __init__(self, lang): path = '..', '..', '..', 'data' data_dir = os.path.abspath(os.path.join(__file__, *path)) data = lambda *args: os.path.join(data_dir, *args) grammar_file = data('grammar.yaml') rules_file = data(lang, 'grammar') hunspell_dic_file = data(lang, 'hunspell.dic') hunspell_aff_file = data(lang, 'hunspell.aff') self.tree = get_grammar_tree(grammar_file) self.rules = get_grammar_rules(self.tree, rules_file) self.hunspell = get_hunspell_dict(hunspell_aff_file, hunspell_dic_file) self.grammar = Grammar(self.hunspell, self.tree, self.rules)
def _get_hunspell(self): hunspell_dic_file = self.data_dir / self.language / 'hunspell.dic' hunspell_aff_file = self.data_dir / self.language / 'hunspell.aff' return get_hunspell_dict(str(hunspell_aff_file), str(hunspell_dic_file))
def hunspell(self): hunspell_dic_file = self.data_dir / self.language / 'hunspell.dic' hunspell_aff_file = self.data_dir / self.language / 'hunspell.aff' return get_hunspell_dict(str(hunspell_aff_file), str(hunspell_dic_file))