Skip to content

FoLiA-correct fails with text consistency error #45

Closed

Description

@proycon

Running the TICCL pipeline on mwsel.pdf (via Piroska Lendvai), using text extracted from the PDF, FoLiA-correct fails with a text consistency error:

ticcl.nf --inputdir input --inputtype pdf --lexicon $LM_PREFIX/opt/PICCL/data/int/deu/deu.aspell.dict --alphabet $LM_PREFIX/opt/PICCL/data/int/deu/deu.aspell.dict.lc.chars --charconfus $LM_PREFIX/opt/PICCL/data/int/deu/deu.aspell.dict.c10.d2.confusion
Command output:
  Now using node v14.9.0 (npm v6.14.8)
  start reading variants
  read 180 variants
  start reading unknowns
  read 1 unknown words
  start reading puncts
  read 350 punctuated words
  verbosity = 0


  finished ./mwsel.folia.xml
  outputdir

Command error:
  start 1-gram correcting in file: ./mwsel.folia.xml
  FoLiA error in paragraph mwsel.p.7 of document mwsel
  inconsistent text: settext(cls=current): deeper text differs from attempted
  deeper='b'
  attempted='•a'

Leads to:

  Missing output file(s) `*.ticcl.folia.xml` expected by process `foliacorrect (1)`

Activity

  1. martinreynaert commented on Sep 10, 2020

    @martinreynaert
    Contributor

    So the web service does not return any other output files than error.log. As a consequence we cannot check what the FoLiA error reported is. We could check that in the version run on the command line. That might finally tell us sth.

  2. kosloot commented on Sep 10, 2020

    @kosloot
    Contributor

    The fastest way to pinpoint the problem is to take FoLiA-correct in isolation and run it with the same input files as in the pipeline.
    If you dare, you could also add '-v -v -v -v' tot the FoLiA-correct command to get a lot of output.

  3. kosloot commented on Sep 10, 2020

    @kosloot
    Contributor
  4. proycon commented on Sep 10, 2020

    @proycon
    MemberAuthor

    Ah, right, I confuse ticcltools and foliautils sometimes... moving it..

  5. proycon commented on Sep 10, 2020

    @proycon
    MemberAuthor

    Reproducing/inspecting the issue (outside of the production environment) is indeed not the problem and the FoLiA error is clear, it's just a matter of tracking it down and solving it. The main underlying issue remains that there's no official maintainer anymore for the ticcl stuff (but foliautils is technically in my jurisdiction now so I'll take a look)

  6. proycon commented on Sep 10, 2020

    @proycon
    MemberAuthor

    @kosloot Thanks for the verbosity tip, that helped get some more output (level 4):

    correct 1-grams in: '), 2 ), 3 ) \ 2, 3 \ 2, 3 A A1, A2, A 3 a b c , , a b •a b DV HS. X' (OCR)
    correct unigrams
    correct unigram ), [ <str xml:id='mwsel.p.7.str.1" > {<t>,}]
    correct unigram 2 [ <str xml:id='mwsel.p.7.str.2" > {<t>,}]
    correct unigram ), [ <str xml:id='mwsel.p.7.str.3" > {<t>,}]
    correct unigram 3 [ <str xml:id='mwsel.p.7.str.4" > {<t>,}]
    correct unigram ) [ <str xml:id='mwsel.p.7.str.5" > {<t>,}]
    correct unigram \ [ <str xml:id='mwsel.p.7.str.6" > {<t>,}]
    correct unigram 2, [ <str xml:id='mwsel.p.7.str.7" > {<t>,}]
    correct unigram 3 [ <str xml:id='mwsel.p.7.str.8" > {<t>,}]
    correct unigram \ [ <str xml:id='mwsel.p.7.str.9" > {<t>,}]
    correct unigram 2, [ <str xml:id='mwsel.p.7.str.10" > {<t>,}]
    correct unigram 3 [ <str xml:id='mwsel.p.7.str.11" > {<t>,}]
    correct unigram A [ <str xml:id='mwsel.p.7.str.12" > {<t>,}]
    correct unigram A1, [ <str xml:id='mwsel.p.7.str.13" > {<t>,}]
    correct unigram A2, [ <str xml:id='mwsel.p.7.str.14" > {<t>,}]
    correct unigram A [ <str xml:id='mwsel.p.7.str.15" > {<t>,}]
    correct unigram 3 [ <str xml:id='mwsel.p.7.str.16" > {<t>,}]
    correct unigram a [ <str xml:id='mwsel.p.7.str.17" > {<t>,}]
    correct unigram b [ <str xml:id='mwsel.p.7.str.18" > {<t>,}]
    correct unigram c [ <str xml:id='mwsel.p.7.str.19" > {<t>,}]
    correct unigram , [ <str xml:id='mwsel.p.7.str.20" > {<t>,}]
    correct unigram , [ <str xml:id='mwsel.p.7.str.21" > {<t>,}]
    correct unigram a [ <str xml:id='mwsel.p.7.str.23" > {<t>,}]
    correct unigram b [ <str xml:id='mwsel.p.7.str.24" > {<t>,}]
    correct unigram •a [ <str xml:id='mwsel.p.7.str.24" > {<t>,<t>,}]
    FoLiA error in paragraph mwsel.p.7 of document mwsel
    inconsistent text: settext(cls=current): deeper text differs from attempted
    deeper='b'
    attempted='•a'
    

    I don't get why it reports the same str ID for the last two items, seems wrong?

  7. martinreynaert commented on Sep 10, 2020

    @martinreynaert
    Contributor

    Seeing that the PICCL website does not leave any output files other than error.log, even when one requests debugging info, I have tried other approaches.

    Now, after other abortive tests with the PICCL webservice currently at Radboud I have used 'pdftotext' to extract the text from this pdf.

    In the webservice FoLiA-stats reported that the FoLiA created by txt2folia was invalid due an invalid character 12.

    The FoLiA file created by command line C++ tool FoLiA-txt from this text file likewise fails validation:

    reynaert@violet:/reddata/PICCL$ /exp/sloot/usr/local/bin/folialint mwsel.folia.xml
    mwsel.folia.xml:814: XML-error: PCDATA invalid Char value 12

    Both tools fail to create valid FoLiA on the basis of this test file. This is an unsavoury situation.

  8. martinreynaert commented on Sep 10, 2020

    @martinreynaert
    Contributor

    proycon, unless I am very mistaken, txt2folia is very much in your province and hence jurisdiction.

  9. proycon commented on Sep 10, 2020

    @proycon
    MemberAuthor

    Seeing that the PICCL website does not leave any output files other than error.log, even when one requests debugging info.

    The only thing that debug option does is not automatically clean up all the intermediate files, leaving them open to inspection if you have access to the server; it was implemented on your request a while ago. Note that the production server is never intended for deep debugging anyway, problems should be reproduced, analysed, and hopefully fixed in a local development environment.

    proycon, unless I am very mistaken, txt2folia is very much in your province and hence jurisdiction.

    Yes, definitely. FoLiA-txt too now. Both should indeed never produce invalid FoLiA, so that's a clear bug. Let's make new issues for that, as it's not directly related to the one in this topic. I reproduced it and already have a clue where it goes wrong (odd control characters in the pdftotext output).

  10. martinreynaert commented on Sep 10, 2020

    @martinreynaert
    Contributor

    Point is, proycon, the intermediate files do seem to have been cleaned up. There should at least have been the *txt file derived from the PDF.

    Characters that are not allowed in XML should be filtered out by the tool that creates the XML.

    Thanks!

  11. proycon commented on Sep 10, 2020

    @proycon
    MemberAuthor

    Point is, proycon, the intermediate files do seem to have been cleaned up.

    No, I meant that the entire work/ directory containing all of nextflow's work is left intact with that option on (by default it would be deleted immediately after a run). Most intermediate files are indeed not made available through the webservice (some are though, irregardless of the debug option, by your request a while back, I'll add the pdf2text result although I'm a bit wary of clutter or confusion for the user if there's a lot of output)

  12. proycon commented on Sep 10, 2020

    @proycon
    MemberAuthor

    Characters that are not allowed in XML should be filtered out by the tool that creates the XML.

    Yes, solved for txt2folia now (proycon/foliatools#14), still looking into FoLiA-txt.

  13. kosloot commented on Sep 12, 2020

    @kosloot
    Contributor

    So is this problem gone now after the fixes in libfolia?

  14. proycon commented on Sep 12, 2020

    @proycon
    MemberAuthor

    No! Only the side-issue @martinreynaert found and mentioned in this thread was solved, it did not affect this issue so it is still very much open.

  15. kosloot commented on Sep 13, 2020

    @kosloot
    Contributor

    So, my offer to analyze this still stands. Please provide me with ALL input files of the FoLiA-correct run.

  16. proycon commented on Sep 13, 2020

    @proycon
    MemberAuthor

    That would be great! Here are all the input files: https://lst.science.ru.nl/~proycon/8d4c3775cda1b0d0a2455f9e64bd7f.tar.gz

    Run as:

    FoLiA-correct --inputclass "OCR" --outputclass current --nums 10 -e folia.xml -O outputdir/ \
    --unk "corpus.wordfreqlist.tsv.unk" --punct "corpus.wordfreqlist.tsv.punct" \
    --rank  "corpus.wordfreqlist.tsv.clean.ldcalc.ranked.chained.ranked"  -t 1 .
    
  17. kosloot commented on Sep 13, 2020

    @kosloot
    Contributor

    O, I can reproduce this. It seems a problem in the HEMP detection. The • in •a is seen as the possible start of an HEMP
    But then the procedure to resolve HEMP's is running havoc somewhere.
    This needs more investigation.

  18. martinreynaert commented on Sep 13, 2020

    @martinreynaert
    Contributor

    The ranked file primarily shows TICCL should not be run on very short texts and particularly not when it is not given a very comprehensive lexicon and name list for the language involved. Also very obvious is that the Aspell lexicon it had available for this run only has lemmata. Other word forms have mainly been lemmatized here.

    This test file is a curious mix of German and Latin. For this a bilingual background lexicon would be called for.

    It seems it somehow normalizes double 's' in TICCL-unk (look there for 'ss') only to correct 'ss' into the Eszett (Dutch: Ringl-s) later. Right now I have no good idea why it normalizes that.

  19. martinreynaert commented on Sep 13, 2020

    @martinreynaert
    Contributor

    So HEMP detection is in the way even if no -hemp parameter was ever set?

  20. martinreynaert commented on Sep 13, 2020

    @martinreynaert
    Contributor

    Another thing that has struck me during these tests is that PICCL does not yet allow for bi- or trigram correction. The parameter for that is in the FoLiA-stats command in ticcl.nf but if I am not mistaken, the interface does not yet allow for setting 'max' to 3 for trigram correction. By rights, this is another issue to be sure.

  21. kosloot commented on Sep 13, 2020

    @kosloot
    Contributor

    interestingly, FoLiA-correct doesn't have a --hemp parameter at all. :)
    It uses the found HEMPS's from the puncts file, I assume.
    But indeed it tries to detect hemps all the time.

    Needs more investigation....

  22. martinreynaert commented on Sep 13, 2020

    @martinreynaert
    Contributor

    If I remember correctly it indeed uses the HEMPs from the puncts file.

  23. martinreynaert commented on Sep 13, 2020

    @martinreynaert
    Contributor

    Does not TICCL-unk normalize '•a' to 'a' ? I seem to remember we have discussed this before.

  24. kosloot commented on Sep 14, 2020

    @kosloot
    Contributor

    Ok. FoLiA-correct uses the same algorithm as TICCL-unk to detect HEMPS. When one is found, it is checked in the PUNCT file.
    When present the HEMP is resolved. Otherwise it is ignored.
    There was a small error in the ignoring step, which caused a one-off error, which is corrected now.

    @martinreynaert '•a' is NOT to included in the punct file by TICCL-unk while the de-punctuated 'a' is too short.

  25. proycon commented on Sep 15, 2020

    @proycon
    MemberAuthor

    Confirmed, is fixed! Guess we should do a release now.

  26. added
    ready
    on Sep 15, 2020
  27. kosloot commented on Sep 15, 2020

    @kosloot
    Contributor

    Nice that this is fixed!
    Final remark: When a HEMP is 'resolved' it is simply done by attaching the resolved text to one of the input string/word nodes.
    This should ideally be done by creating a real FoLiA correction.
    I will add this as a separate issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    ready

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions