Page MenuHomec4science

foreign_text.ts
No OneTemporary

File Metadata

Created
Tue, Sep 10, 10:30

foreign_text.ts

import { FusekiResults, BasicResultBindingElement } from './basic_datatype';
import { TlnPositionalObject } from './positional_object';
import { TextByForeignHand } from '../models';
import { TlnPositionalStyleMarkup } from './positional-markup';
/**
* This is the 'text by foreign hand' instantiation of an element of {@link /interfaces/FusekiResults.html|FusekiResults}.
* It extends {@link /classes/BasicResultBindingElement.html|BasicResultBindingElement}.
**/
export class TlnTextByForeignHand extends TlnPositionalObject implements TextByForeignHand {
/**
* the SPARQL-query of this datatype.
**/
static readonly query: string = `
PREFIX tln: <http://www.nie.org/ontology/nietzsche#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?id ?text ?pen ?left ?top ?width ?height ?resolution ?transform ?markup ?sStyle ?start ?end WHERE {
?page tln:hasMarkForeignHands/rdf:rest*/rdf:first ?id.
?id tln:textOfForeignHands ?textOfForeignHands;
tln:penOfForeignHands ?pen;
tln:hasTranskriptionPosition ?tp.
?textOfForeignHands tln:textHasContent ?text.
?tp tln:hasLeft ?left; tln:hasTop ?top; tln:hasWidth ?width; tln:hasHeight ?height.
OPTIONAl { ?id tln:resolutionOfAbbreviation ?resolution.}
OPTIONAl { ?textOfForeignHands tln:textHasMarkup ?markup.
?markup tln:standoffTagHasEndIndex ?end;
tln:standoffTagHasStartIndex ?start;
tln:standoffTagHasCSS ?sStyle.
}
OPTIONAl { ?tp tln:hasTransform ?transform.}
} `;
/**
* the text of this word
**/
text: string;
/**
* the text of this word as it has been edited by the editors.
**/
pen: string;
/**
* resolution of the abbrevation
**/
resolution?: string;
markups: TlnPositionalStyleMarkup[] = [];
/**
* The constructor creates a datatype from the data.
*
* @param id if omitted the id will be retrieved from data
**/
constructor(data: any, id?: string, service?: any){
super(data, id, service)
this.text = this.getData4Key('text');
this.pen = this.getData4Key('pen');
this.resolution = this.getData4Key('resolution');
}
public static convertData<T extends typeof BasicResultBindingElement>(this: T, data: FusekiResults, id?: string, service?: any): Array<InstanceType<T>> {
let elements = [];
let content = this.getContent(data);
for (var i = 0; i < content.length; i++){
let element = new TlnTextByForeignHand(content[i], id, service);
if (content[i]['markup'] != undefined && content[i]['markup']['value'] != null){
element.markups = TlnPositionalStyleMarkup.convertData({ head: { vars: []}, results: { bindings: <any>[ content[i] ] } }, content[i]['markup']['value'])
}
if (elements.length > 0 && elements[elements.length-1].id == element.id){
element.markups.forEach(markup =>{elements[elements.length-1].markups.push(markup)});
} else {
elements.push(element)
}
}
//console.log(elements)
return elements;
}
}
/**
* This is the faksimile text by foreign hand instantiation of an element of {@link /interfaces/FusekiResults.html|FusekiResults}.
* It extends {@link /classes/BasicResultBindingElement.html|BasicResultBindingElement}.
**/
export class FaksimileTextByForeignHand extends TlnTextByForeignHand {
/**
* the SPARQL-query of this datatype.
**/
static readonly query: string = `
PREFIX tln: <http://www.nie.org/ontology/nietzsche#>
PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#>
SELECT ?id ?text ?pen ?left ?top ?width ?height ?resolution ?transform ?markup ?sStyle ?start ?end WHERE {
?page tln:hasMarkForeignHands/rdf:rest*/rdf:first ?id.
?id tln:textOfForeignHands ?textOfForeignHands;
tln:penOfForeignHands ?pen;
tln:hasFaksimilePosition ?fp.
?textOfForeignHands tln:textHasContent ?text.
?fp tln:hasLeft ?left; tln:hasTop ?top; tln:hasWidth ?width; tln:hasHeight ?height.
OPTIONAl { ?id tln:resolutionOfAbbreviation ?resolution.}
OPTIONAl { ?textOfForeignHands tln:textHasMarkup ?markup.
?markup tln:standoffTagHasEndIndex ?end;
tln:standoffTagHasStartIndex ?start;
tln:standoffTagHasCSS ?sStyle.
}
OPTIONAl { ?fp tln:hasTransform ?transform.}
} `;
}

Event Timeline