Skip to content

Commit

Permalink
FoLiA-txt now continues when a file failed to be processed
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Oct 31, 2024
1 parent 52ec165 commit 20b37dd
Showing 1 changed file with 9 additions and 11 deletions.
20 changes: 9 additions & 11 deletions src/FoLiA-txt.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -95,8 +95,6 @@ bool handle_one_file( const string& fileName ){
{
cerr << "failed to read " << fileName << endl;
}
++failed_docs;
--to_do;
return false;
}
#pragma omp critical
Expand All @@ -121,8 +119,6 @@ bool handle_one_file( const string& fileName ){
if ( !isNCName( docid ) ){
cerr << "unable to generate a Document ID from the filename: '"
<< fileName << "'" << endl;
++failed_docs;
--to_do;
return false;
}
}
Expand All @@ -135,8 +131,6 @@ bool handle_one_file( const string& fileName ){
{
cerr << "failed to create a document with id:'" << docid << "'" << endl;
cerr << "reason: " << e.what() << endl;
++failed_docs;
--to_do;
}
return false;
}
Expand Down Expand Up @@ -234,8 +228,6 @@ bool handle_one_file( const string& fileName ){
{
cerr << "no useful data found in document:'" << docid << "'" << endl;
cerr << "skipped!" << endl;
++failed_docs;
--to_do;
}
return false;
}
Expand Down Expand Up @@ -348,10 +340,16 @@ int main( int argc, char *argv[] ){
}
#endif
string fileName = file_names[fn];
handle_one_file( fileName );
if ( !handle_one_file( fileName ) ){
#pragma omp critical
{
++failed_docs;
}
}
}
if ( failed_docs > 0 && failed_docs == to_do ){
cerr << "No documents could be handled successfully!" << endl;
if ( failed_docs > 0 ){
cerr << std::to_string( failed_docs ) << " documents out of "
<< std::to_string(file_names.size()) << " failed" << endl;
return EXIT_SUCCESS;
}
else {
Expand Down

0 comments on commit 20b37dd

Please sign in to comment.