From 3f3d2f1ae5758a29d97086d080a584644d18df2d Mon Sep 17 00:00:00 2001 From: Ko van der Sloot Date: Tue, 3 Dec 2024 20:24:31 +0100 Subject: [PATCH] adapting to newer libfolia --- src/FoLiA-clean.cxx | 2 +- src/FoLiA-correct.cxx | 13 +++++++++++-- src/FoLiA-merge.cxx | 2 +- src/FoLiA-txt.cxx | 2 +- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/src/FoLiA-clean.cxx b/src/FoLiA-clean.cxx index df254ea..79eca8c 100644 --- a/src/FoLiA-clean.cxx +++ b/src/FoLiA-clean.cxx @@ -85,7 +85,7 @@ void clean_text( FoliaElement *node, } for ( size_t i=0; i < node->size(); ++i ){ FoliaElement *p = node->index(i); - if ( p->element_id() == TextContent_t ) { + if ( p->isinstance() ) { if ( !textclass.empty() ){ if ( debug ){ #pragma omp critical( debugging ) diff --git a/src/FoLiA-correct.cxx b/src/FoLiA-correct.cxx index 0f569f8..440c2f3 100644 --- a/src/FoLiA-correct.cxx +++ b/src/FoLiA-correct.cxx @@ -1271,6 +1271,15 @@ void correctNgrams( FoliaElement *root, } } +template +vector upcast( const vector& v ){ + vector result; + for( const auto& it : v ){ + result.push_back(static_cast(it)); + } + return result; +} + bool correctDoc( Document *doc, const unordered_map >& variants, const unordered_set& unknowns, @@ -1285,9 +1294,9 @@ bool correctDoc( Document *doc, doc->declare( folia::AnnotationType::CORRECTION, setname, args ); vector ev; if ( tag_list.empty() ){ - vector v1 = doc->doc()->select( Sentence_t ); + vector v1 = upcast(doc->doc()->select()); if ( v1.empty() ){ - v1 = doc->doc()->select( Paragraph_t ); + v1 = upcast(doc->doc()->select() ); } ev = v1; } diff --git a/src/FoLiA-merge.cxx b/src/FoLiA-merge.cxx index 41f58a7..5e217e9 100644 --- a/src/FoLiA-merge.cxx +++ b/src/FoLiA-merge.cxx @@ -111,7 +111,7 @@ bool merge_values( Document *doc, args["processor"] = proc->id(); doc->declare( folia::AnnotationType::LEMMA, lem_setname, args ); doc->declare( folia::AnnotationType::POS, pos_setname, args ); - vector wv = doc->doc()->select( Word_t ); + vector wv = doc->doc()->select(); for( const auto& word : wv ){ try { add_lemma_pos( word, lexicon ); diff --git a/src/FoLiA-txt.cxx b/src/FoLiA-txt.cxx index 30b5266..2724e09 100644 --- a/src/FoLiA-txt.cxx +++ b/src/FoLiA-txt.cxx @@ -81,7 +81,7 @@ void add_paragraph( folia::FoliaElement *par, // we don't want a terminating
at the end of a paragraph. // 2 newlines ar already implicit for a paragraph if ( &it == &par_stack.back() - && it->isSubClass( Linebreak_t ) ){ + && it->isSubClass() ){ break; } txt->append(it );