Skip to content

Commit

Permalink
adapting to newer libfolia
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Dec 3, 2024
1 parent 9bb38f9 commit 3f3d2f1
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/FoLiA-clean.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<TextContent>() ) {
if ( !textclass.empty() ){
if ( debug ){
#pragma omp critical( debugging )
Expand Down
13 changes: 11 additions & 2 deletions src/FoLiA-correct.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1271,6 +1271,15 @@ void correctNgrams( FoliaElement *root,
}
}

template<typename T>
vector<FoliaElement*> upcast( const vector<T*>& v ){
vector<FoliaElement*> result;
for( const auto& it : v ){
result.push_back(static_cast<FoliaElement*>(it));
}
return result;
}

bool correctDoc( Document *doc,
const unordered_map<string,vector<word_conf> >& variants,
const unordered_set<string>& unknowns,
Expand All @@ -1285,9 +1294,9 @@ bool correctDoc( Document *doc,
doc->declare( folia::AnnotationType::CORRECTION, setname, args );
vector<FoliaElement*> ev;
if ( tag_list.empty() ){
vector<FoliaElement*> v1 = doc->doc()->select( Sentence_t );
vector<FoliaElement*> v1 = upcast(doc->doc()->select<Sentence>());
if ( v1.empty() ){
v1 = doc->doc()->select( Paragraph_t );
v1 = upcast(doc->doc()->select<Paragraph>() );
}
ev = v1;
}
Expand Down
2 changes: 1 addition & 1 deletion src/FoLiA-merge.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -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<FoliaElement*> wv = doc->doc()->select( Word_t );
vector<Word*> wv = doc->doc()->select<Word>();
for( const auto& word : wv ){
try {
add_lemma_pos( word, lexicon );
Expand Down
2 changes: 1 addition & 1 deletion src/FoLiA-txt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ void add_paragraph( folia::FoliaElement *par,
// we don't want a terminating <br/> 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<Linebreak>() ){
break;
}
txt->append(it );
Expand Down

0 comments on commit 3f3d2f1

Please sign in to comment.