def test_rebuild_same_quantity_of_links_for_many_to_one_default_only(self): title = "Rashi on Deuteronomy" base = "Deuteronomy" rf = Ref(title) linker = rf.autolinker() # prepare the text for the tests: # convert simple text to a complex text with default node and add base_text_* and dependence properties. index = library.get_index(title) convert_simple_index_to_complex(index) index.base_text_mapping = "many_to_one_default_only" index.base_text_titles = [base] index.dependence = "Commentary" index.save() # add intro node and give it some text intro = JaggedArrayNode() intro.add_shared_term("Introduction") intro.key = 'intro' intro.add_structure(["Chapter", "Paragraph"]) insert_first_child(intro, library.get_index(title).nodes) comm_ref = "{}, Introduction 1:1".format(title) tc = TextChunk(Ref(comm_ref), vtitle="test", lang="en") tc.text = "Intro first segment text" tc.save() # assert that despite adding text to the intro node, the number of links # should be exactly as they were before (e.g desired_link_count) found = linker.rebuild_links() desired_link_count = self.desired_link_counts[title] assert len(found) == desired_link_count
def test_rebuild_same_quantity_of_links_for_one_to_one_default_only(self): title = "Onkelos Genesis" base = "Genesis" rf = Ref(title) linker = rf.autolinker() # prepare the text for the tests: # convert simple text to a complex text with default node and add base_text_* and dependence properties. index = library.get_index(title) convert_simple_index_to_complex(index) index.base_text_mapping = "one_to_one_default_only" index.base_text_titles = [base] index.dependence = "Commentary" index.save() # add intro node and give it some text intro = JaggedArrayNode() intro.add_shared_term("Introduction") intro.key = 'intro' intro.add_structure(["Chapter", "Paragraph"]) insert_first_child(intro, library.get_index(title).nodes) comm_ref = "{}, Introduction 1:1".format(title) tc = TextChunk(Ref(comm_ref), vtitle="test", lang="en") tc.text = "Intro first segment text" tc.save() # need to change value of "generated_by" from "MatchBaseTextDepthAutoLinker" to "add_commentary_links" # and "link_type" from "targum" to "commentary" for l in LinkSet({ "refs": { "$regex": title }, "generated_by": "MatchBaseTextDepthAutoLinker" }): l.generated_by = linker._generated_by_string l.auto = linker._auto l.type = linker._link_type l.save() # assert that despite adding text to the intro node, the number of links # should be exactly as they were before (e.g desired_link_count) found = linker.rebuild_links() desired_link_count = self.desired_link_counts[title] assert len(found) == desired_link_count
def test_rebuild_same_quantity_of_links_for_one_to_one_default_only(self): title = "Onkelos Genesis" base = "Genesis" rf = Ref(title) linker = rf.autolinker() # prepare the text for the tests: # convert simple text to a complex text with default node and add base_text_* and dependence properties. index = library.get_index(title) convert_simple_index_to_complex(index) index.base_text_mapping = "one_to_one_default_only" index.base_text_titles = [base] index.dependence = "Commentary" index.save() # add intro node and give it some text intro = JaggedArrayNode() intro.add_shared_term("Introduction") intro.key = 'intro' intro.add_structure(["Chapter", "Paragraph"]) insert_first_child(intro, library.get_index(title).nodes) comm_ref = "{}, Introduction 1:1".format(title) tc = TextChunk(Ref(comm_ref), vtitle="test", lang="en") tc.text = "Intro first segment text" tc.save() # need to change value of "generated_by" from "MatchBaseTextDepthAutoLinker" to "add_commentary_links" # and "link_type" from "targum" to "commentary" for l in LinkSet({"refs": {"$regex": title}, "generated_by": "MatchBaseTextDepthAutoLinker"}): l.generated_by = linker._generated_by_string l.auto = linker._auto l.type = linker._link_type l.save() # assert that despite adding text to the intro node, the number of links # should be exactly as they were before (e.g desired_link_count) found = linker.rebuild_links() desired_link_count = self.desired_link_counts[title] assert len(found) == desired_link_count
i = library.get_index("Sefer HaChinuch") convert_simple_index_to_complex(i) i = library.get_index("Sefer HaChinuch") root = i.nodes n = JaggedArrayNode() n.key = "Opening Letter by the Author" n.add_title("Opening Letter by the Author", "en", primary=True) n.add_title(u"איגרת המחבר", "he", primary=True) n.depth = 1 n.sectionNames = ["Paragraph"] n.addressTypes = ["Integer"] insert_first_child(n, root) n = JaggedArrayNode() n.key = "Author's Introduction" n.add_title("Author's Introduction", "en", primary=True) n.add_title(u"הקדמת המחבר", "he", primary=True) n.depth = 1 n.sectionNames = ["Paragraph"] n.addressTypes = ["Integer"] insert_first_child(n, root) # while we're at it, let's nail some more. convert_simple_index_to_complex(library.get_index('Seder Olam Rabbah')) convert_simple_index_to_complex(library.get_index('Eight Chapters'))
shir.addressTypes = ["Integer"] lechu.key = "Lechu" lechu.add_title("Go See", "en", primary=True) lechu.add_title(u"לכו חזו", "he", primary=True) lechu.depth = 1 lechu.sectionNames = ["Paragraph"] lechu.addressTypes = ["Integer"] tinyana.key = "Tinyana" tinyana.add_title("Part II", "en", primary=True) tinyana.add_title("Tinyana", "en") tinyana.add_title(u"תנינא", "he", primary=True) tinyana.depth = 2 tinyana.sectionNames = ["Torah", "Section"] tinyana.addressTypes = ["Integer", "Integer"] letters.key = "Letters" letters.add_title("Letters", "en", primary=True) letters.add_title(u"מכתבים", "he", primary=True) letters.depth = 2 letters.sectionNames = ["Letter", "Paragraph"] letters.addressTypes = ["Integer", "Integer"] insert_first_child(lechu, root) insert_first_child(shir, root) insert_first_child(hakdama, root) insert_last_child(tinyana, root) insert_last_child(letters, root)