Code Monkey home page Code Monkey logo

interactive-dictionary-in-python's Introduction

Interactive Dictionary in Python

Create a dictionary in Python which can retrieve definitions for user, ask 'did you mean this instead?' if user made a typo while entering the word, and if the word has more than one definition then retrieve them all.

1. Installing dependencies

Installing dependencies is the first thing you want to do.

import json
import difflib

2. Understanding files in the directory

Data

The data is in .json format. If you are not aware what JSON is and how it works I recommend referring to this article.

dictionary.json

Step by Step Solution

I have created different files for each step in creating the interactive dictionary, here's the description of what each file does.

dictionary_1.py

Load the data, and just check if data loaded correctly.

dictionary_2.py

Check for non-existing words.

dictionary_3.py

Removing the case-sensitivity from the program. For example 'Rain' and 'rain' will give same output.

dictionary_4-1.py
dictionary_4-2.py

Learn how 'difflib' works in order to suggest a similar word.

dictionary_5.py

Use 'difflib' in our code to retrieve closest match

dictionary_6.py

If the suggested word is what user wants, retrive the meaning of suggested word.

dictionary_7.py

If the word has more than 1 definition, retrive all by iterating.

Note: All files are integrated with comments to help you understand each and every line/command of the code.

Run All Together

Even though the dictionary_7.py is the complete file, I made a new copy of that file namely interactive_dictionary.py to serve as a final file.

python3 interactive_dictionary.py

License

This project is licensed under the MIT License - see the LICENSE file for details

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.