当前位置: 首页>>代码示例>>Python>>正文


Python JaggedArrayNode.validate方法代码示例

本文整理汇总了Python中sefaria.model.schema.JaggedArrayNode.validate方法的典型用法代码示例。如果您正苦于以下问题:Python JaggedArrayNode.validate方法的具体用法?Python JaggedArrayNode.validate怎么用?Python JaggedArrayNode.validate使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在sefaria.model.schema.JaggedArrayNode的用法示例。


在下文中一共展示了JaggedArrayNode.validate方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: post_yitzira

# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import validate [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

示例2: build_index

# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import validate [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,代码来源:

示例3: test_jaggedarray_fields

# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import validate [as 别名]
    def test_jaggedarray_fields(self):

        j = JaggedArrayNode()
        j.add_title(u"title1", "en", primary=True)\
         .add_title(u"ייי", "he", primary=True)\
         .add_title(u"title2", "en")\
         .add_title(u"ייכי", "he")
        j.depth = 1
        j.sectionNames = ["Foo"]
        j.addressTypes = ["Integer"]
        j.key = "bob"

        j.validate()

        for f in ["depth", "sectionNames", "addressTypes", "key"]:
            t = copy.deepcopy(j)
            delattr(t, f)

            with pytest.raises(IndexSchemaError):
                t.validate()

        t = copy.deepcopy(j)
        t.sectionNames += ["foob"]
        with pytest.raises(IndexSchemaError):
            t.validate()

        t = copy.deepcopy(j)
        t.addressTypes += ["Integer"]
        with pytest.raises(IndexSchemaError):
            t.validate()
开发者ID:JonMosenkis,项目名称:Sefaria-Project,代码行数:32,代码来源:node_test.py

示例4: get_base_index

# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import validate [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,代码来源:

示例5: post_simple_commentaries

# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import validate [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

示例6: commentary_ja_node

# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import validate [as 别名]
 def commentary_ja_node(en_title, he_title):
     """
     Each commentary is a complex text, with a root schema and depth 3 JAnodes for each tractate. The JAnode for each
     tractate is essentially identical across commentaries. The root schema is what defines the particular
     commentator.
     :param en_title: English Title of base text
     :param he_title: Hebrew Title of base text
     :return: JaggedArrayNode
     """
     node = JaggedArrayNode()
     node.add_primary_titles(en_title, he_title)
     node.add_structure(['Chapter', 'Halakhah', 'Comment'])
     node.validate()
     return node
开发者ID:,项目名称:,代码行数:16,代码来源:

示例7: test_remove

# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import validate [as 别名]
    def test_remove(self):
        j = JaggedArrayNode()
        j.add_title(u"title1", "en", primary=True)\
         .add_title(u"ייי", "he", primary=True)\
         .add_title(u"title2", "en")\
         .add_title(u"ייכי", "he")
        j.remove_title(u"title1", "en")
        j.depth = 1
        j.sectionNames = ["Foo"]
        j.addressTypes = ["Integer"]
        j.key = "bob"

        with pytest.raises(IndexSchemaError):
            j.validate()
开发者ID:JonMosenkis,项目名称:Sefaria-Project,代码行数:16,代码来源:node_test.py

示例8: construct_index

# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import validate [as 别名]
def construct_index():
    root = SchemaNode()
    root.add_title('Chesed LeAvraham', 'en', primary=True)
    root.add_title(u'חסד לאברהם', 'he', primary=True)
    root.key = 'Chesed LeAvraham'

    intro = JaggedArrayNode()
    intro.add_title('Introduction', 'en', primary=True)
    intro.add_title(u'הקדמה', 'he', primary=True)
    intro.key = 'Introduction'
    intro.depth = 1
    intro.sectionNames = ['Paragraph']
    intro.addressTypes = ['Integer']
    intro.validate()
    root.append(intro)

    even = JaggedArrayNode()
    even.add_title('Even Shetiya', 'en', primary=True)
    even.add_title(u'אבן שתיה', 'he', primary=True)
    even.key = 'Even Shetiya'
    even.sectionNames = ['Maayan']
    even.depth = 1
    even.addressTypes = ['Integer']

    maayanot = [u'עין כל', u'עין הקורא', u'עין הארץ', u'עין יעקב', u'עין משפט', u'עין גנים', u'עין גדי']
    for i, title in enumerate(maayanot):
        node = JaggedArrayNode()
        node.add_title('Maayan {}'.format(i+1), 'en', primary=True)
        node.add_title(title, 'he', primary=True)
        node.key = 'Maayan {}'.format(i+1)
        node.depth = 2
        node.sectionNames = ['Nahar', 'Paragraph']
        node.addressTypes = ['Integer', 'Integer']
        node.validate()
        even.append(node)
    even.validate()
    root.append(even)

    breichat = JaggedArrayNode()
    breichat.add_title('Breichat Avraham', 'en', primary=True)
    breichat.add_title(u'בריכת אברהם', 'he', primary=True)
    breichat.key = 'Breichat Avraham'
    breichat.depth = 2
    breichat.sectionNames = ['Shoket', 'Paragraph']
    breichat.addressTypes = ['Integer', 'Integer']
    breichat.validate()
    root.append(breichat)

    root.validate()
    return {
        'title': 'Chesed LeAvraham',
        'categories': ['Kabbalah'],
        'schema': root.serialize()
    }
开发者ID:,项目名称:,代码行数:56,代码来源:

示例9: build_index

# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import validate [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.validate方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。