sanskrit_data.schema.books

Intro

Here we define data-containers to store books. Books are stored or represented as a tree of BookPortion objects - book containing many chapters containing many lines etc..

class sanskrit_data.schema.books.BookPortion[source]

Bases: sanskrit_data.schema.common.UllekhanamJsonObject

classmethod add_indexes(db_interface)[source]
dump_book_portion(export_dir, db_interface)[source]
classmethod from_details(title, path=None, authors=None, targets=None, base_data=None, curated_content=None, portion_class=None, publication_details=None, source=None)[source]
classmethod from_path(path, db_interface)[source]
classmethod get_allowed_target_classes()[source]
get_path(db_interface)[source]
schema = {'description': 'A BookPortion could represent a Book or a chapter or a verse or a half-verse or a sentence or any such unit.', 'properties': {'editable_by_others': {'default': False}, 'creation_details': {'required': ['jsonClass'], 'type': 'object', 'properties': {'authors': {'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'names': {'minItems': 1, 'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'search_strings': {'items': {'type': 'string'}, 'type': 'array', 'description': 'Search strings which should match this text. It could be derived from script_renderings - by a simple copy (intended for use with a text index) or some intelligent tokenization thereof.'}, 'language_code': {'type': 'string'}, 'script_renderings': {'minItems': 1, 'items': {'required': ['text', 'jsonClass'], 'type': 'object', 'properties': {'encoding_scheme': {'type': 'string'}, 'text': {'type': 'string'}, 'jsonClass': {'enum': ['ScriptRendering'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'jsonClass': {'enum': ['Text'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'jsonClass': {'enum': ['NamedEntity'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'names': {'minItems': 1, 'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'search_strings': {'items': {'type': 'string'}, 'type': 'array', 'description': 'Search strings which should match this text. It could be derived from script_renderings - by a simple copy (intended for use with a text index) or some intelligent tokenization thereof.'}, 'language_code': {'type': 'string'}, 'script_renderings': {'minItems': 1, 'items': {'required': ['text', 'jsonClass'], 'type': 'object', 'properties': {'encoding_scheme': {'type': 'string'}, 'text': {'type': 'string'}, 'jsonClass': {'enum': ['ScriptRendering'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'jsonClass': {'enum': ['Text'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'jsonClass': {'enum': ['CreationDetails'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'source': {'properties': {'source_type': {'default': 'system_inferred', 'enum': ['system_inferred', 'user_supplied'], 'type': 'string', 'description': 'Does this data come from a machine, or a human? source_ prefix avoids keyword conflicts in some languages.'}, 'by_admin': {'type': 'boolean', 'description': 'Was the creator of this data an admin at the time it was created or updated?'}, 'id': {'type': 'string', 'description': 'Something to identify the particular data source.'}, 'jsonClass': {'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}, 'required': ['source_type', 'jsonClass'], 'type': 'object', 'description': 'Source of the json-data which contains this node. Eg. Uploader details in case of books, annotator in case of annotations. Consider naming the field that contains this object `source` to make querying uniform.', 'jsonClass': {'enum': ['DataSource']}}, 'base_data': {'enum': ['image', 'text'], 'type': 'string'}, 'portion_class': {'type': 'string', 'description': 'book, part, chapter, verse, line etc..'}, 'thumbnail_path': {'type': 'string'}, 'path': {'type': 'string', 'description': 'The path prefix where files are to be stored. If this field is empty, such a path is computed from _id of this object and its ancestors. Ideally, the value stored here should equal the result of this computation - but it may not be the case, especially in the following cases: * Imported books * Moved BookPortions. Once upon a time this field also uniquely identified a BookPortion.'}, 'curated_content': {'required': ['jsonClass'], 'type': 'object', 'properties': {'search_strings': {'items': {'type': 'string'}, 'type': 'array', 'description': 'Search strings which should match this text. It could be derived from script_renderings - by a simple copy (intended for use with a text index) or some intelligent tokenization thereof.'}, 'language_code': {'type': 'string'}, 'script_renderings': {'minItems': 1, 'items': {'required': ['text', 'jsonClass'], 'type': 'object', 'properties': {'encoding_scheme': {'type': 'string'}, 'text': {'type': 'string'}, 'jsonClass': {'enum': ['ScriptRendering'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'jsonClass': {'enum': ['Text'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'targets': {'items': {'required': ['container_id', 'jsonClass'], 'type': 'object', 'description': 'A BookPortion could represent a Book or a chapter or a verse or a half-verse or a sentence or any such unit.', 'properties': {'position': {'type': 'number', 'description': 'Any number describing the position of one BookPortion within another.'}, 'container_id': {'type': 'string'}, 'jsonClass': {'enum': ['BookPositionTarget'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'description': 'Target for BookPortion of which this BookPortion is a part. It is an array only for consistency. For any given BookPortion, one can get the right order of contained BookPortions by seeking all BookPortions referring to it in the targets list, and sorting them by their target.position values.', 'maxLength': 1}, 'publication_details': {'required': ['jsonClass'], 'type': 'object', 'description': 'Publication details of a BookPortion.', 'properties': {'publisher': {'required': ['jsonClass'], 'type': 'object', 'properties': {'names': {'minItems': 1, 'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'search_strings': {'items': {'type': 'string'}, 'type': 'array', 'description': 'Search strings which should match this text. It could be derived from script_renderings - by a simple copy (intended for use with a text index) or some intelligent tokenization thereof.'}, 'language_code': {'type': 'string'}, 'script_renderings': {'minItems': 1, 'items': {'required': ['text', 'jsonClass'], 'type': 'object', 'properties': {'encoding_scheme': {'type': 'string'}, 'text': {'type': 'string'}, 'jsonClass': {'enum': ['ScriptRendering'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'jsonClass': {'enum': ['Text'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'jsonClass': {'enum': ['NamedEntity'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'issue_page': {'type': 'string'}, 'release_time': {'type': 'string'}, 'canonical_source': {'type': 'string'}, 'jsonClass': {'enum': ['PublicationDetails'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'jsonClass': {'enum': ['BookPortion'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}, 'required': ['jsonClass'], 'type': 'object'}
target_class

alias of BookPositionTarget

class sanskrit_data.schema.books.BookPositionTarget[source]

Bases: sanskrit_data.schema.common.Target

classmethod from_details(container_id=None, position=None)[source]
schema = {'description': 'A BookPortion could represent a Book or a chapter or a verse or a half-verse or a sentence or any such unit.', 'properties': {'position': {'type': 'number', 'description': 'Any number describing the position of one BookPortion within another.'}, 'container_id': {'type': 'string'}, 'jsonClass': {'enum': ['BookPositionTarget'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}, 'required': ['container_id', 'jsonClass'], 'type': 'object'}
class sanskrit_data.schema.books.CreationDetails[source]

Bases: sanskrit_data.schema.common.NamedEntity

Many names are possible for the same work (eg. meghasandeshaH vs meghadUtam) - hence we extend the NamedEntity schema.

classmethod from_details(names, authors=None)[source]
schema = {'properties': {'jsonClass': {'enum': ['CreationDetails'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}, 'names': {'minItems': 1, 'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'search_strings': {'items': {'type': 'string'}, 'type': 'array', 'description': 'Search strings which should match this text. It could be derived from script_renderings - by a simple copy (intended for use with a text index) or some intelligent tokenization thereof.'}, 'jsonClass': {'enum': ['Text'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}, 'script_renderings': {'minItems': 1, 'items': {'required': ['text', 'jsonClass'], 'type': 'object', 'properties': {'encoding_scheme': {'type': 'string'}, 'text': {'type': 'string'}, 'jsonClass': {'enum': ['ScriptRendering'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'language_code': {'type': 'string'}}}, 'type': 'array'}, 'authors': {'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'names': {'minItems': 1, 'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'search_strings': {'items': {'type': 'string'}, 'type': 'array', 'description': 'Search strings which should match this text. It could be derived from script_renderings - by a simple copy (intended for use with a text index) or some intelligent tokenization thereof.'}, 'jsonClass': {'enum': ['Text'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}, 'script_renderings': {'minItems': 1, 'items': {'required': ['text', 'jsonClass'], 'type': 'object', 'properties': {'encoding_scheme': {'type': 'string'}, 'text': {'type': 'string'}, 'jsonClass': {'enum': ['ScriptRendering'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'language_code': {'type': 'string'}}}, 'type': 'array'}, 'jsonClass': {'enum': ['NamedEntity'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}}, 'required': ['jsonClass'], 'type': 'object'}
class sanskrit_data.schema.books.PublicationDetails[source]

Bases: sanskrit_data.schema.common.JsonObject

schema = {'description': 'Publication details of a BookPortion.', 'properties': {'publisher': {'required': ['jsonClass'], 'type': 'object', 'properties': {'names': {'minItems': 1, 'items': {'required': ['jsonClass'], 'type': 'object', 'properties': {'search_strings': {'items': {'type': 'string'}, 'type': 'array', 'description': 'Search strings which should match this text. It could be derived from script_renderings - by a simple copy (intended for use with a text index) or some intelligent tokenization thereof.'}, 'jsonClass': {'enum': ['Text'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}, 'script_renderings': {'minItems': 1, 'items': {'required': ['text', 'jsonClass'], 'type': 'object', 'properties': {'encoding_scheme': {'type': 'string'}, 'text': {'type': 'string'}, 'jsonClass': {'enum': ['ScriptRendering'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'type': 'array'}, 'language_code': {'type': 'string'}}}, 'type': 'array'}, 'jsonClass': {'enum': ['NamedEntity'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}}}, 'jsonClass': {'enum': ['PublicationDetails'], 'type': 'string', 'description': 'A hint used by json libraries to deserialize json data to an object of the appropriate type. This is necessary for sub-objects to have as well (to ensure that the deserialization functions as expected).'}, 'release_time': {'type': 'string'}, 'canonical_source': {'type': 'string'}, 'issue_page': {'type': 'string'}}, 'required': ['jsonClass'], 'type': 'object'}