Example #1
0
def select_linkage(sent, num_linkages):
    """
    Поиск наиболее точной структуры предложения
    Аргументы:
    sent - предложение с пометками
    num_linkages - количество вариантов структур предложения
    Возвращаемое значение:
    linkage - структура предложения выданная парсером
    """ 
    ind = 1
    is_good = False
    is_v_or_n = False
    linkage = clg.linkage_create(0, sent, parse_opts)
    for num in range(clg.linkage_get_num_words(linkage)):
        if (clg.linkage_get_word(linkage, num).find(".v") >= 0 or clg.linkage_get_word(linkage, num).find(".n") >= 0):
            is_v_or_n = True
    while (ind < num_linkages and is_good == False):
        for i in range(clg.linkage_get_num_links(linkage)):
            if (clg.linkage_get_link_label(linkage, i).find("W") == 0):
                if (clg.linkage_get_word(linkage, clg.linkage_get_link_rword(linkage, i)).find(".v") >= 0 or clg.linkage_get_word(linkage, clg.linkage_get_link_rword(linkage, i)).find(".n") >= 0):
                    is_good = True
        if (is_good == False and is_v_or_n == True and ind < num_linkages):
            clg.linkage_delete(linkage)
            linkage = clg.linkage_create(ind, sent, parse_opts)
        ind += 1
    return linkage
Example #2
0
 def __init__(self, idx, sentence, parse_options):
     # Keep all args passed into clg.* functions.
     self.sentence, self.parse_options = sentence, parse_options
     self._obj = clg.linkage_create(idx, sentence._obj, parse_options)
Example #3
0
 def __init__(self, idx, sentence, parse_options):
     # Keep all args passed into clg.* functions.
     self.sentence, self.parse_options = sentence, parse_options
     self._obj = clg.linkage_create(idx, sentence._obj, parse_options)