Skip to content

Commit

Permalink
[folia2html] added sentiments and statements
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Apr 11, 2019
1 parent df6bfe6 commit 423444e
Show file tree
Hide file tree
Showing 2 changed files with 67 additions and 5 deletions.
2 changes: 1 addition & 1 deletion foliatools/folia2html.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ def main():
usage = """folia2html
by Maarten van Gompel (proycon)
Centre for Language and Speech Technology, Radboud University Nijmegen
2016 - Licensed under GPLv3
2016-2019 - Licensed under GPLv3
This conversion script converts one or more FoLiA documents to a semi-interactive HTML document for
Expand Down
70 changes: 66 additions & 4 deletions foliatools/folia2html.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -518,10 +518,9 @@
<span class="part"><xsl:apply-templates /></span>
</xsl:template>

<xsl:variable name="ignore_list" select="' original suggestion alternative altlayers foreign-data '" /> <!-- The leading/trailing space is deliberate! -->

<xsl:variable name="ancestors_ok">not(ancestor::folia:original) and not(ancestor::folia:suggestion) and not(ancestor::folia:alt) and not(ancestor::folia:altlayers)</xsl:variable><!-- Checks if all ancestors are authoritative -->
<xsl:variable name="ancestors_nosubtoken">not(ancestor::folia:morpheme) and not(ancestor::folia:phoneme)</xsl:variable><!-- Checks if all ancestors are authoritative -->
<xsl:variable name="textclass_current">(not(@class) or (@class='current'))</xsl:variable>

<xsl:template match="folia:w">
<xsl:variable name="wid" select="@xml:id" />
Expand All @@ -543,7 +542,7 @@
<!-- Test presence of text in deeper structure elements, if they exist we don't
render this text but rely on the text in the deeper structure -->
<!-- Next, check if text element is authoritative (ancestors_ok) and have the proper class -->
<xsl:if test="not(following-sibling::*//folia:t[(not(./@class) or ./@class='current') and $ancestors_ok and $ancestors_nosubtoken and not(ancestor::folia:str)])"><xsl:if test="(not(./@class) or ./@class='current') and $ancestors_ok and $ancestors_nosubtoken and not(ancestor::folia:str)"><xsl:apply-templates /></xsl:if></xsl:if>
<xsl:if test="not(following-sibling::*//folia:t[$textclass_current and $ancestors_ok and $ancestors_nosubtoken and not(ancestor::folia:str)])"><xsl:if test="$textclass_current and $ancestors_ok and $ancestors_nosubtoken and not(ancestor::folia:str)"><xsl:apply-templates /></xsl:if></xsl:if>
</xsl:template>


Expand Down Expand Up @@ -676,7 +675,7 @@
<span class="attrvalue">
<xsl:for-each select="folia:morpheme">
<span class="morpheme">
<xsl:value-of select="./folia:t[not(@class) or @class='current']" />
<xsl:value-of select="./folia:t[$textclass_current]" />
<xsl:if test="@class">
<span class="details">(<xsl:value-of select="@class" />)</span>
</xsl:if>
Expand Down Expand Up @@ -860,6 +859,69 @@
</span><br/>
</xsl:for-each>
</xsl:for-each>

<xsl:for-each select="$ancestors">
<xsl:for-each select="folia:statements">
<xsl:for-each select="folia:statement">
<xsl:if test=".//folia:wref[@id=$id]">
<span class="attrlabel">Statement</span>
<span class="attrvalue">
<span class="spanclass"><xsl:value-of select="@class" /></span><xsl:text> </xsl:text>
<xsl:for-each select="folia:hd">
<strong>Head:</strong>
<xsl:call-template name="span">
<xsl:with-param name="id" select="$id" />
</xsl:call-template>
</xsl:for-each>
<xsl:for-each select="folia:source">
<strong>Source:</strong>
<xsl:call-template name="span">
<xsl:with-param name="id" select="$id" />
</xsl:call-template>
</xsl:for-each>
<xsl:for-each select="folia:rel">
<strong>Relation:</strong>
<xsl:call-template name="span">
<xsl:with-param name="id" select="$id" />
</xsl:call-template>
</xsl:for-each>
</span><br />
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>


<xsl:for-each select="$ancestors">
<xsl:for-each select="folia:sentiments">
<xsl:for-each select="folia:sentiment">
<xsl:if test=".//folia:wref[@id=$id]">
<span class="attrlabel">Sentiment</span>
<span class="attrvalue">
<span class="spanclass"><xsl:value-of select="@class" /></span><xsl:text> </xsl:text>
<xsl:for-each select="folia:hd">
<strong>Head:</strong>
<xsl:call-template name="span">
<xsl:with-param name="id" select="$id" />
</xsl:call-template>
</xsl:for-each>
<xsl:for-each select="folia:source">
<strong>Source:</strong>
<xsl:call-template name="span">
<xsl:with-param name="id" select="$id" />
</xsl:call-template>
</xsl:for-each>
<xsl:for-each select="folia:target">
<strong>Target:</strong>
<xsl:call-template name="span">
<xsl:with-param name="id" select="$id" />
</xsl:call-template>
</xsl:for-each>
</span><br />
</xsl:if>
</xsl:for-each>
</xsl:for-each>
</xsl:for-each>
</xsl:template>


Expand Down

0 comments on commit 423444e

Please sign in to comment.