Ejemplo n.º 1
0
    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)
Ejemplo n.º 2
0
    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)
Ejemplo n.º 3
0
    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)
Ejemplo n.º 4
0
    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)
Ejemplo n.º 5
0
 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))
Ejemplo n.º 6
0
 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))