Commit 04d88dba authored by MRodz's avatar MRodz Committed by mrodzis
Browse files

Add first draft for eliminating double tei:handshift entries

parent b1a132e1
......@@ -370,16 +370,32 @@ declare
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" script=""Latn clean""/>")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Archivar_1"" script=""Latn clean""/>")
%test:assertEmpty
function teisimple-test:analyze-handshift($node as element(*)) {
fontane-simple:transform($node)
};
declare
%test:name("Omitting handshifts")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#fremde_Hand1"" medium=""black_ink thin_pen"" script=""Latn clean""/><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:0.8cm"">C</line><handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf standard""/><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:0.8cm"">7</line></zone>")
%test:assertEmpty
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""black_ink thin_pen"" script=""Latn clean""/><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:0.8cm"">C</line><handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf standard""/><line xmlns=""http://www.tei-c.org/ns/1.0"" style=""margin-left:0.8cm"">7</line></zone>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""black_ink thin_pen"" script=""Latn clean""/>", "C", "<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil"" script=""Latf standard""/>", "7")
%test:args("<zone xmlns=""http://www.tei-c.org/ns/1.0""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Fontane<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new =""#fremde_Hand1"" medium=""pencil"" script=""Latf standard""/>Fremd<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>Fontane<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""pencil""/></zone> ")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>", "Fontane", "Fontane", "<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""pencil""/>")
function teisimple-test:analyze-handshift-omissions($node as element(*)) {
fontane-simple:transform($node)
};
(: FONTS :)
declare
%test:name("Fonts")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latn""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latn""/>")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""initials""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latn""/></seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""initials""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/><handShift xmlns=""http://www.tei-c.org/ns/1.0"" script=""Latn""/></seg>")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""initials""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>LVNGiS</seg>")
%test:assertEquals("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""initials""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>LVNGiS</seg>")
%test:args("<seg xmlns=""http://www.tei-c.org/ns/1.0"" type=""monogram""><handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane""/>LC</seg>")
......@@ -391,10 +407,10 @@ declare
(: WRITING MEDIUM :)
declare
%test:name("Writing medium")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""black_ink thin_pen""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""black_ink thin_pen""/>")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" medium=""pencil""/>")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""black_ink thin_pen""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""black_ink thin_pen""/>")
%test:args("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""pencil""/>")
%test:assertEquals("<handShift xmlns=""http://www.tei-c.org/ns/1.0"" new=""#Fontane"" medium=""pencil""/>")
function teisimple-test:analyze-medium($node as element(*)) {
fontane-simple:transform($node)
};
......
......@@ -152,25 +152,20 @@ declare function fontane-simple:transform($nodes as node()*) as node()* {
fontane-simple:transform($node/node())
case element(tei:handShift) return
(: tei:local:copy-element($node)ft without @new denote the duct of the current
writer or a change of writing medium :)
if($node/@new and (fontane-simple:is-hand-contemporary($node/@new) or
($node/@new = "#Friedrich_Fontane"
and $node/ancestor::tei:surface[@type = "label"]))
or not($node/@new))
then
if($node/@new) then
if(fontane-simple:is-hand-valid($node)
and not(fontane-simple:is-prev-valid-hand-same($node))) then
local:copy-element($node)
else
()
(: if($node/following-sibling::*[1][count(./*) = 1 :)
(: and child::tei:fw or child::tei:stamp]):)
(: then:)
(: ():)
(: else:)
(: element tei:local:copy-element($node)ft {:)
(: $node/@*:)
(: }:)
else
(: tei:local:copy-element($node)ft without @new denote the duct
of the current writer or a change of writing medium :)
if(fontane-simple:is-hand-valid($node/preceding::tei:handShift[@new][1])) then
local:copy-element($node)
else
()
case element(tei:stamp) return
()
......@@ -681,4 +676,28 @@ declare function fontane-simple:filter-rendition($seg-styles as xs:string) as xs
else
()
return string-join($relevant-styles, " ")
};
declare function fontane-simple:is-hand-valid($node as element(tei:handShift))
as xs:boolean {
if(fontane-simple:is-hand-contemporary($node/@new)
or ($node/ancestor::tei:surface[@type = "label"]
and matches($node/@new, "Friedrich_Fontane"))
) then
true()
else
false()
};
declare function fontane-simple:is-prev-valid-hand-same($node as element(tei:handShift))
as xs:boolean {
let $prev-valid := $node/preceding::tei:handShift[fontane-simple:is-hand-valid(.)][1]
return
if($prev-valid
and functx:sequence-deep-equal($node/@*, $prev-valid/@*)) then
true()
else
false()
};
\ No newline at end of file
This diff is collapsed.
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