mhwgoo / cambridge

Terminal version of Cambridge Dictionary by default. Also supports Merrian-Webster Dictionary.
GNU General Public License v3.0
51 stars 6 forks source link

Fail in case of word not found #6

Open ghost opened 1 year ago

ghost commented 1 year ago

Current in case the word is not found, cambridge asks the user to select a similar word that is present in the dictionary.

I'm basic building a GUI around cambridge, and I need it to fail and return exit code != 0 in case the word is not found, without asking the user.

Otherwise my GUI will hang waiting for cambridge to exit.

mhwgoo commented 1 year ago

Hi. Actually I didn't intend this project to be used as a library since its data is scraped.

However, I still added a new parameter no_suggestions to the functions search_webster and search_cambridge for your convenience. If you don't want spell suggestions, just pass these two functions with no_suggestions as True (False by default). If not found with no_suggestions as True, '-1' will be returned. You can update the package to v3.6.2 to use them.

def search_webster(con, cur, input_word, is_fresh=False, no_suggestions=False) def search_cambridge(con, cur, input_word, is_fresh=False, is_ch=False, no_suggestions=False)

P.S. PLEASE don't use this project for monetary gains because we are not sure if there is legal risks of using scraped data for that purpose. Thank you.