question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Bugs in normalize text algorithm

See original GitHub issue

Explain what you did

Call normalize(1) in iPhone 5. It will return 0.95.

Expected behavior

It should be 1 according to the comments in source codes.

Describe the bug

The reason is that iPhone 5 has a 320x568 screen, which will trigger the first if statement in src/helpers/normalizeText.js.

What’s more, in other cases like pixelRatio >= 3 && pixelRatio < 3.5 and pixelRatio >= 3.5, the condition of the first if statement includes deviceWidth=360, but pixelRatio >= 2 && pixelRatio < 3 does not. It looks like strange.

At last, would you mind adding tests like https://github.com/gitpoint/git-point/pull/899 for this file?

    // iphone 5s and older Androids
    if (deviceWidth < 360) {
      return size * 0.95;
    }

    // iphone 5
    if (deviceHeight < 667) {
      return size;
      // iphone 6-6s
    }

To Reproduce

See https://github.com/gitpoint/git-point/pull/899.

Screenshots

None.

Your Environment (please complete the following information):

software version
react-native-elements any
react-native any

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:9 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
flyingcirclecommented, Sep 17, 2020

As a side note, to my knowledge regexs are only expensive when .* is overused and the likelyhood of the regex having to backtrack increases. That regex looks fairly straight forward and not too intense of a process. Also, that regex is only run once. If the regex was being run every time it needed to scale a number, I’d agree that that would intense.

1reaction
flyingcirclecommented, May 7, 2020

I’m wondering if instead of trying to fix this rather complicated algorithm we instead change to using this library instead: https://github.com/NewBieBR/react-native-normalize thoughts? This would likely require a major revision bump though.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Identifying Implementation Bugs in Machine Learning Based ...
When a ML algorithm exhibits an incorrect output (e.g. wrong classification to a particular input), there can be multiple under- lying reasons. ...
Read more >
Finding Bugs in Source Code Using Commonly Available ...
The text matching method is most use- ful for catching two types of bug injection: vulnerable code reuse and vulnerability reintroduction (regression).
Read more >
Developing bug severity prediction models using word2vec
Text mining techniques have the potential to analyze such massive databases of the textual description of bug reports to classify bug severity levels...
Read more >
Regular Expressions, Text Normalization, Edit Distance
We'll introduce a metric called edit distance that measures how similar two strings are based on the number of edits (insertions, deletions, substitutions)...
Read more >
Into NLP 4 ~ Normal Language Perfection - Text Normalization
Stemming is the first method one can use when the words get too annoying. A stemming algorithm simply tries to identify the endings...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found