Fuzzy Search for better results

Topic: 
|
2 min read
Media contact: Cognigy July 2, 2019

Humans tend to be imprecise in what they say and write: Incomplete utterances, ambiguities and typos are just a few challenges for Conversational AIs. You can compensate for these issues by searching a list of items using Cognigy’s new Fuzzy Search module.

Based on the Apache License open source project Fuse.js, a search can be configured in a couple of ways to improve the result. For instance, the result could include the score for each hit which describes the distance between the search term and the item. Zero means it is a perfect match, while a score of one indicates a complete mismatch. It is worth mentioning, because popular NLUs (Natural Language Understanding) work with probability where the values usually mean the exact opposite.

chat01-1

Fuse.js is a lightweight fuzzy-search. It comes with a convenient live demo website, where you can try out all of the settings.

 

Build fast 

nodessearch01


To perform a fuzzy search, use the “Search” node which provides you with all of the hits in a list of items. Your items can be either simple or complex, but they must be provided in the JavaScript Object Notation (JSON):

[

  {

    "ISBN": "A",

    "title": "Old Man's War",

    "author": "John Scalzi"

  },

  {

    "ISBN": "B",

    "title": "The Lock Artist",

    "author": "Steve Hamilton"

  }

]

You can provide parameters (or keys) of the items you would like to consider– among a variety of other settings – inside the options object, which also needs to follow the JavaScript Object Notation:

{

  "keys": [

    "title",

    "author"

  ],

  "includeScore": true

}

nodesettings01-1

Now, you can perform a fuzzy search using the Search-node. This means, the search calculates the distance between the search term and the keys. This allows you to work around common typos and leads to better results. For instance, in this example you can use olt, oldje, olderly, or other misspellings to find the item A.

[

    {

      "item": {

        "ISBN": "A",

        "title": "Old Man's War",

        "author": "John Scalzi"

      },

      "score": 0.4

    }

]

 

Deploy on multiple channels
Once a basic flow has been made, Cognigy.AI’s endpoint connectors can be used to easily make the bot available across a wide-range of channels. An example of this could be Facebook Messenger or Microsoft Teams. Another option would be a Twilio endpoint that allows users to simply call our bot via phone or Amazon Alexa.

 

Give it a try!
Want to take the module for a spin? Check out our Module GitHub Repo. Need more technical information? Have a look at our docs. Ready to give it a go? Contact your Cognigy.AI sales rep or request a demo!