Esempio 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)
Esempio 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)
Esempio 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)
Esempio 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)
Esempio n. 5
0
 def _get_grammar(self):
     rules_file = self.data_dir / self.language / 'grammar'
     rules = get_grammar_rules(self.symbols, str(rules_file))
     return Grammar(self.hunspell, self.symbols, rules)
Esempio n. 6
0
 def grammar(self):
     symbols = self.symbols()
     rules_file = self.data_dir / self.language / 'grammar'
     rules = get_grammar_rules(symbols, str(rules_file))
     return Grammar(self.hunspell(), symbols, rules)