@prefix e: . @prefix list: . @prefix kb: . @prefix tln: . # update reference to next page if there is no line info { ?manuscript a tln:ArchivalManuscriptUnity; tln:hasPages ?pages. ?page list:in ?pages; tln:hasLines ?lines. ?line list:in ?lines; tln:lineHasEditorComment ?lineContinuationFrom. ?lineContinuationFrom a tln:LineContinuation; tln:isUncertain false ; tln:isLineAContinuationTo true ; tln:lineContinuationHasReference ?reference. ?reference a tln:Reference. ?SCOPE e:fail {?reference tln:firstLineOfReference ?no_firstLine}. # there is no line info ?SCOPE e:fail {?reference tln:wordReference ?no_reference} . # there is no word reference (?previous_pages (?page ?next_page) ?other_pages) list:append ?pages. } => { ?reference tln:refersToPage ?next_page. _:d kb:retract (?s ?p ?o). }. # update reference to previous page if there is no line info { ?manuscript a tln:ArchivalManuscriptUnity; tln:hasPages ?pages. ?page list:in ?pages; tln:hasLines ?lines. ?line list:in ?lines; tln:lineHasEditorComment ?lineContinuationFrom. ?lineContinuationFrom a tln:LineContinuation; tln:isUncertain false ; tln:isLineAContinuationTo false ; tln:lineContinuationHasReference ?reference. ?reference a tln:Reference. ?SCOPE e:fail {?reference tln:firstLineOfReference ?no_firstLine}. # there is no line info ?SCOPE e:fail {?reference tln:wordReference ?no_reference} . # there is no word reference (?previous_pages (?previous_page ?page) ?other_pages) list:append ?pages. } => { ?reference tln:refersToPage ?previous_page. _:d kb:retract (?s ?p ?o). }.