Skip to content

Commit

Permalink
Fixes related to l10n and errros in data.
Browse files Browse the repository at this point in the history
  • Loading branch information
TomazErjavec committed Sep 12, 2023
1 parent 93d5084 commit a67ece7
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 27 deletions.
4 changes: 2 additions & 2 deletions Scripts/parlamint-lib.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -193,8 +193,8 @@
<xsl:variable name="bods">
<xsl:for-each select="distinct-values(tokenize(normalize-space($references), ' '))">
<xsl:if test="key('idr', ., $rootHeader)[ancestor::tei:category[@xml:id = 'parla.organization']]">
<xsl:variable name="body-en" select="et:l10n('en', key('idr', ., $rootHeader)//tei:catDesc)/tei:term"/>
<xsl:variable name="body" select="et:l10n($corpus-language, key('idr', ., $rootHeader)//tei:catDesc)/tei:term"/>
<xsl:variable name="body-en" select="et:l10n('en', key('idr', ., $rootHeader)//tei:catDesc)/tei:term"/>
<xsl:variable name="body" select="et:l10n($corpus-language, key('idr', ., $rootHeader)//tei:catDesc)/tei:term"/>
<!-- We unfortunatelly need an explicit test if the reference we got is appropriate -->
<!-- This needs to be rethought! (e.g. 'National Parliament' might be better than 'Unicameralism' -->
<xsl:if test="$body-en = 'Unicameralism' or
Expand Down
49 changes: 25 additions & 24 deletions Scripts/parlamint2meta.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -24,17 +24,15 @@
<xsl:choose>
<xsl:when test="normalize-space($subtitles[2])">
<xsl:variable name="joined-subtitles">
<xsl:for-each select="$subtitles/self::tei:*">
<xsl:value-of select="concat(., ' + ')"/>
</xsl:for-each>
<xsl:variable name="j-s">
<xsl:for-each select="$subtitles/self::tei:*">
<xsl:value-of select="concat(., $body-separator)"/>
</xsl:for-each>
</xsl:variable>
<xsl:value-of select="replace($j-s, concat('\', $body-separator, '$'), '')"/>
</xsl:variable>
<xsl:message>
<xsl:text>INFO: Joining subtitles: </xsl:text>
<xsl:value-of select="replace($joined-subtitles, ' \+ $', '')"/>
<xsl:text> in </xsl:text>
<xsl:value-of select="/tei:*/@xml:id"/>
</xsl:message>
<xsl:value-of select="replace($joined-subtitles, ' \+ $', '')"/>
<xsl:message select="concat('INFO: Joining subtitles: ', $joined-subtitles, ' in ', /tei:*/@xml:id)"/>
<xsl:value-of select="$joined-subtitles"/>
</xsl:when>
<xsl:when test="normalize-space($subtitles)">
<xsl:value-of select="$subtitles"/>
Expand Down Expand Up @@ -84,8 +82,21 @@
<xsl:value-of select="concat($subcorpus, '&#9;')"/>
<!-- Speaker metadata -->
<xsl:value-of select="concat(et:u-role(@ana), '&#9;')"/>
<xsl:variable name="speaker" select="key('idr', @who, $rootHeader)"/>
<xsl:choose>
<xsl:when test="not(@who)">
<xsl:text>-&#9;</xsl:text>
<xsl:text>-&#9;</xsl:text>
<xsl:text>-&#9;</xsl:text>
<xsl:text>-&#9;</xsl:text>
<xsl:text>-&#9;</xsl:text>
<xsl:text>-&#9;</xsl:text>
<xsl:text>-&#9;</xsl:text>
<xsl:text>-</xsl:text>
</xsl:when>
<xsl:when test="not(normalize-space($speaker))">
<xsl:message select="concat('ERROR: Cant find speaker for ', @who, ' in ', @xml:id)"/>
<xsl:text>-&#9;</xsl:text>
<xsl:text>-&#9;</xsl:text>
<xsl:text>-&#9;</xsl:text>
<xsl:text>-&#9;</xsl:text>
Expand All @@ -95,32 +106,22 @@
<xsl:text>-</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:variable name="speaker" select="key('idr', @who, $rootHeader)"/>
<xsl:if test="not(normalize-space($speaker))">
<xsl:message terminate="yes">
<xsl:text>FATAL ERROR: Can't find speaker for </xsl:text>
<xsl:value-of select="@who"/>
<xsl:text> in </xsl:text>
<xsl:value-of select="@xml:id"/>
</xsl:message>
</xsl:if>
<xsl:value-of select="concat(et:speaker-mp($speaker), '&#9;')"/>
<xsl:value-of select="concat(et:speaker-minister($speaker), '&#9;')"/>
<xsl:value-of select="concat(et:speaker-party($speaker, 'abb'), '&#9;')"/>
<xsl:value-of select="concat(et:speaker-party($speaker, 'yes'), '&#9;')"/>
<xsl:value-of select="concat(et:party-status($speaker), '&#9;')"/>
<xsl:value-of select="concat(et:format-name-chrono($speaker//tei:persName, $at-date),
'&#9;')"/>
<xsl:value-of select="concat(et:format-name-chrono($speaker//tei:persName, $at-date), '&#9;')"/>
<xsl:choose>
<xsl:when test="$speaker/tei:sex">
<xsl:value-of select="$speaker/tei:sex/@value"/>
<xsl:value-of select="$speaker/tei:sex/@value"/>
</xsl:when>
<xsl:otherwise>-</xsl:otherwise>
</xsl:choose>
<xsl:text>&#9;</xsl:text>
<xsl:choose>
<xsl:when test="$speaker/tei:birth">
<xsl:value-of select="replace($speaker/tei:birth/@when, '-.+', '')"/>
<xsl:value-of select="replace($speaker/tei:birth/@when, '-.+', '')"/>
</xsl:when>
<xsl:otherwise>-</xsl:otherwise>
</xsl:choose>
Expand All @@ -130,5 +131,5 @@
<!--xsl:value-of select="count(.//tei:w) + count(.//tei:pc)"/-->
<xsl:text>&#10;</xsl:text>
</xsl:template>

</xsl:stylesheet>
7 changes: 6 additions & 1 deletion Scripts/parlamint2xmlvert.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@
date="{$at-date}" title="{$title}">
<xsl:attribute name="speaker_role" select="et:u-role(@ana)"/>
<xsl:choose>
<xsl:when test="@who">
<xsl:when test="key('idr', @who, $rootHeader)/@xml:id">
<xsl:variable name="speaker" select="key('idr', @who, $rootHeader)"/>
<xsl:attribute name="speaker_id" select="$speaker/@xml:id"/>
<xsl:attribute name="speaker_name" select="et:format-name-chrono(
Expand All @@ -125,6 +125,11 @@
<xsl:attribute name="speaker_gender" select="$speaker/tei:sex/@value"/>
<xsl:attribute name="speaker_birth" select="replace($speaker/tei:birth/@when, '-.+', '')"/>
</xsl:when>
<!-- A speaker that does not have a corresponding <person> element -->
<xsl:when test="normalize-space(@who)">
<xsl:message select="concat('ERROR: cannot find person ', @who, ' for ', $text_id)"/>
</xsl:when>
<!-- No @who, legit if speaker is unknown -->
<xsl:otherwise>
<xsl:attribute name="speaker_id"/>
<xsl:attribute name="speaker_name"/>
Expand Down

0 comments on commit a67ece7

Please sign in to comment.