def parse_the_text(file_name_teshuvot, file_name_footnotes, dictionary): teshuvot_ja = function.parse(file_name_teshuvot) footnotes_ja = function.parse(file_name_footnotes) links = function.create_links(teshuvot_ja, dictionary) index_teshuvot = function.create_index(dictionary) index_footnotes = function.create_index(dictionary,footnotes, footnotes_hebrew) teshuvot_ja = util.clean_jagged_array(teshuvot_ja, ['\d+', '\+']) footnotes_ja = util.clean_jagged_array(footnotes_ja, ['\d+', '\+']) text_teshuvot = function.create_text(dictionary, teshuvot_ja) text_footnotes = function.create_text(dictionary, footnotes_ja) functions.post_index(index_teshuvot) functions.post_index(index_footnotes) functions.post_text_weak_connection('Teshuvot haRashba part {}'.format(dictionary['roman numeral']), text_teshuvot) functions.post_text_weak_connection('Footnotes to Teshuvot haRashba part {}'.format(dictionary['roman numeral']), text_footnotes) functions.post_link_weak_connection(links)
def parse_the_text(file_name_teshuvot, file_name_footnotes, dictionary): teshuvot_ja = function.parse(file_name_teshuvot) footnotes_ja = function.parse(file_name_footnotes) links = function.create_links(teshuvot_ja, dictionary) index_teshuvot = function.create_index(dictionary) index_footnotes = function.create_index(dictionary, footnotes, footnotes_hebrew) teshuvot_ja = util.clean_jagged_array(teshuvot_ja, ['\d+', '\+']) footnotes_ja = util.clean_jagged_array(footnotes_ja, ['\d+', '\+']) text_teshuvot = function.create_text(dictionary, teshuvot_ja) text_footnotes = function.create_text(dictionary, footnotes_ja) functions.post_index(index_teshuvot) functions.post_index(index_footnotes) functions.post_text_weak_connection( 'Teshuvot haRashba part {}'.format(dictionary['roman numeral']), text_teshuvot) functions.post_text_weak_connection( 'Footnotes to Teshuvot haRashba part {}'.format( dictionary['roman numeral']), text_footnotes) functions.post_link_weak_connection(links)
def extract_notes(footnote_struct): """ Extract notes from data structure to jaggedArray form (footnote data structure contains links). :param footnote_struct: Data structure created from align_footnotes() function. Recommended to run footnote linker, as this functions performs important editing on the footnotes. :return: Depth 2 jaggedArray for convenient upload via API. """ books = library.get_indexes_in_category('Tanach') notes = {} for book in books: notes[book] = [] for index, chapter in enumerate(footnote_struct[book]): chap_notes = [] for note in chapter: chap_notes.append(note['footnote']) notes[book].append(chap_notes) return notes jps_main = parse() jps_footnotes = align_footnotes(jps_main) links = footnote_linker(jps_main, jps_footnotes) upload_main_text(jps_main, True) upload_footnote_index() upload_footnotes(extract_notes(jps_footnotes), True) functions.post_link_weak_connection(links) set_flags(jps_main, True)