Outils pour utilisateurs

Outils du site


public:specs_correction_tokenisation

Spécifications de la re-segmentation et de la ré-annotation des mots

Objectifs

  • Améliorer la qualité de la tokenisation en appliquant des règles de transformation sur un document tokenisé
  • Ajouter des propriétés utiles aux unités lexicales (références, structures de niveau supérieur)

Etat des lieux

Méthode

  • Transformation XSL entre l'étape de la tokenisation et la production de XML-TXM
  • Actuellement, on peut
    • arrêter l'import à la fin de la tokenisation
    • récupérer les fichiers du dossier <répertoire utilisateur>/TXM/corpora/<nom du corpus>/tokenised/
    • réimporter les fichiers tokenisés en appliquant une XSL spéciale

Solution

ajout de références

   <xsl:template match="tei:w">
     <xsl:copy>
       <xsl:apply-templates select="@*"/>
       <xsl:attribute name="ref"><xsl:value-of select="concat(ancestor::tei:text/@id,', p. ',preceding::tei:pb[1]/@n)"/></xsl:attribute>
       <xsl:apply-templates/>
     </xsl:copy>
   </xsl:template> 

mots coupés

  <xsl:template match="w">
    <xsl:variable name="nextLb">
      <xsl:choose>
        <xsl:when test="following-sibling::lb[@rend='hyphen']">
          <xsl:apply-templates select="following-sibling::lb[@rend='hyphen'][1]" mode="position"/>
        </xsl:when>
        <xsl:otherwise>99999999</xsl:otherwise>
      </xsl:choose>      
    </xsl:variable>
    <xsl:variable name="nextW1">
      <xsl:choose>
        <xsl:when test="following-sibling::w[1]">
          <xsl:apply-templates select="following-sibling::w[1]" mode="position"/>
        </xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>    
    <xsl:variable name="nextW2">
      <xsl:choose>
        <xsl:when test="following-sibling::w[2]">
          <xsl:apply-templates select="following-sibling::w[2]" mode="position"/>
        </xsl:when>
        <xsl:otherwise>0</xsl:otherwise>
      </xsl:choose>
    </xsl:variable>
    <xsl:choose>
      <xsl:when test="following::w[1][matches(.,'^\s*-\s*$')] and ($nextW2 &gt; $nextLb)">
        <w>
          <xsl:apply-templates select="@*"/>
          <xsl:value-of select="normalize-space(.)"/><lb rend="hyphen"/><xsl:value-of select="normalize-space(following::w[2])"/>
        </w>
      </xsl:when>
      <xsl:when test="not(matches(.,'^\s*-\s*$')) and following-sibling::*[1][self::lb[@rend='hyphen']]">
        <w>
          <xsl:apply-templates select="@*"/>
          <xsl:value-of select="normalize-space(.)"/><lb rend="hyphen"/><xsl:value-of select="normalize-space(following::w[1])"/>
        </w>
      </xsl:when>
      <xsl:when test="matches(.,'^\s*-\s*$') and ($nextW1 &gt; $nextLb)">
        <xsl:comment>trait d'union effacé</xsl:comment>
      </xsl:when>
      <xsl:when test="preceding-sibling::*[1][self::lb[@rend='hyphen']]">
        <xsl:comment>fin de mot coupé : <xsl:value-of select="."/></xsl:comment>
      </xsl:when>
      <xsl:otherwise>
        <xsl:copy>
          <xsl:apply-templates select="*|@*|processing-instruction()|comment()|text()"/>
        </xsl:copy>
      </xsl:otherwise>
    </xsl:choose>
  </xsl:template>

Protocole de test

Recette

public/specs_correction_tokenisation.txt · Dernière modification : 04/06/2015 11:30 de matthieu.decorde@ens-lyon.fr