Пример #1
0
def init(rule_dict, pwd=join_path('.', 'data', 'rules')):
    '''Initialize rules from file.'''

    for elem in run_file(join_path(pwd, 'rules_list.csv')):
        rule_dict[elem] = Rule(elem)

    rules_list = ['nominal', 'verbal']
    for rule_name in rules_list:
        for elem in run_file(join_path(pwd, rule_name+'.csv')):
            name, par, subs = elem.split(',')
            rule_dict[name].insert(par, subs)
Пример #2
0
def init_category(category, pwd=join_path('.', 'data', 'knowledge')):
    '''
    Initializes the association between concepts and entities of a
    given lexical category.
    '''

    table[category] = [
        entity.from_line(category, elem)
        for elem in run_file(join_path(pwd, category+'.csv'))
    ]
Пример #3
0
def init(extra, dic, rules, pwd):
    if extra not in EXTRA_LIST:
        raise UnknownCategoryError(extra)
    for elem in utils.run_file(join_path(pwd, extra+'.csv')):
        if extra in NOMINAL_CATEGORY_LIST:
            item = nominal.from_line(elem, rules)
        elif extra == 'verb':
            item = verbal.from_line(elem, rules)
        elif extra == 'preposition':
            item = preposition.from_line(elem)
        elif extra == 'personal_pronoun':
            item = personal_pronoun.from_line(elem, rules)
        elif extra == 'possessive_pronoun':
            item = possessive_pronoun.from_line(elem, rules)
        elif extra == 'contraction':
            item = contraction.from_line(elem, rules)
        dic[item.index] = item
Пример #4
0
def init_knowledge(pwd):
    '''Initialize the concepts' knowledge.'''

    for elem in run_file(join_path(pwd, 'concept.csv')):
        x = concept.from_line(elem)
        knowledge[x.index] = x