當前位置: 首頁>>代碼示例>>Python>>正文


Python JaggedArrayNode.serialize方法代碼示例

本文整理匯總了Python中sefaria.model.schema.JaggedArrayNode.serialize方法的典型用法代碼示例。如果您正苦於以下問題:Python JaggedArrayNode.serialize方法的具體用法?Python JaggedArrayNode.serialize怎麽用?Python JaggedArrayNode.serialize使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在sefaria.model.schema.JaggedArrayNode的用法示例。


在下文中一共展示了JaggedArrayNode.serialize方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: build_index

# 需要導入模塊: from sefaria.model.schema import JaggedArrayNode [as 別名]
# 或者: from sefaria.model.schema.JaggedArrayNode import serialize [as 別名]
def build_index(titles):

    struct_node = JaggedArrayNode()
    struct_node.add_title('Sefer HaKana', 'en', primary=True)
    struct_node.add_title(u'ספר הקנה', 'he', primary=True)
    struct_node.key = 'Sefer HaKana'
    struct_node.depth = 2
    struct_node.addressTypes = ['Integer', 'Integer']
    struct_node.sectionNames = ['Chapter', 'Comment']
    struct_node.add_title('Sefer HaQana', 'en')
    struct_node.add_title('Sefer HaQanah', 'en')
    struct_node.add_title('Sefer Hakana', 'en')
    struct_node.add_title('Sefer HaKanah', 'en')
    struct_node.validate()

    alt_struct = TitledTreeNode()
    for index, title in enumerate(titles):
        i = index + 1
        node = ArrayMapNode()
        node.add_title('Chapter {}'.format(i), 'en', primary=True)
        node.add_title(title.replace(u'ד"ה ', u''), 'he', primary=True)
        node.depth = 0
        node.wholeRef = 'Sefer HaKana {}'.format(i)
        alt_struct.append(node)

    return {
        'title': 'Sefer HaKana',
        'categories': ['Kabbalah'],
        'schema': struct_node.serialize(),
        'alt_structs': {'Titles': alt_struct.serialize()}
    }
開發者ID:,項目名稱:,代碼行數:33,代碼來源:

示例2: post_yitzira

# 需要導入模塊: from sefaria.model.schema import JaggedArrayNode [as 別名]
# 或者: from sefaria.model.schema.JaggedArrayNode import serialize [as 別名]
def post_yitzira():
    node = JaggedArrayNode()
    node.add_title('Sefer Yetzirah', 'en', primary=True)
    node.add_title(u'ספר יצירה', 'he', primary=True)
    node.key = 'Sefer Yetzirah'
    node.depth = 2
    node.addressTypes = ['Integer', 'Integer']
    node.sectionNames = ['Chapter', 'Mishnah']
    node.validate()

    y_index = {
        'title': 'Sefer Yetzirah',
        'categories': ['Kabbalah'],
        'language': 'he',
        'schema': node.serialize()
    }

    y_version = {
        'versionTitle': 'Sefer Yetzirah, Warsaw 1884',
        'versionSource': 'http://primo.nli.org.il/primo_library/libweb/action/dlDisplay.do?vid=NLI&docId=NNL_ALEPH001310968',
        'language': 'he',
        'text': parse_yitzira()
    }
    post_index(y_index)
    post_text("Sefer Yetzirah", y_version, index_count='on')
開發者ID:JonMosenkis,項目名稱:Sefaria-Data,代碼行數:27,代碼來源:yitzira_parser.py

示例3: get_base_index

# 需要導入模塊: from sefaria.model.schema import JaggedArrayNode [as 別名]
# 或者: from sefaria.model.schema.JaggedArrayNode import serialize [as 別名]
    def get_base_index(en_title, he_title):
        node = JaggedArrayNode()
        node.add_primary_titles(en_title, he_title)
        node.add_structure(['Chapter', 'Halakhah'])
        node.validate()

        return {
            'title': en_title,
            'categories': ["Masechtot Ketanot"],
            'schema': node.serialize()
        }
開發者ID:,項目名稱:,代碼行數:13,代碼來源:

示例4: post_simple_commentaries

# 需要導入模塊: from sefaria.model.schema import JaggedArrayNode [as 別名]
# 或者: from sefaria.model.schema.JaggedArrayNode import serialize [as 別名]
def post_simple_commentaries():
    ramban_node, rasag_node = JaggedArrayNode(), JaggedArrayNode()
    ramban_text = parse_general('yitzira_ramban.txt')
    rasag_text = parse_general('yitzira_rasag.txt')

    ramban_node.add_title("Ramban on Sefer Yetzirah", 'en', primary=True)
    ramban_node.add_title(u'רמב"ן על ספר יצירה', 'he', primary=True)
    ramban_node.key = "Ramban on Sefer Yetzirah"
    ramban_node.addressTypes = ['Integer', 'Integer', 'Integer']
    ramban_node.sectionNames = ["Chapter", "Mishnah", "Comment"]
    ramban_node.toc_zoom = 2
    ramban_node.depth = 3
    ramban_node.validate()

    rasag_node.add_title("Rasag on Sefer Yetzirah", 'en', primary=True)
    rasag_node.add_title(u'רס"ג על ספר יצירה', 'he', primary=True)
    rasag_node.key = "Rasag on Sefer Yetzirah"
    rasag_node.addressTypes = ['Integer', 'Integer', 'Integer']
    rasag_node.sectionNames = ["Chapter", "Mishnah", "Comment"]
    rasag_node.toc_zoom = 2
    rasag_node.depth = 3
    rasag_node.validate()

    ramban_index = {
        "title": "Ramban on Sefer Yetzirah",
        "categories": ["Commentary2", "Kabbalah", "Ramban"],
        "language": "he",
        "schema": ramban_node.serialize()
    }
    post_index(ramban_index)
    post_text("Ramban on Sefer Yetzirah", {
        'versionTitle': 'Ramban on Sefer Yetzirah, Warsaw 1884',
        'versionSource': 'http://primo.nli.org.il/primo_library/libweb/action/dlDisplay.do?vid=NLI&docId=NNL_ALEPH001310968',
        'language': 'he',
        'text': ramban_text
    })

    rasag_index = {
        "title": "Rasag on Sefer Yetzirah",
        "categories": ["Commentary2", "Kabbalah", "Rasag"],
        "language": "he",
        "schema": rasag_node.serialize()
    }
    post_index(rasag_index)
    post_text("Rasag on Sefer Yetzirah", {
        'versionTitle': 'Rasage on Sefer Yetzirah, Warsaw 1884',
        'versionSource': 'http://primo.nli.org.il/primo_library/libweb/action/dlDisplay.do?vid=NLI&docId=NNL_ALEPH001310968',
        'language': 'he',
        'text': rasag_text
    })
    links = linker(ramban_text, "Ramban on Sefer Yetzirah")
    links.extend(linker(rasag_text, "Rasag on Sefer Yetzirah"))
    post_link(links)
開發者ID:JonMosenkis,項目名稱:Sefaria-Data,代碼行數:55,代碼來源:yitzira_parser.py

示例5: build_index

# 需要導入模塊: from sefaria.model.schema import JaggedArrayNode [as 別名]
# 或者: from sefaria.model.schema.JaggedArrayNode import serialize [as 別名]
 def build_index(self, base_title, he_base_title):
     """
     Builds the root schema node for the commentary
     :return: serialized index
     """
     node = JaggedArrayNode()
     he_author = self.get_author()
     en_author = commentatorNames[he_author]
     node.add_primary_titles('{} on {}'.format(en_author, base_title), u'{} על {}'.format(he_author, he_base_title))
     node.add_structure(['Chapter', 'Halakhah', 'Comment'])
     node.validate()
     return {
         'title': '{} on {}'.format(en_author, base_title),
         'categories': ['Tanaitic', 'Commentary', en_author, "Masechtot Ketanot"],
         'schema': node.serialize(),
         'collective_title': en_author,
         'dependence': "Commentary",
         'base_text_titles': [base_title]
     }
開發者ID:JonMosenkis,項目名稱:Sefaria-Data,代碼行數:21,代碼來源:DCXMLsubs.py


注:本文中的sefaria.model.schema.JaggedArrayNode.serialize方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。