Skip to content

Commit

Permalink
more adaptations
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Dec 4, 2024
1 parent 3f3d2f1 commit 27de86d
Showing 1 changed file with 9 additions and 14 deletions.
23 changes: 9 additions & 14 deletions src/FoLiA-correct.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -1144,7 +1144,8 @@ void correctNgrams( FoliaElement *root,
#else
string inval;
if ( ev.size() == 0 ){
vector<TextContent *> origV = root->select<TextContent>(false);
vector<TextContent *> origV
= root->select<TextContent>(SELECT_FLAGS::LOCAL);
if ( origV.empty() ){
// OK, no text directly
// look deeper then
Expand Down Expand Up @@ -1271,15 +1272,6 @@ 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 @@ -1294,11 +1286,14 @@ bool correctDoc( Document *doc,
doc->declare( folia::AnnotationType::CORRECTION, setname, args );
vector<FoliaElement*> ev;
if ( tag_list.empty() ){
vector<FoliaElement*> v1 = upcast(doc->doc()->select<Sentence>());
if ( v1.empty() ){
v1 = upcast(doc->doc()->select<Paragraph>() );
vector<Sentence *> vs = doc->doc()->select<Sentence>();
if ( vs.empty() ){
vector<Paragraph*> vp = doc->doc()->select<Paragraph>();
merge<Paragraph>( ev, vp );
}
else {
merge<Sentence>( ev, vs );
}
ev = v1;
}
else {
for ( const auto& et : tag_list ){
Expand Down

0 comments on commit 27de86d

Please sign in to comment.