proycon / foliatools

A number of command-line tools for working with FoLiA (Format for Linguistic Annotation). Includes validators, converters, visualisers, and more.
GNU General Public License v3.0
10 stars 4 forks source link

folia2txt vs. FoLiA-2text handling of <part> nodes #28

Closed kosloot closed 3 years ago

kosloot commented 3 years ago

Given this FoLiA file:

<?xml version="1.0" encoding="UTF-8"?>
<FoLiA xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://ilk.uvt.nl/folia" xml:id="parts" generator="libfolia-v2.8" version="2.4.0">
  <metadata type="native">
    <annotations>
      <paragraph-annotation set="set"/>
      <part-annotation set="set"/>
      <style-annotation set="set"/>
      <hyphenation-annotation set="set"/>
      <text-annotation set="https://raw.githubusercontent.com/proycon/folia/master/setdefinitions/text.foliaset.ttl"/>
    </annotations>
  </metadata>
  <text xml:id="parts.text">
    <p xml:id="parts.text.p1">
      <feat class="Justified" subset="par_align"/>
      <part xml:id="parts.text.p1.part.1" class="line">
        <part xml:id="parts.text.p1.part.1.part.1" class="fragment">
          <t>
            <t-style>Dit </t-style>
          </t>
        </part>
        <part xml:id="parts.text.p1.part.1.part.2" class="fragment">
          <t>
            <t-style>is een gebroken lijn</t-style>
          </t>
        </part>
      </part>
      <part xml:id="parts.text.p1.part.2" class="line" space="no">
        <t>
          <t-style>met nog een lijn die is af<t-hbr/></t-style>
        </t>
      </part>
      <part xml:id="parts.text.p1.part.3" class="line">
        <part xml:id="parts.text.p1.part.3.part.1" class="fragment">
          <t>
            <t-style>gebroken bij een hyphen.<br/></t-style>
          </t>
          </part>
          <part xml:id="parts.text.p1.part.2.part.2" class="fragment">
            <t>
              <t-style>nieuwe regel</t-style>
            </t>
          </part>
      </part>
    </p>
  </text>
</FoLiA>

Note the space="no" and and the
!

folia2txt produces this text:

            Dit 

            is een gebroken lijn

          met nog een lijn die is af

            gebroken bij een hyphen.

              nieuwe regel

OTOH, FoLiA-2text produces:

Dit is een gebroken lijn met nog een lijn die is afgebroken bij een hyphen.
nieuwe regel

I wonder which of both is "correct". folia2txt missing the space="no" seems a problem to me anyway.

I tries the same with on level of <part> nodes less:

<?xml version="1.0" encoding="UTF-8"?>
<FoLiA xmlns:xlink="http://www.w3.org/1999/xlink" xmlns="http://ilk.uvt.nl/folia" xml:id="parts" generator="libfolia-v2.8" version="2.4.0">
  <metadata type="native">
    <annotations>
      <paragraph-annotation set="set"/>
      <part-annotation set="set"/>
      <style-annotation set="set"/>
      <hyphenation-annotation set="set"/>
      <text-annotation set="https://raw.githubusercontent.com/proycon/folia/master/setdefinitions/text.foliaset.ttl"/>
    </annotations>
  </metadata>
  <text xml:id="parts.text">
    <p xml:id="parts.text.p1">
      <feat class="Justified" subset="par_align"/>
      <part xml:id="parts.text.p1.part.1." class="line">
        <t>
          <t-style>Dit </t-style>
        </t>
      </part>
      <part xml:id="parts.text.p1.part.2" class="line">
        <t>
          <t-style>is een gebroken lijn</t-style>
        </t>
      </part>
      <part xml:id="parts.text.p1.part.3" class="line" space="no">
        <t>
          <t-style>met nog een lijn die is af<t-hbr/></t-style>
        </t>
      </part>
      <part xml:id="parts.text.p1.part.4" class="line">
        <t>
          <t-style>gebroken bij een hyphen.<br/></t-style>
        </t>
      </part>
      <part xml:id="parts.text.p1.part.5" class="fragment">
        <t>
          <t-style>nieuwe regel</t-style>
        </t>
      </part>
    </p>
  </text>
</FoLiA>

In that case the results are: folia2txt:

            Dit 

            is een gebroken lijn

          met nog een lijn die is af

            gebroken bij een hyphen.

              nieuwe regel

FoLiA-2text:

Dit is een gebroken lijn met nog een lijn die is afgebroken bij een hyphen.
nieuwe regel

(which is the same as before)

So again: which one is "correct"

proycon commented 3 years ago

Hmm, all that indentation and the newlines shouldn't be there, I was under the impression we fixed that in https://github.com/proycon/folia/issues/88 . Was this on the latest foliatools/foliapy?

The libfolia output is the correct one indeed here.

proycon commented 3 years ago

I think your foliapy/foliatools was outdated, I can't reproduce it:

$ folia2txt issue28.folia.xml
Converting issue28.folia.xml
Dit is een gebroken lijn met nog een lijn die is afgebroken bij een hyphen.
 nieuwe regel

That indenting single space on the second line may be a new issue though, your FoLiA-2text is better.

kosloot commented 3 years ago

Yest thanx, I did an update and now I can reproduce the last 'new' issue