예제 #1
0
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()}
    }
예제 #2
0
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()
        }
    }
예제 #3
0
import unicodecsv
from sources.functions import get_index, post_index, numToHeb
from sefaria.model.schema import ArrayMapNode, TitledTreeNode

day_root, book_root = TitledTreeNode(), TitledTreeNode()
with open('psalms_30_day_cycle.csv') as infile:
    reader = unicodecsv.DictReader(infile)
    for item in reader:
        map_node = ArrayMapNode()
        map_node.add_title('Day {}'.format(item['Day']), 'en', primary=True)
        map_node.add_title(u'יום {}'.format(numToHeb(item['Day'])),
                           'he',
                           primary=True)
        map_node.depth = 0
        map_node.includeSections = True
        map_node.wholeRef = item['Ref']
        day_root.append(map_node)

with open('psalms_books.csv') as infile:
    reader = unicodecsv.DictReader(infile)
    for item in reader:
        map_node = ArrayMapNode()
        map_node.add_title('Book {}'.format(item['Book en']),
                           'en',
                           primary=True)
        map_node.add_title(u'ספר {}'.format(item['Book he']),
                           'he',
                           primary=True)
        map_node.depth = 0
        map_node.includeSections = True
        map_node.wholeRef = item['Ref']
# encoding=utf-8

import unicodecsv
from sources.functions import get_index, post_index, numToHeb
from sefaria.model.schema import ArrayMapNode, TitledTreeNode

day_root, book_root = TitledTreeNode(), TitledTreeNode()
with open('psalms_30_day_cycle.csv') as infile:
    reader = unicodecsv.DictReader(infile)
    for item in reader:
        map_node = ArrayMapNode()
        map_node.add_title('Day {}'.format(item['Day']), 'en', primary=True)
        map_node.add_title(u'יום {}'.format(numToHeb(item['Day'])), 'he', primary=True)
        map_node.depth = 0
        map_node.includeSections = True
        map_node.wholeRef = item['Ref']
        day_root.append(map_node)

with open('psalms_books.csv') as infile:
    reader = unicodecsv.DictReader(infile)
    for item in reader:
        map_node = ArrayMapNode()
        map_node.add_title('Book {}'.format(item['Book en']), 'en', primary=True)
        map_node.add_title(u'ספר {}'.format(item['Book he']), 'he', primary=True)
        map_node.depth = 0
        map_node.includeSections = True
        map_node.wholeRef = item['Ref']
        book_root.append(map_node)
p_index = get_index('Psalms')
p_index['alt_structs'] = {
    'Books': book_root.serialize(),