本文整理汇总了Python中sefaria.model.schema.JaggedArrayNode.key方法的典型用法代码示例。如果您正苦于以下问题:Python JaggedArrayNode.key方法的具体用法?Python JaggedArrayNode.key怎么用?Python JaggedArrayNode.key使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类sefaria.model.schema.JaggedArrayNode
的用法示例。
在下文中一共展示了JaggedArrayNode.key方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: construct_index
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [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()
}
示例2: test_presentation_and_default
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def test_presentation_and_default(self):
s = SchemaNode()
s.key = "root"
s.add_title("root", "en", primary=True)
j2 = JaggedArrayNode()
j2.key = "default"
j2.default = True
j2.depth = 1
j2.sectionNames = ["Foo"]
j2.addressTypes = ["Integer"]
s.append(j2)
assert not s.has_titled_continuation()
j = JaggedArrayNode()
j.key = "child1"
j.depth = 1
j.sectionNames = ["Foo"]
j.addressTypes = ["Integer"]
j.add_title("Child 1", "en", primary=True)
j.add_title("Sweet Child", "en", presentation="alone")
j.add_title("Sweet Child of Mine", "en", presentation="both")
s.append(j)
s.validate()
assert s.has_titled_continuation()
assert s.has_numeric_continuation()
assert not j.has_titled_continuation()
assert not j2.has_titled_continuation()
assert j2.has_numeric_continuation()
assert j.has_numeric_continuation()
td = s.title_dict()
assert len(td) == 7
target = {
'root': j2,
'root, Child 1': j,
'root, Sweet Child of Mine': j,
'root Child 1': j,
'root Sweet Child of Mine': j,
'Sweet Child of Mine': j,
'Sweet Child': j,
}
assert td == target
示例3: build_index
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [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()}
}
示例4: test_default_chain
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def test_default_chain(self):
s = SchemaNode()
s.key = "root"
s.add_title("root", "en", primary=True)
s.add_title("alt root", "en")
s2 = SchemaNode()
s2.key = "default"
s2.default = True
s2.append_to(s)
j = JaggedArrayNode()
j.key = "default"
j.depth = 1
j.default = True
j.sectionNames = ["Foo"]
j.addressTypes = ["Integer"]
j.append_to(s2)
s.validate()
assert s.has_numeric_continuation()
assert s2.has_numeric_continuation()
assert j.has_numeric_continuation()
assert not s.has_titled_continuation()
assert not s2.has_titled_continuation()
assert not j.has_titled_continuation()
示例5: test_jaggedarray_fields
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [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()
示例6: post_yitzira
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [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')
示例7: create_default_nodes
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def create_default_nodes():
default = JaggedArrayNode()
default.default = True
default.key = 'default'
default.depth = 2
default.addressTypes = ["Integer", "Integer"]
default.sectionNames = ["Mitzvah", "Comment"]
return default
示例8: create_commentary_node
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def create_commentary_node():
commentary = JaggedArrayNode()
commentary.default = True
commentary.key = 'default'
commentary.depth = 3
commentary.addressTypes = ["Integer", "Integer", "Integer"]
commentary.sectionNames = ["Perek", "Pasuk", "Comment"]
return commentary
示例9: create_default_nodes
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def create_default_nodes():
default_node = JaggedArrayNode()
default_node.key = "default"
default_node.default = True
default_node.depth = 1
default_node.addressTypes = ["Integer"]
default_node.sectionNames = ["Comment"]
return default_node
示例10: create_jagged_array_node
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def create_jagged_array_node():
jagged_array_node = JaggedArrayNode()
jagged_array_node.key = 'default'
jagged_array_node.default = True
jagged_array_node.depth = 1
jagged_array_node.addressTypes = ["Integer"]
jagged_array_node.sectionNames = ["Comment"]
return jagged_array_node
示例11: create_jagged_array_nodes
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def create_jagged_array_nodes(en_name, he_name):
book_node = JaggedArrayNode()
book_node.key = en_name
book_node.add_title(en_name, 'en', primary=True)
book_node.add_title(he_name, 'he', primary=True)
book_node.depth = 2
book_node.addressTypes = ["Integer", "Integer"]
book_node.sectionNames = ["Chapter", "Verse"]
return book_node
示例12: create_intro_node
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def create_intro_node():
intro = JaggedArrayNode()
intro.add_title('Introduction', 'en', primary=True)
intro.add_title(u'הקדמה', 'he', primary=True)
intro.key = 'Introduction'
intro.depth = 1
intro.addressTypes = ["Integer"]
intro.sectionNames = ["Comment"]
return intro
示例13: create_schema
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def create_schema():
rif_on_nedarim = JaggedArrayNode()
rif_on_nedarim.add_title('Rif_Nedarim', 'en', primary=True)
rif_on_nedarim.add_title(u'רי"ף נדרים', 'he', primary=True)
rif_on_nedarim.key = 'Rif_Nedarim'
rif_on_nedarim.depth = 2
rif_on_nedarim.addressTypes = ["Talmud", "Integer"]
rif_on_nedarim.sectionNames = ["Daf", "Line"]
return rif_on_nedarim
示例14: create_mitzvah_node
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def create_mitzvah_node(en_name, he_name):
mitzvah = JaggedArrayNode()
mitzvah.add_title(en_name, 'en', primary=True)
mitzvah.add_title(he_name, 'he', primary=True)
mitzvah.key = en_name
mitzvah.depth = 2
mitzvah.addressTypes = ["Integer", "Integer"]
mitzvah.sectionNames = ["Mitzvah", "Comment"]
return mitzvah
示例15: create_schema
# 需要导入模块: from sefaria.model.schema import JaggedArrayNode [as 别名]
# 或者: from sefaria.model.schema.JaggedArrayNode import key [as 别名]
def create_schema():
gra_schema = JaggedArrayNode()
gra_schema.add_title('Gra on Pirkei Avot', 'en', primary=True)
gra_schema.add_title(u'גר"א על פרקי אבות', 'he', primary=True)
gra_schema.key = 'Gra on Pirkei Avot'
gra_schema.depth = 3
gra_schema.addressTypes = ["Integer", "Integer", "Integer"]
gra_schema.sectionNames = ["Perek", "Mishna", "Comment"]
return gra_schema