andylokandy / simsearch-rs

A simple and lightweight fuzzy search engine that works in memory, searching for similar strings (a pun here).
MIT License
167 stars 25 forks source link

strip whitespace from user input in example #3

Closed JoshMcguigan closed 5 years ago

JoshMcguigan commented 5 years ago

The standard behavior of read_line leaves the newline from the user pressing the enter key. This PR strips that newline before performing the search.

andylokandy commented 5 years ago

Thanks! I do have trimed the returns before implementing the tokenizer. With the built-in tokenizer with deafult setting, any whitespaces including \r \n will be removed as stop words. But it's a good practice not to rely on any internal behavior and to always handle the standard input by ourselves.