Skip to content

Commit

Permalink
Convert CRLF line endings to LF
Browse files Browse the repository at this point in the history
Signed-off-by: Stefan Weil <sw@weilnetz.de>
  • Loading branch information
stweil committed Aug 23, 2018
1 parent 63965bd commit f24426c
Show file tree
Hide file tree
Showing 2 changed files with 98 additions and 98 deletions.
112 changes: 56 additions & 56 deletions src/classify/mfoutline.cpp
Expand Up @@ -379,62 +379,62 @@ void ComputeDirection(MFEDGEPT *Start,
MFEDGEPT *Finish,
float MinSlope,
float MaxSlope) {
FVECTOR Delta;

Delta.x = Finish->Point.x - Start->Point.x;
Delta.y = Finish->Point.y - Start->Point.y;
if (Delta.x == 0) {
if (Delta.y < 0) {
Start->Slope = -FLT_MAX;
Start->Direction = south;
} else {
Start->Slope = FLT_MAX;
Start->Direction = north;
}
} else {
Start->Slope = Delta.y / Delta.x;
if (Delta.x > 0) {
if (Delta.y > 0) {
if (Start->Slope > MinSlope) {
if (Start->Slope < MaxSlope) {
Start->Direction = northeast;
} else {
Start->Direction = north;
}
} else {
Start->Direction = east;
}
}
else if (Start->Slope < -MinSlope) {
if (Start->Slope > -MaxSlope) {
Start->Direction = southeast;
} else {
Start->Direction = south;
}
} else {
Start->Direction = east;
}
} else if (Delta.y > 0) {
if (Start->Slope < -MinSlope) {
if (Start->Slope > -MaxSlope) {
Start->Direction = northwest;
} else {
Start->Direction = north;
}
} else {
Start->Direction = west;
}
} else if (Start->Slope > MinSlope) {
if (Start->Slope < MaxSlope) {
Start->Direction = southwest;
} else {
Start->Direction = south;
}
} else {
Start->Direction = west;
}
}
Finish->PreviousDirection = Start->Direction;
FVECTOR Delta;

Delta.x = Finish->Point.x - Start->Point.x;
Delta.y = Finish->Point.y - Start->Point.y;
if (Delta.x == 0) {
if (Delta.y < 0) {
Start->Slope = -FLT_MAX;
Start->Direction = south;
} else {
Start->Slope = FLT_MAX;
Start->Direction = north;
}
} else {
Start->Slope = Delta.y / Delta.x;
if (Delta.x > 0) {
if (Delta.y > 0) {
if (Start->Slope > MinSlope) {
if (Start->Slope < MaxSlope) {
Start->Direction = northeast;
} else {
Start->Direction = north;
}
} else {
Start->Direction = east;
}
}
else if (Start->Slope < -MinSlope) {
if (Start->Slope > -MaxSlope) {
Start->Direction = southeast;
} else {
Start->Direction = south;
}
} else {
Start->Direction = east;
}
} else if (Delta.y > 0) {
if (Start->Slope < -MinSlope) {
if (Start->Slope > -MaxSlope) {
Start->Direction = northwest;
} else {
Start->Direction = north;
}
} else {
Start->Direction = west;
}
} else if (Start->Slope > MinSlope) {
if (Start->Slope < MaxSlope) {
Start->Direction = southwest;
} else {
Start->Direction = south;
}
} else {
Start->Direction = west;
}
}
Finish->PreviousDirection = Start->Direction;
}

/**
Expand Down
84 changes: 42 additions & 42 deletions src/lstm/recodebeam.cpp
Expand Up @@ -199,16 +199,16 @@ void RecodeBeamSearch::ExtractBestPathAsWords(const TBOX& line_box,
}
int current_char;
int timestepEnd = 0;
//if glyph confidence is required in granularity level 2 it stores the x
//if glyph confidence is required in granularity level 2 it stores the x
//Coordinates of every chosen character to match the alternative glyphs to it
if (glyph_confidence == 2) {
ExtractPathAsUnicharIds(best_nodes, &unichar_ids, &certs, &ratings,
&xcoords, &best_glyphs);
&xcoords, &best_glyphs);
if (best_glyphs.size() > 0) {
current_char = best_glyphs.front().first;
timestepEnd = best_glyphs.front().second;
best_glyphs.pop_front();
}
}
} else {
ExtractPathAsUnicharIds(best_nodes, &unichar_ids, &certs, &ratings,
&xcoords);
Expand Down Expand Up @@ -250,48 +250,48 @@ void RecodeBeamSearch::ExtractBestPathAsWords(const TBOX& line_box,
timestepEnd = xcoords[word_end];
} else if (glyph_confidence == 2) {
float sum = 0;
std::vector<std::pair<const char*, float>> glyph_pairs;
for (size_t i = timestepEnd; i < xcoords[word_end]; i++) {
for (std::pair<const char*, float> glyph : timesteps[i]) {
if (std::strcmp(glyph.first, "") != 0) {
sum += glyph.second;
glyph_pairs.push_back(glyph);
}
}
if (best_glyphs.size() > 0 && i == best_glyphs.front().second-1
|| i == xcoords[word_end]-1) {
std::map<const char*, float> summed_propabilities;
for(auto it = glyph_pairs.begin(); it != glyph_pairs.end(); ++it) {
summed_propabilities[it->first] += it->second;
}
std::vector<std::pair<const char*, float>> accumulated_timestep;
accumulated_timestep.push_back(std::pair<const char*,float>
(unicharset->id_to_unichar_ext
(current_char), 2.0));
int pos;
for (auto it = summed_propabilities.begin();
it != summed_propabilities.end(); ++it) {
if(sum == 0) break;
it->second/=sum;
std::vector<std::pair<const char*, float>> glyph_pairs;
for (size_t i = timestepEnd; i < xcoords[word_end]; i++) {
for (std::pair<const char*, float> glyph : timesteps[i]) {
if (std::strcmp(glyph.first, "") != 0) {
sum += glyph.second;
glyph_pairs.push_back(glyph);
}
}
if (best_glyphs.size() > 0 && i == best_glyphs.front().second-1
|| i == xcoords[word_end]-1) {
std::map<const char*, float> summed_propabilities;
for(auto it = glyph_pairs.begin(); it != glyph_pairs.end(); ++it) {
summed_propabilities[it->first] += it->second;
}
std::vector<std::pair<const char*, float>> accumulated_timestep;
accumulated_timestep.push_back(std::pair<const char*,float>
(unicharset->id_to_unichar_ext
(current_char), 2.0));
int pos;
for (auto it = summed_propabilities.begin();
it != summed_propabilities.end(); ++it) {
if(sum == 0) break;
it->second/=sum;
pos = 0;
while (accumulated_timestep.size() > pos
while (accumulated_timestep.size() > pos
&& accumulated_timestep[pos].second > it->second) {
pos++;
}
accumulated_timestep.insert(accumulated_timestep.begin() + pos,
std::pair<const char*,float>(it->first,
it->second));
}
if (best_glyphs.size() > 0) {
current_char = best_glyphs.front().first;
best_glyphs.pop_front();
}
glyph_pairs.clear();
word_res->timesteps.push_back(accumulated_timestep);
sum = 0;
}
}
timestepEnd = xcoords[word_end];
}
accumulated_timestep.insert(accumulated_timestep.begin() + pos,
std::pair<const char*,float>(it->first,
it->second));
}
if (best_glyphs.size() > 0) {
current_char = best_glyphs.front().first;
best_glyphs.pop_front();
}
glyph_pairs.clear();
word_res->timesteps.push_back(accumulated_timestep);
sum = 0;
}
}
timestepEnd = xcoords[word_end];
}
for (int i = word_start; i < word_end; ++i) {
BLOB_CHOICE_LIST* choices = new BLOB_CHOICE_LIST;
Expand Down

0 comments on commit f24426c

Please sign in to comment.