Commit c8a19ee5 authored by Michelle Rodzis's avatar Michelle Rodzis Committed by mrodzis
Browse files

Finalize 3.2. textual interventions

parent 5ed7d397
......@@ -28,7 +28,10 @@ import module namespace simpleHelpers="http://fontane-nb.dariah.eu/teisimplehelp
declare function fontaneSimple:main($file as xs:string) as node()? {
let $doc :=
try {
(doc("/db/sade-projects/textgrid/data/xml/data/" || $file))
(: TODO:An error with the index occured while building so we
temporarily put the file somewhere else :)
(: (doc("/db/sade-projects/textgrid/data/xml/data/" || $file)):)
(doc("/db/apps/SADE/resources/xml/" || $file))
} catch * {
(console:log("It was not possible to open the requested file " || $file))
}
......@@ -80,6 +83,8 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:lb) return
if($node[@break = "keepHyphen"]) then
()
else if($node[@break = "no"]) then
fontaneSimple:mark-intervention($node)
else
fontaneSimple:copy-element($node)
......@@ -122,7 +127,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else if($node[matches(@copyOf, $node/preceding::tei:seg/@xml:id)
and not(@cause = "unclear")]) then
fontaneSimple:mark-syllable-duplication($node)
fontaneSimple:mark-intervention($node)
else if($node/@cause ="catchword" or $node/@cause ="unclear") then
()
......@@ -161,16 +166,38 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
or matches($node/@rendition, "black_letter")
or matches($node/@rendition, "roman")) then
fontaneSimple:make-seg-with-rendition($node)
else if($node/following::*[1][self::tei:lb[@break = "no"]]) then
simpleHelpers:trim-last-char($node)
else if ($node/preceding::*[1][self::tei:lb[@break = "no"]]) then
simpleHelpers:trim-first-char($node)
else if($node/@type = "verse") then
(if(not($node/preceding-sibling::tei:line[@type = "verse"])) then
fontaneSimple:mark-linegroup-beginning()
else
(),
element tei:l {
fontaneSimple:transform($node/node())
},
if(not($node/following-sibling::tei:line[@type = "verse"])) then
fontaneSimple:mark-linegroup-end()
else
())
else if(not($node/@type = "item")) then
fontaneSimple:transform($node/node())
else if($node/@type = "item" and not($node/@xml:id)) then
element tei:item {
fontaneSimple:transform($node/node())
}
else if($node/@type = "item"
and simpleHelpers:is-transposed($node)) then
()
else
fontaneSimple:transform($node/node())
......@@ -211,6 +238,9 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
or $node/@function ="unknown")
then
()
else if($node/parent::tei:add and $node/@copyOf) then
fontaneSimple:mark-intervention($node)
else
fontaneSimple:transform($node/node())
......@@ -224,7 +254,7 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:mod) return
if($node/@type = "highlighted"
and simpleHelpers:is-hand-contemporary($node/@hand)) then
fontaneSimple:copy-element($node)
$node
else
fontaneSimple:transform($node/node())
......@@ -285,9 +315,8 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
else
()
(: TODO: check if correct :)
case element(tei:surplus) return
()
fontaneSimple:mark-intervention($node)
case element(tei:zone) return
if(matches($node/@style, "border-style:solid")
......@@ -467,6 +496,12 @@ declare function fontaneSimple:transform($nodes as node()*) as node()* {
case element(tei:expan) return
fontaneSimple:copy-element($node)
case element(tei:sic) return
fontaneSimple:copy-element($node)
case element(tei:corr) return
fontaneSimple:copy-element($node)
case element(tei:rs) return
fontaneSimple:copy-element($node)
......@@ -622,12 +657,49 @@ as element(tei:handShift) {
};
declare function fontaneSimple:mark-syllable-duplication($node as element(tei:add))
declare function fontaneSimple:mark-intervention($node as element(*))
as element(tei:seg) {
element tei:seg {
attribute type {"reduplication"},
<hi>‹</hi>,
fontaneSimple:transform($node/node()),
<hi>›</hi>
if($node[self::tei:lb]) then
attribute type {"missing-hyphen"}
else if($node[self::tei:surplus]) then
attribute type {"surplus"}
else
attribute type {"reduplication"},
<tei:hi xmlns="http://www.tei-c.org/ns/1.0">‹</tei:hi>,
if($node[self::tei:lb]) then
simpleHelpers:find-chars($node)
else
fontaneSimple:transform($node/node()),
<tei:hi xmlns="http://www.tei-c.org/ns/1.0">›</tei:hi>
}
};
declare function fontaneSimple:mark-missing-hyphen($node as element(tei:lb)) as
element(tei:seg) {
element tei:seg {
attribute type {"missing-hyphen"},
<tei:hi xmlns="http://www.tei-c.org/ns/1.0">‹</tei:hi>,
simpleHelpers:find-chars($node),
<tei:hi xmlns="http://www.tei-c.org/ns/1.0">›</tei:hi>
}
};
(:~ In this first serialization step the beginning and end of line groups are
: simply marked with milestones, which are expanded to a full tei:lg in the
: second serialization step. :)
declare function fontaneSimple:mark-linegroup-beginning() as
element(tei:milestone) {
element tei:milestone {
attribute unit {"start-lg"}
}
};
declare function fontaneSimple:mark-linegroup-end() as
element(tei:milestone) {
element tei:milestone {
attribute unit {"end-lg"}
}
};
\ No newline at end of file
......@@ -28,7 +28,10 @@ import module namespace functx = "http://www.functx.com";
declare function simpleHelpers:is-hand-contemporary($hand as xs:string?)
as xs:boolean {
let $hand := replace($hand, "#", "")
let $file := doc("/db/sade-projects/textgrid/data/xml/data/16b00.xml")
(: TODO:An error with the index occured while building so we
temporarily put the file somewhere else :)
(: let $file := doc("/db/sade-projects/textgrid/data/xml/data/16b00.xml"):)
let $file := doc("/db/apps/SADE/resources/xml/16b00.xml")
let $handNote := $file//tei:handNote[@xml:id = $hand]
return
if($handNote/@script = "contemporary")
......@@ -342,4 +345,33 @@ as element(tei:section) {
let $bla := console:log(util:get-fragment-between($node, $corresp, true(), true()))
return
<div/>
};:)
\ No newline at end of file
};:)
declare function simpleHelpers:find-chars($node as element(tei:lb)) as text() {
let $prev-line := $node/preceding::tei:line[1]
let $prev-last-text := $prev-line/text()[last()]
let $prev-length := string-length($prev-last-text)
let $prev-char := substring($prev-last-text, $prev-length,$prev-length)
let $next-line := $node/following::tei:line[1]
let $next-first-text := $next-line/text()[1]
let $next-char := substring($next-first-text, 1, 1)
return text{$prev-char || $next-char}
};
declare function simpleHelpers:trim-last-char($node as element(tei:line))
as text() {
let $blae := console:log($node)
let $length := string-length($node/string())
let $trim-last-char := substring($node/string(), 1, $length - 1)
return text{$trim-last-char}
};
declare function simpleHelpers:trim-first-char($node as element(tei:line))
as text() {
let $blae := console:log($node)
let $length := string-length($node/string())
let $trim-first-char := substring($node/string(), 2, $length)
return text{$trim-first-char}
};
\ No newline at end of file
......@@ -44,12 +44,27 @@ declare
declare
%test:name("Intervening in texts")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><surface xmlns=""http://www.tei-c.org/ns/1.0"" n=""10v""><zone xmlns=""http://www.tei-c.org/ns/1.0""><line xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C03_10v_1"">mar</seg>-</line></zone><zone><line><add copyOf=""#C03_10v_1"" cause=""catchword"">mar</add>mor</line></zone></surface></zone>")
%test:assertEquals("<pb xmlns=""http://www.tei-c.org/ns/1.0"" n=""10v""/>", "mar", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""reduplication""><hi xmlns=""http://www.tei-c.org/ns/1.0"" >‹</hi>mar<hi xmlns=""http://www.tei-c.org/ns/1.0"" >›</hi></seg>", "mor")
%test:assertEquals("<pb xmlns=""http://www.tei-c.org/ns/1.0"" n=""10v""/>", "mar", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""reduplication""><hi xmlns=""http://www.tei-c.org/ns/1.0"" >‹</hi>mar<hi xmlns=""http://www.tei-c.org/ns/1.0"" >›</hi></seg>", "mor")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><line xmlns=""http://www.tei-c.org/ns/1.0"">ei<mod xmlns=""http://www.tei-c.org/ns/1.0"" type=""subst""><del xmlns=""http://www.tei-c.org/ns/1.0"" rend=""overwritten"">l</del><add xmlns=""http://www.tei-c.org/ns/1.0"" place=""superimposed"">n</add></mod>la<seg xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""C02_32r_1"">den</seg>-</line><line xmlns=""http://www.tei-c.org/ns/1.0""><add xmlns=""http://www.tei-c.org/ns/1.0"" copyOf=""#C02_32r_1"">den</add>den</line></zone>")
%test:assertEquals("ei", "n", "la", "den", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""reduplication""><hi xmlns=""http://www.tei-c.org/ns/1.0"" >‹</hi>den<hi xmlns=""http://www.tei-c.org/ns/1.0"" >›</hi></seg>", "den")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""D08_7v_1"">und</seg><add xmlns=""http://www.tei-c.org/ns/1.0"" place=""above"" copyOf=""#D08_7v_1"" cause=""unclear"">und</add></line>")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" xml:id=""D08_7v_1"">und</seg><add xmlns=""http://www.tei-c.org/ns/1.0"" place=""above"" copyOf=""#D08_7v_1"" cause=""unclear"">und</add></line>")
%test:assertEquals("und")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0""><add place=""above"" style=""margin-left:-0.4cm"" xmlns=""http://www.tei-c.org/ns/1.0"" rend=""caret:bow(1.5cm,pos-right)"">ringt <seg xmlns=""http://www.tei-c.org/ns/1.0"" copyOf=""#B05_5r_z"">und</seg></add></line>")
%test:assertEquals("ringt ", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""reduplication""><hi xmlns=""http://www.tei-c.org/ns/1.0"" >‹</hi>und<hi xmlns=""http://www.tei-c.org/ns/1.0"" >›</hi></seg>")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0""><add xmlns=""http://www.tei-c.org/ns/1.0"">oder Ende des 17<seg xmlns=""http://www.tei-c.org/ns/1.0"" copyOf=""#D08_30r_a"">.</seg></add></line>")
%test:assertEquals("oder Ende des 17", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""reduplication""><hi xmlns=""http://www.tei-c.org/ns/1.0"" >‹</hi>.<hi xmlns=""http://www.tei-c.org/ns/1.0"" >›</hi></seg>")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><line xmlns=""http://www.tei-c.org/ns/1.0"">Von allen Sei</line><lb xmlns=""http://www.tei-c.org/ns/1.0"" break=""no""/><line xmlns=""http://www.tei-c.org/ns/1.0"">ten rückten</line></zone>")
%test:assertEquals("Von allen Se", "<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""missing-hyphen""><hi xmlns=""http://www.tei-c.org/ns/1.0"" >‹</hi>it<hi xmlns=""http://www.tei-c.org/ns/1.0"" >›</hi></seg>","en rückten")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0""><choice xmlns=""http://www.tei-c.org/ns/1.0""><sic xmlns=""http://www.tei-c.org/ns/1.0""/><corr xmlns=""http://www.tei-c.org/ns/1.0"">.</corr></choice></line>")
%test:assertEquals("<choice xmlns=""http://www.tei-c.org/ns/1.0""><sic xmlns=""http://www.tei-c.org/ns/1.0""/><corr xmlns=""http://www.tei-c.org/ns/1.0"">.</corr></choice>")
%test:args("<line xmlns=""http://www.tei-c.org/ns/1.0"" type=""verse""><surplus xmlns=""http://www.tei-c.org/ns/1.0"">„</surplus>Für die vielen Anſtrengungen</line>")
%test:assertEquals("<milestone unit=""start-lg"" xmlns=""http://www.tei-c.org/ns/1.0""/>", "<l xmlns=""http://www.tei-c.org/ns/1.0""><seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""surplus""><hi xmlns=""http://www.tei-c.org/ns/1.0"" >‹</hi>„<hi xmlns=""http://www.tei-c.org/ns/1.0"" >›</hi></seg>Für die vielen Anstrengungen</l>", "<milestone unit=""end-lg"" xmlns=""http://www.tei-c.org/ns/1.0""/>")
function teisimple-test:analyze-interventions($node as element(*)) {
fontaneSimple:transform($node)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment