Skip to content

Commit

Permalink
small refactorings
Browse files Browse the repository at this point in the history
  • Loading branch information
kosloot committed Sep 27, 2024
1 parent 4a5c191 commit fc88ce7
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 21 deletions.
8 changes: 4 additions & 4 deletions src/FoLiA-alto.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -132,7 +132,7 @@ xmlDoc *docCache::find( const string& f ) const {
xmlNode *findPart2Level( const xmlNode *start ){
if ( start && start->next ){
xmlNode *pnt = start->next->children;
while ( pnt != 0 ){
while ( pnt ){
if ( pnt->type == XML_ELEMENT_NODE &&
TiCC::Name(pnt) == "String" ){
break;
Expand Down Expand Up @@ -162,7 +162,7 @@ xmlNode *findPart2Block( const xmlNode *start ){
if ( pnt ){
// found a node "TextLine"
pnt = pnt->children;
while ( pnt != 0 ){
while ( pnt ){
if ( pnt->type == XML_ELEMENT_NODE &&
TiCC::Name(pnt) == "String" ){
break;
Expand Down Expand Up @@ -309,7 +309,7 @@ void createFile( folia::FoliaElement *text,
int cnt = 0;
for ( const auto *line : lv ){
xmlNode *pnt = line->children;
while ( pnt != 0 ){
while ( pnt ){
if ( pnt->type == XML_ELEMENT_NODE ){
if ( TiCC::Name(pnt) == "String" ){
string sub_t = TiCC::getAttribute( pnt, "SUBS_TYPE" );
Expand Down Expand Up @@ -1018,7 +1018,7 @@ void solveBook( const string& altoFile,
list<xmlNode*> lv = TiCC::FindNodes( node, "*[local-name()='TextLine']" );
for ( const auto *line : lv ){
xmlNode *pnt = line->children;
while ( pnt != 0 ){
while ( pnt ){
if ( pnt->type == XML_ELEMENT_NODE ){
if ( TiCC::Name(pnt) == "String" ){
string sub_t = TiCC::getAttribute( pnt, "SUBS_TYPE" );
Expand Down
28 changes: 11 additions & 17 deletions src/FoLiA-stats.cxx
Original file line number Diff line number Diff line change
Expand Up @@ -117,15 +117,13 @@ void create_agg_list( const map<string,vector<map<UnicodeString, unsigned int>>>
map<UnicodeString,map<string,unsigned int>> totals;
for ( const auto& wc0 : wcv ){
string lang = wc0.first;
auto cit = wc0.second[ng].begin();
while( cit != wc0.second[ng].end() ){
if ( cit->second <= clip ){
for ( auto const &[str,val] : wc0.second[ng] ){
if ( val <= clip ){
++clipped;
}
else {
totals[cit->first].insert( make_pair(lang, cit->second ) );
totals[str].insert( make_pair(lang, val ) );
}
++cit;
}
}
map<string,unsigned int> lang_tot;
Expand Down Expand Up @@ -207,15 +205,13 @@ void create_wf_list( const map<string,vector<map<UnicodeString, unsigned int>>>&
}
ofstream os( ofilename );
map<unsigned int, set<UnicodeString>> wf;
auto cit = wc0.second[ng].begin();
while( cit != wc0.second[ng].end() ){
if ( cit->second <= clip ){
total_n -= cit->second;
for ( auto const& [str,val] : wc0.second[ng] ){
if ( val <= clip ){
total_n -= val;
}
else {
wf[cit->second].insert( cit->first );
wf[val].insert( str );
}
++cit;
}
unsigned int sum=0;
unsigned int types=0;
Expand Down Expand Up @@ -282,15 +278,13 @@ void create_collected_wf_list( const map<string,vector<map<UnicodeString, unsign
grand_total += totals_per_n[lang][ng];
unsigned int total_n = totals_per_n[lang][ng];
if ( total_n > 0 ){
auto cit = wc0.second[ng].begin();
while( cit != wc0.second[ng].end() ){
if ( cit->second <= clip ){
total_n -= cit->second;
for ( const auto& [str,val] : wc0.second[ng] ){
if ( val <= clip ){
total_n -= val;
}
else {
wf[cit->second].insert( cit->first );
wf[val].insert( str );
}
++cit;
}
grand_total_clipped += total_n;
}
Expand Down

0 comments on commit fc88ce7

Please sign in to comment.