Skip to main content
Version: 0.18.0

withText

production

Filters for similar -- meaning >70% similar -- text.

Takes an optional parameter to specify the similarity. Usually you need the optional parameter for long texts you want to match precisely.

We use RapidFuzz which calculates the similarity like this:

1 - (distance / (lengthString1 + lengthString2))

Examples:

'text' === withText('text') => true
'test' === withText('text') => true
'Test' === withText('text') => true
'Text' === withText('text') => true
'TEXT' === withText('text') => true
'texst' === withText('text') => true
'texts' === withText('text') => true

'atebxtc' === withText('text') => false
'other' === withText('text') => false

// optional parameter: similarity_score
'978-0-201-00650-6' == withText("978-0-201-00", 90) => false with 82.76 < 90 similarity
'978-0-201-00650-6' == withText("978-0-201-00650", 90) => true with 93.75 > 90 similarity

  • @param {string} text - A text to be matched.