Beispiel #1
0
def find_links(current_text, parent_text, dh_finder, *args):
    """

    :param current_text: Text being parsed. Must have keys "name" and "text"
    :param parent_text: Parent text text should be linked to. Must have keys "name" and "text"
    :param dh_finder:  function to find dh in text
    :return: List of links
    """

    matcher = Match(guess=True)
    links = []

    for chapter_num, chapter in enumerate(current_text['text']):

        if chapter:
            dh_list = [
                dh_finder(seif[0], *args) for seif in chapter
                if dh_finder(seif[0], *args)
            ]
            matches = matcher.match_list(dh_list,
                                         parent_text['text'][chapter_num],
                                         parent_text['name'])
            links.append(
                build_links(parent_text['name'], current_text['name'],
                            chapter_num + 1, matches))

    return [linker for sublist in links for linker in sublist]
Beispiel #2
0
def find_links(current_text, parent_text, dh_finder, *args):
    """

    :param current_text: Text being parsed. Must have keys "name" and "text"
    :param parent_text: Parent text text should be linked to. Must have keys "name" and "text"
    :param dh_finder:  function to find dh in text
    :return: List of links
    """

    matcher = Match(guess=True)
    links = []

    for chapter_num, chapter in enumerate(current_text['text']):

        if chapter:
            dh_list = [dh_finder(seif[0], *args) for seif in chapter if dh_finder(seif[0], *args)]
            matches = matcher.match_list(dh_list, parent_text['text'][chapter_num], parent_text['name'])
            links.append(build_links(parent_text['name'], current_text['name'], chapter_num+1, matches))

    return [linker for sublist in links for linker in sublist]
Beispiel #3
0
def create_links(sanhedrin_ja, yad_ramah_ja):
    list_of_links = []
    amud_number = 1
    match_object = Match(in_order=True,
                         min_ratio=80,
                         guess=False,
                         range=False,
                         can_expand=True)
    for amud_of_sanhedrin, amud_yad_ramah in zip(sanhedrin_ja, yad_ramah_ja):
        ref = 'Sanhedrin {}'.format(AddressTalmud.toStr('en', amud_number))
        the_first_few_words = take_the_first_few_words_of_each_paragraph(
            amud_yad_ramah)
        matches_dict = match_object.match_list(the_first_few_words,
                                               amud_of_sanhedrin, ref)
        for key in matches_dict:
            for match in matches_dict[key]:
                if match != 0:
                    # print'Amud: {} comment: {} corresponds to {}'.format(AddressTalmud.toStr('en', amud_number), key, match)
                    print create_link_text(amud_number, match, key)
                    list_of_links.append(
                        create_link_text(amud_number, match, key))
        amud_number += 1

    return list_of_links