formulae nemo

class formulae.nemo.NemoFormulae(*args, **kwargs)
CACHED = ['r_index', 'get_inventory', 'get_collection', 'get_reffs', 'get_passage', 'get_siblings', 'get_open_texts', 'get_all_corpora', 'semantic', 'make_coins', 'expose_ancestors_or_children', 'make_members', 'transform']

Assets dictionary model

after_request(response: Response) Response

Post-processes the response object after each request.

  • Disables caching for authentication and language-switching routes.

  • Applies extended caching for static assets.

  • Sets general cache-control headers using CACHE_MAX_AGE for all other responses.

  • Persists certain variables from g to the session.

call_collate_api(obj_ids: list, subrefers: list) Dict[str, str]

Transforms texts, sends them to collate API and transforms the results

Returns:

static check_project_team() bool

A convenience function that checks if the current user is a part of the project team

create_blueprint() Blueprint

Enhance original blueprint creation with error handling

Returns:

flask.Blueprint

extract_notes(text: str) str

Constructs a dictionary that contains all notes with their ids. This will allow the notes to be rendered anywhere on the page and not only where they occur in the text.

Parameters:

text – the string to be transformed

Returns:

dict(‘note_id’: ‘note_content’)

static f_insert_in_list(l: list, i: int, v: Any) list

A Jinja filter to insert a value ‘v’ into an existing list ‘l’ at a given index ‘i’

Parameters:
  • l – the list of values

  • i – the index at which the item should be inserted

  • v – the value that will be inserted

Returns:

new list

static f_join_list_values(l: list, s: str) str

A Jinja filter to join the values of a list “l” into a string using the separator “s”

Parameters:
  • l – the list of values

  • s – the separator

Returns:

a string of the values joined by the separator

static f_random_int(start: int = 1, end: int = 10000) int

A Jinja filter to produce a random integer between 1 and 10,000

static f_remove_from_list(l: list, i: Any) list

A Jinja filter to remove item “i” from list “l”

Parameters:
  • l – the list

  • i – the item

Returns:

the list without the item

static f_replace_indexed_item(l: list, i: int, v: Any) list

A Jinja filter to replace an item at ‘i’ with the value of ‘v’

Parameters:
  • l – the list of values

  • i – the index to be replace

  • v – the value with which the indexed value will be replaced

Returns:

new list

get_all_corpora() Dict[str, List[XmlCapitainsCollectionMetadata]]

A convenience function to return all sub-corpora in all collections

Returns:

dictionary with all the collections as keys and a list of the corpora in the collection as values

get_first_passage(objectId: str) str

Provides a redirect to the first passage of given objectId

Parameters:

objectId – Collection identifier

Returns:

Redirection to the first passage of given text

get_locale() str

Retrieve the best matching locale using request headers

Note

Probably one of the thing to enhance quickly.

Returns:

the 3-letter language code

get_mss_eds(metadata, split_token: str = '**') list[str]

Extracts a list of manuscript edition references from the metadata.

The method retrieves the value associated with the Dublin Core ‘references’ field, splits it into separate entries based on a given split token (defaulting to “**”), and unescapes any escaped “**” sequences within each entry.

Parameters:
  • metadata – the metadata object containing a ‘DCTERMS.references’ field

  • split_token – the delimiter used to separate edition entries (default ‘**’)

Returns:

a list of manuscript edition references as strings

get_open_texts() Tuple[Dict[str, Tuple[str | Tuple[str, Tuple[str, str]], List[Sequence[str]] | list, XmlCapitainsReadableMetadata]], List[str], List[str]]

Creates the lists of open and half-open texts to be used later.

Returns:

dictionary of all texts {collection: [readableDescendants]}, list of open texts, list of half-open texts

get_prev_next_texts(objectId: str) Dict[str, str | list]

Get the previous and next texts in a collection

Parameters:

objectId – the ID of the current object

Returns:

the IDs of the previous and next text in the same collection and lists of all previous and next texts

static get_readable_siblings(obj: XmlCapitainsReadableMetadata) List[XmlCapitainsReadableMetadata]

Returns the readable children of every ancestor. This assumes that any direct readable descendants that an ancestor has will also be readable siblings to the collection.

Parameters:

obj – the collection for which to find siblings

Returns:

the list of siblings

get_transcriptions(obj: XmlCapitainsReadableMetadata) List[XmlCapitainsReadableMetadata]

Returns any manuscript transcriptions that are associated with this text

Parameters:

obj – the readable collection for which to find transcriptions

Returns:

the list of transcriptions

static highlight_found_sents(html: str, results: List[Dict[str, str | List[str]]]) str

Adds “searched” to the classList of words in “sents” from elasticsearch results

Parameters:
  • html – the marked-up text to be searched

  • results – the previous search session information from the session

Returns:

transformed html

make_closed_texts() dict

Ingests an existing JSON file that contains notes about specific manuscript transcriptions

make_coins(collection: XmlCapitainsCollectionMetadata | XmlCapitainsReadableMetadata, text: XmlCapitainsReadableMetadata, subreference: str = '', lang: str = None) str

Creates a CoINS Title string from information

Parameters:
  • collection – Collection to create coins from

  • text – Text/Passage object

  • subreference – Subreference

  • lang – Locale information

Returns:

Coins HTML title value

make_collected_colls() dict

Ingests an existing JSON file that contains notes about specific manuscript transcriptions

make_comp_places_list() list

Ingests an existing JSON file that maps dead urls to active ones, e.g., urn:cts:formulae:lorsch.gloeckner4233 ->urn:cts:formulae:lorsch.gloeckner1134

make_dead_url_mapping() dict

Ingests an existing JSON file that maps dead urls to active ones, e.g., urn:cts:formulae:lorsch.gloeckner4233 ->urn:cts:formulae:lorsch.gloeckner1134

make_inflected_to_lem_mapping() dict

Ingests an existing JSON file that maps inflected forms onto their lemmata

make_lem_to_lem_mapping() dict

Ingests an existing JSON file that maps theoretical lemmas onto the used lemmas, e.g., gero -> gerere

make_manuscript_notes() dict

Ingests an existing JSON file that contains notes about specific manuscript transcriptions

Ingests an existing JSON file that contains notes about specific manuscript transcriptions

make_parents(collection: XmlCapitainsCollectionMetadata | XmlCapitainsReadableMetadata, lang: str = None) List[Dict[str, str | int]]

Build parents list for given collection

Parameters:
  • collection – Collection to build dict view of for its members

  • lang – Language to express data in

Returns:

List of basic objects

ordered_corpora(m: XmlCapitainsReadableMetadata, collection: str) Tuple[str | Tuple[str, Tuple[str, str]], List[Sequence[str]] | list, XmlCapitainsReadableMetadata]

Sets up the readable descendants in each corpus to be correctly ordered. These strings are later used in displaying the buttons on templates/main/sub_collection.html

Parameters:
  • m – the metadata for the descendant

  • collection – the collection to which readable collection belongs

Returns:

a tuple that will be put in the correct place in the ordered list when sorted

static r_accessibility_statement() Dict[str, str]

Route for accessibility statement

Returns:

Template to use for accessibility statement page

Return type:

{str: str}

r_add_text_collection(objectId: str, objectIds: str, reffs: str, lang: str = None) Dict[str, Any]

Route to browse a top-level collection and add another text to the view

Parameters:
  • objectId – the id of the collection from which the new text for the reading view should be added

  • objectIds – the object ids from the previous view separated by ‘+’

  • reffs – the citation references from the objects in the previous view seperated by ‘+’

  • lang – Lang in which to express main data

Returns:

Template and collections contained in given collection

r_add_text_collections(objectIds: str, reffs: str, lang: str = None) Dict[str, Any]

Retrieve the top collections of the inventory

Parameters:
  • objectIds – the object ids from the previous view separated by ‘+’

  • reffs – the citation references from the objects in the previous view seperated by ‘+’

  • lang – Lang in which to express main data

Returns:

Collections information and template

r_add_text_corpus(objectId: str, objectIds: str, reffs: str, lang: str = None) Dict[str, Any]

Route to browse collections and add another text to the view

Parameters:
  • objectId – Collection identifier

  • objectIds – the ids of the documents in the previous view separated by ‘+’

  • reffs – the references for the documents in the previous view separated by ‘+’

  • lang – Lang in which to express main data

Returns:

Template and collections contained in given collection

r_assets(filetype, asset)

Route for specific assets.

Parameters:
  • filetype – Asset Type

  • asset – Filename of an asset

Returns:

Response

static r_bibliography() Dict[str, str]

Bibliography route function

Returns:

Template to use for Bibliography page

Return type:

{str: str}

r_charter_formulaic() Dict[str, str | List[Tuple[str]]]

Route for page with intro and links to data from Franziska Quaas

Returns:

all_parts template

Return type:

{str: str, str: list(tuple(str))}

r_collection(objectId: str, lang: str = None) Dict[str, Any]

Route to show a collection of different corpora, e.g., all formulae collections

Parameters:
  • objectId – The id of the collection to be shown

  • lang – Language in which to show the collection’s metadata

Returns:

Template and collections contained in a given collection

static r_contact() Dict[str, str]

Contact route function

Returns:

Template to use for Bibliography page

Return type:

{str: str}

r_corpus(objectId: str, lang: str = None) Dict[str, Any]

Route to browse collections and add another text to the view

Parameters:
  • objectId – Collection identifier

  • lang – Lang in which to express main data

Returns:

Template and collections contained in given collection

r_corpus_mv(objectId: str, lang: str = None) Dict[str, Any]

Route to browse collections and add another text to the view

Parameters:
  • objectId – Collection identifier

  • lang – Lang in which to express main data

Returns:

Template and collections contained in given collection

static r_feedback() Dict[str, str]

Feedback route function

Returns:

Template to use for Bibliography page

Return type:

{str: str}

r_formulae_charter() Dict[str, str | List[Tuple[str]]]

Route for page with data from Franziska Quaas showing formulae with charter agreements

Returns:

all_parts template

Return type:

{str: str, str: list(tuple(str))}

r_formulae_formulae() Dict[str, str | List[Tuple[str]]]

Route for page with data from Franziska Quaas showing formulae with formulae agreements

Returns:

all_parts template

Return type:

{str: str, str: list(tuple(str))}

r_groups() Dict[str, str | List[Tuple[str]]]

Route for page with data from Franziska Quaas showing charter and charter part groups

Returns:

all_parts template

Return type:

{str: str, str: list(tuple(str))}

static r_impressum() Dict[str, str]

Impressum route function

Returns:

Template to use for Impressum page

Return type:

{str: str}

r_lexicon(objectId: str, lang: str = None) Dict[str, Any]

Retrieve the eLexicon entry for a word

Parameters:
  • objectId (str) – Collection identifiers separated by ‘+’

  • lang (str) – Lang in which to express main data

Returns:

Template, collections metadata and Markup object representing the text

Return type:

{str: Any}

static r_man_desc(manuscript: str) Dict[str, str]

Route for manuscript descriptions

Returns:

Template to use for Bibliography page

Return type:

{str: str}

static r_man_siglen() Dict[str, str]

Route for manuscript descriptions

Returns:

Template to use for Bibliography page

Return type:

{str: str}

r_multipassage(objectIds: str, subreferences: str, lang: str = None, collate: bool = False) Dict[str, Any]

Retrieve the text of the passage

Parameters:
  • objectIds – Collection identifiers separated by ‘+’

  • lang – Lang in which to express main data

  • subreferences – Reference identifiers separated by ‘+’

Returns:

Template, collections metadata and Markup object representing the text

r_multipassage_authentication_check(objectIds: str, subreferences: str, lang: str = None, collate: bool = False) Dict[str, Any]

Wrapper method for r_multipassage. Requires all users to be logged in, when using ‘+’ in the query. It should eventually replace r_multipassage.

Parameters:
  • objectIds – Collection identifiers separated by ‘+’

  • lang – Lang in which to express main data

  • subreferences – Reference identifiers separated by ‘+’

Returns:

Template, collections metadata and Markup object representing the text

r_part_groups() Dict[str, str | List[Tuple[str]]]

Route for page with data from Franziska Quaas showing similar parts for Arengen and Überleitungsformel

Returns:

all_parts template

Return type:

{str: str, str: list(tuple(str))}

r_parts() Dict[str, str | List[Tuple[str]]]

Route for page with data from Franziska Quaas showing all charters with certain formulaic parts

Returns:

all_parts template

Return type:

{str: str, str: list(tuple(str))}

r_passage(objectId: str, subreference: str, lang: str = None) Dict[str, Any]

Retrieve the text of the passage

Parameters:
  • objectId – Collection identifier

  • lang – Lang in which to express main data

  • subreference – Reference identifier

Returns:

Template, collections metadata and Markup object representing the text

r_pdf(objectId: str) Response

Produces a PDF from the objectId for download and then delivers it.

If the objectId is not part of the open_texts a pdf only generated if project member tries to access it.

Parameters:

objectId – the URN of the text to transform

Returns:

static r_reading_format(direction: str) str | redirect

Sets the reading direction of the texts in the multipassage view

Parameters:

direction – a string representing whether the texts are listed in ‘rows’ or ‘columns’

static r_robots()

Route for the robots.txt

Parameters:
  • filetype – Asset Type

  • asset – Filename of an asset

Returns:

Response

static r_set_language(code: str) str | redirect

Sets the session’s language code which will be used for all requests

Parameters:

code – The 2-letter language code

r_videos() Dict[str, str | List[Tuple[str]]]

Route for videos

Returns:

Video template with video and subtitle filenames

Return type:

{str: str, str: list(tuple(str))}

static register_font()

Registers the LiberationSerif font to be used in producing PDFs

semantic(collection: XmlCapitainsCollectionMetadata | XmlCapitainsReadableMetadata, parent: XmlCapitainsCollectionMetadata = None) str

Generates a SEO friendly string for given collection

Parameters:
  • collection – Collection object to generate string for

  • parent – Current collection parent

Returns:

SEO/URL Friendly string

sort_folia(matchobj: Match) str

Sets up the folia ranges of manuscripts for better sorting.

This method parses folio identifiers with possible HTML formatting and generates a consistent representation suitable for sorting manuscript items. It maps certain folio number ranges to letter prefixes specific to manuscript collections (e.g., ‘m4’, ‘p3’).

Example inputs and outputs: - ‘28r’ → ‘0028<span class=”verso-recto”>r</span>’ - ‘101bisv’ → ‘0101 bis<span class=”verso-recto”>v</span>’ - ‘m4.45r-46v’ → ‘a0045<span class=”verso-recto”>r</span>-0046<span class=”verso-recto”>v</span>’

sort_katalonien(t: tuple)

Correctly sort the Katalonien documents with mixed number and Roman numerals

static sort_parents(d: Dict[str, str | int]) int

Sort parents from closest to furthest

Parameters:

d – The dictionary to be sorted

Returns:

integer representing how deep in the collection a collection stands from lowest (i.e., text) to highest

static sort_transcriptions(obj: XmlCapitainsReadableMetadata | XmlCapitainsCollectionMetadata) Tuple[str, int]

Return sortable tuple for the transcriptions of an object

view_maker(name: str, instance=None) Callable

Create a view

Parameters:
  • name – Name of the route function to use for the view.

  • instance – The Flask instance for which to create the view function

Returns:

Route function which makes use of Nemo context (such as menu informations)