@prefix e: . @prefix homotypic: . @prefix list: . @prefix math: . @prefix stoff: . @prefix string: . # CASE 1: ?unity has no homotypic parts and is not such a part => create standoff for entire ?unity (startIndex: 0, endIndex: length of unity). { ?unity a homotypic:HomotypicEntity; ?p ?o; homotypic:hasText ?string. ?SCOPE e:findall (?unity {?unity homotypic:hasHomotypicParts ?parts} ?partList). # ?unity has no homotypic parts. ?partList e:length ?numParts. ?numParts math:equalTo 0 . ?SCOPE e:findall (?unity {?greater_unity homotypic:hasHomotypicParts ?list. ?unity list:in ?list} ()). # ?unity is not a homotypic part. ?o stoff:styleHasCSS ?css. # ?unity has an object that has ?css. ## get ?endIndex for ?string (?string ?string) e:stringSplit ?listOfChars. # create a list of all chars of ?string ?listOfChars e:length ?endIndex. # calculate length of this list as ?endIndex } => { ?markup a stoff:StandoffMarkup; stoff:hasCSS ?css; stoff:standoffMarkupHasStartIndex 0; stoff:standoffMarkupHasEndIndex ?endIndex. ?unity homotypic:hasMarkup ?markup. }. # CASE 2: ?unity has homotypic parts => create standoff by calculating startIndex and endIndex from ?part. { ?unity a homotypic:HomotypicEntity; homotypic:hasHomotypicParts ?listOfParts . ?part list:in ?listOfParts; ?p ?o. ?o stoff:styleHasCSS ?css. (?before (?part) ?after) list:append ?listOfParts. # get list of entities before and list of entities after ?part in ?listOfParts. ## get ?startIndex ?SCOPE e:findall (?text { ?before_part list:in ?before; homotypic:hasText ?text .} ?before_text ). # create list of text before ?part ?before_text string:concatenation ?before_text_concated. # concate texts (?before_text_concated ?before_text_concated) e:stringSplit ?listOfCharsA. # split into list of chars ?listOfCharsA e:length ?startsRaw. # calculate length of this list ->number of chars of before ?part ("_startsRaw-1" ?startsRaw) e:calculate ?startIndex. # number of chars -1 -> ?startIndex of ?part ## get ?endIndex (?before (?part)) list:append ?before_with_part_list. # create list that contains both ?before and ?part. ?SCOPE e:findall (?text { ?item list:in ?before_with_part_list; homotypic:hasText ?text .} ?part_included_text ). # create list of text. ?part_included_text string:concatenation ?part_included_concated. # concat texts. (?part_included_concated ?part_included_concated) e:stringSplit ?listOfCharsB. # split into list of chars ?listOfCharsB e:length ?endValue. # calculate length of this list ('_endValue-1' ?endValue) e:calculate ?endIndex. } => { ?markup a stoff:StandoffMarkup; stoff:hasCSS ?css; stoff:standoffMarkupHasStartIndex ?startIndex; stoff:standoffMarkupHasEndIndex ?endIndex. ?unity homotypic:hasMarkup ?markup. }.