| 1759 | */ |
| 1760 | private: |
| 1761 | double match_bitapScore(ssize_t e, ssize_t x, ssize_t loc, const string_t &pattern) const { |
| 1762 | const float accuracy = static_cast<float> (e) / pattern.length(); |
| 1763 | const ssize_t proximity = (loc - x < 0)? (x - loc) : (loc - x); |
| 1764 | if (Match_Distance == 0) { |
| 1765 | // Dodge divide by zero error. |
| 1766 | return proximity == 0 ? accuracy : 1.0; |
| 1767 | } |
| 1768 | return accuracy + (proximity / static_cast<float> (Match_Distance)); |
| 1769 | } |
| 1770 | |
| 1771 | /** |
| 1772 | * Initialise the alphabet for the Bitap algorithm. |