Table of Contents

Virtual Doctor Using Natural Language Processing Extension in PictoBlox

Virtual Doctor Using NLP
Project Description
Learn how to create a virtual doctor using Natural Language Processing (NLP) in PictoBlox. Train the text data for diseases and build a text classifier.

Introduction

You feel a little unwell, who do you tell your symptoms first? (Except for mom.) Google! Yes, you google the symptoms, find what is the thing that has made you unwell, and then you move on to find a remedy for the same.

In this project, we are going to make a virtual doctor using the NLP extension. You need to tell your symptoms to him and he will tell you what caught you and what shall you do next.

Wonder how will the virtual doctor figure out the disease as many have a couple of symptoms same. Using NLP!

So let’s begin by understanding what NLP is.

What is NLP?

NLP stands for Natural Language Processing.

This is the area of AI concerned with the interaction between computers and humans in natural language. The aim of this extension is to help computers understand language as well as we do.

Along with the NLP Extension, there are a lot of new features added to the latest version of PictoBlox. You may need to download PictoBlox or update it to use the latest features.

Setting the Stage for the Virtual Doctor

Open PictoBlox.

Let’s begin by setting up the stage.

  1. Delete Tobi’s Sprite.
  2. Click on Upload Sprite Button and upload the Doctor Sprite.Doctor Sprite
  3. Go to the Backdrop Palette, add the Blue Sky backdrop from the library.
  4. To get the hospital on the stage, Upload the image of hospital as the backdrop.Hospital Sprite
  5. You may find the one backdrop of Blue Sky and one of the hospital. Copy the hospital image and then paste it into the backdrop of Blue Sky.
  6. Adjust the placement of the hospital and doctor according to your choice.
  7. The final stage will look like this:Setting the stage for Virtual Doctor

 You can download the sprites of doctor and hospital from here.

Training the Text Classifier

Now that we have set the stage. Let’s begin by training the text data for diseases. We need to train PictoBlox to analyze the text and perform the corresponding action.

Add text data in classes

We will first add data i.e the symptoms for three diseases, COVID-19, Malaria, and Diabetes one-by-one.

  1. Go to the My Blocks palette and create a block named Data for COVID-19.Text Classifier
  2. To make the text classifier, we need the Natural Language Processing extension. Add the Natural Language Processing extension from the extension library.
  3. Take the Data for COVID-19 hat block and drop an add () as () block below it.
  4. In place of text in the add () as () block, write the first command, “Dry Cough”. In place of class, write “COVID-19”. COVID-19 will be the name of the class.text classifier
  5. We’re going to give the classifier three more symptoms to add to our class. You can add many as you may find. Duplicate the add () as () block and write the rest of the symptoms in them.text classifier
  6. Now, we similarly need to add text training blocks for the other two diseases too.text classifiertext classifier

Training the Classifier

Now that we have added data in classes, we need to train our classifier.

  1. Create a block named Train Data.
  2. Take the Train Data hat block and add a reset text classifier block below it from the Natural Language Processing palette.reset text classifier block in NLP
  3. Add the Data for COVID-19, Data for Malaria, and Data for Diabetes stack blocks one after the other.
  4. Add a train text classifier block.Train text classifier block
  5. The script will look like this:Training Classifier using NLP

With this our text classifier for our virtual doctor is trained, it’s time to bring it into action.

Final Script for the Virtual Doctor Using NLP

Let’s begin to write the script that to make the virtual doctor say the name of the disease we have after we tell him our symptoms.

  1. Add a when flag clicked hat block to run the script when the green flag is clicked.        
  2. Drop the Train Data stack block below it.script for virtual doctor using NLP
  3. Let’s make the doctor greet us. Add a say () for () seconds block from the Looks palette. Write “Hello! Welcome to the virtual hospital” in the first space given.
  4. Next, we’ll want the doctor to ask the symptoms, thus from the Operators palette, add a ask () and wait block. Write “How are you feeling today? Please tell me your symptoms.” in the space given.Virtual doctor using NLP
  5. Here is when we will write the symptoms and the doctor will tell us the remedies for the same. Place an if () block into the scripting area.
  6. Add an () = () block from the Operator palette.
  7. Inside the first space of the () = () block, drop a get class of () block. In the second space, write “COVID-19”.Get class of block
  8. Inside the get class of () block, drop a answer block from the Sensing palette.
  9. This will check the symptoms you enter with the text data, and if they match with COVID class, the doctor will say out the disease as COVID-19.
  10. Into the if () arm place a say () for () seconds block.matching the symptom entered by patient with the train data
  11. Place join () () block from the Operator palette.
  12. Write “You are infected with  ” in the first space. Add another join block in the second space. Drop a get class of () block into the first space of the second join block and write “.” to complete the statement in the second space. Inside the get class of () block, drop an answer block from the Sensing palette.Diagonising the dieases
  13. Now that we got to know the disease, doctor will say the remedy for the same. Place a say () for () seconds block from the Looks Palette and write the remedies into it. If you need to write more remedies, you can use another say block too.COVID diagonized and remedy
  14. With this diagnosis of COVID is done, we will now follow similar steps for Malaria and Diabetes. Duplicate the if block and make the changes respectively. Malaria diagonized and remedyDiabetesdiagonized and remedy
  15. With this our script is complete. Virtual doctor using NLP in PictoBlox

Press the green flag to start the script.

Conclusion

This project demonstrated how to create a virtual doctor using the NLP extension in PictoBlox. We used the Natural Language Processing (NLP) extension to train the text classifier by creating a data set of symptoms and the corresponding diseases. After training, we wrote the script that interacts with the user and gives them the diagnosis of their symptomatic input. The script facilitates the interaction between the user and the virtual doctor.

Project Downloads - Code and Files

Explore Related Projects by STEMpedia

Learn how to make a self-driving car using PictoBlox and the Recognition Card Extension. Create a stage resembling a street and program John the instructor to guide the user through selecting lanes and recognizing number cards.
Learn how to make a face recognition-based attendance system using micro: bit in PictoBlox AI. Track attendance by scanning faces and storing data in Excel.
Learn how to make a touch-free security system based on face recognition technology that unlocks a door if it matches your face using PictoBlox.

Explore Community Projects