Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix FP division by zero (issue #3995) #3996

Merged
merged 2 commits into from
Jan 20, 2023
Merged

Conversation

stweil
Copy link
Contributor

@stweil stweil commented Jan 19, 2023

No description provided.

@stweil stweil mentioned this pull request Jan 19, 2023
@@ -1375,7 +1375,12 @@ void LanguageModel::ExtractFeaturesFromPath(const ViterbiStateEntry &vse, float
// features[PTRAIN_NUM_BAD_FONT] = vse.consistency_info.inconsistent_font;

// Classifier-related features.
features[PTRAIN_RATING_PER_CHAR] = vse.ratings_sum / static_cast<float>(vse.outline_length);
if (vse.outline_length != 0.0f) {

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

features[PTRAIN_RATING_PER_CHAR] = (vse.outline_length > 0.0f) ? (vse.ratings_sum / static_cast<float>(vse.outline_length)) : 0.0f;

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why would that be better?

Copy link

@zvezdochiot zvezdochiot Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @stweil .

⚠️ (vse.outline_length != 0.0f)!!! (float?)

If not (float) then replace with (vse.outline_length != 0).

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks. I replaced != by > now. Please review the updated code.

Copy link

@zvezdochiot zvezdochiot Jan 19, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @stweil .

vse.outline_length is it (float)? See #3996 (comment)

PS:

float outline_length; ///< length of the outline so far

Resolved. 👍

@stweil stweil merged commit 3bedea1 into tesseract-ocr:main Jan 20, 2023
@stweil stweil deleted the issue3995 branch January 20, 2023 15:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants