JamesBrill / react-speech-recognition

💬Speech recognition for your React app
https://webspeechrecognition.com/
MIT License
657 stars 119 forks source link

String-Similarity-Commands - Added string similarity check on the com… #47

Closed urbanL1fe closed 4 years ago

urbanL1fe commented 4 years ago

…mands API

I implemented the fuzzy matching within the commands api as discussed in this pull request.

I wondered how to handle the cases where isFuzzyMatch is true but the api user passes a regex or a string with special characters as the command. At first, for the 'string with special characters' case i thought that we should maybe do a fuzzy match check against the predefined or the variable part of the command but both seemed confusing for the user and probably not really helpful. Then i tried to decide the way that we will ignore these cases and i chose to convert regex to string and string with special characters to string without them. The other way to handle these would probably be to act like isFuzzyMatch is false for these cases but i decided against because the user has explicitly set it to true.

Is that what you had in mind? I am open, of course, for changes and proposals.

soesujith commented 4 years ago

I had made a minor change locally in the command to pass the regex expression object itself. commandToRegExp() is only called if command is not IsRegEx().

JamesBrill commented 4 years ago

👏 Excellent change! Yes, this is exactly what I had in mind.

One request before we merge this: can you document this new feature in the Commands section of the README? It doesn't need to be perfect - I can tweak the README after merging this PR if needed. A few things worth emphasising in the README:

urbanL1fe commented 4 years ago

Since english is not my native language there may be some errors. Your advice about what i need to emphasise help a lot though.

urbanL1fe commented 4 years ago

It was interesting for sure. If it needs any changes or you have any new features in mind i ll be happy to contribute

JamesBrill commented 4 years ago

@urbanL1fe Fuzzy matching is now live on npm in version 3.1.0