Skip to content

Latest commit

 

History

History
81 lines (48 loc) · 2.67 KB

File metadata and controls

81 lines (48 loc) · 2.67 KB

Fuzzy Match v0.2.0 Delphi/FreePascal

Delphi/FreePascal implementation of the fts_fuzzy_match algorithm, ported by j.visser and tweaked by @forever-new.

Original code taken from j.visser's public GitHub Gist (commit ebe9842d, 2020-11-02).


Table of Contents


Folder Contents

History

The original port of the algorithm was slightly adapted by j.visser for his own use, especially:

  • Calculation corrected for double byte chars.
  • Added a match index offset of 1 to match Delphi/Pascal string indexes.

@forever-new tweaked the original code to align it with the needs of this project, enforcing the behaviour of the original algorithm, and added the algorithm validation test code, and contributed the changes in PR #19:

  1. Added check for non-uppercaseable characters. e.g. numbers — so 'a4' doesn't get camel case bonus. 2, Removed extra Delphi index pascal_index = 1 — it broke the score calculation in a couple of places.
  2. Removed update for double byte chars — it was causing wrong calculation of unmatched count, and other issues.
  3. Added initialization for internal static array so the output Matches array is not populated with memory garbage.
  4. Set option first_letter_count to 1, to align with other ports.
  5. Added test algorithm.

Usage

Can be used in Delphi, or in FreePascal in Delphi or ObjFPC mode.

fpc -Mdelphi FuzzyScore.pp
FuzzyScore [search string] [ < input ]

License

CC0, Creative Commons Zero, (public domain).