×

Activity Summary

If you’re accessing this activity directly, did you know there are nine other activities in this series up on our website? Check out our AI page to see a breakdown of the activities and our recommended order to complete them in! Also, these activities introduce AI concepts and terminology. If you find yourself unfamiliar with any of the words in this activity, the landing page also has a glossary of AI terms. Happy space-station-fixing!

To recap: You and your group-mates are astronauts and scientists aboard the Actua Orbital Station. Unfortunately, your station just got bombarded by magnetic rays and your electronics have begun to shut down! The only one who can save you is the station’s AI, DANN. DANN stands for Dedicated Actua Neural Network, and it’s gone a little loopy. Brush up on your technical skills, learn about AI, and save yourself and your crewmates!

Congratulations! So far, you have rebooted all of DANN’s communication cores, and now you’ve helped it redevelop a code of ethics in “Ethics in AI: Don’t Let DANN Turn Evil!”. DANN is in pretty good shape, but we aren’t done yet! It needs to be able to communicate with all the other bots on the station to start repairs, and some of them are very broken. Help DANN learn how to communicate properly again, and how to process languages! Once that’s done, we can move on to the very last step: Helping DANN relearn emotions in “Sentiment Analysis: Finding Emotion in Text”.

In this activity, participants will learn about the field of Natural Language Processing, or NLP. They will follow the process of coding a computer program that mimics conversations, known as a chatbot. This activity will explore what goes into the area of translation between human languages and computer languages, and how much effort it takes for a computer to properly understand the complexities of human speech.

Educator’s note: This activity requires some experience with AI concepts, as well as familiarity with coding in Python. It is recommended that you explore our other AI activities before running this one.

Activity Procedure

To Do in Advance

  • Ensure that participants have Gmail accounts that allow for the use of Google Colaboratory. Some organizations don’t have access to it. If necessary, create a temporary gmail address that all participants can log into to use Google Colaboratory.

Opening Hook & Introduction

  1. Begin the activity by watching this video about natural language processing. The video is a 3-minute long animated clip about how Natural Language Processing works, and how it can be applied to the real world.
  2. Reflect on the video and the following questions, for no more than 3 or 4 minutes.

Q: What is Natural Language Processing?

A: Natural Language processing, or NLP for short, is the ability of an artificial intelligence to understand human languages. This is difficult for traditional computers, since human languages have a lot of context and double meanings. The ultimate goal of NLP is to create a perfect understanding of communication between humans and computers.

Q: What can it be used for?

A: Like we saw in the video, an artificial intelligence with the capability to sort through text can be helpful in a variety of ways, such as looking through injury reports for specific data. Another use, however, and the one that this activity explores, is creating a “chatbot”.

Q: What is a chatbot?

A: A chatbot is a computer program designed to mimic human conversations. They have come a long way in recent years, but the difference between talking to a chatbot and talking to another human are still pretty clear. Today, participants are going to go through the process of developing their own chatbot!

Building a Chatbot
  1. Open the Google Colaboratory file
    1. Follow the link above to a sheet of encrypted code. At the top of the page, it should say “Open in Google Colaboratory”. Click that button.
    2. The file should open in a large notebook Natural_Language_Processing.ipynb. This is our Colaboratory space!
    3. You can read through the text as normal, and some ‘cells’, or parts of the text, have small play buttons in the top left corners. Click those to run the cell and see what the code does!
    4. Make sure to run the cells in order as instructed by the activity, otherwise there may be some bugs.

There may be some technical difficulties opening it, so allow for a few minutes before every participant has it. Afterwards, participants can follow along with the Colab file for the majority of the activity as it guides them through the process of making a chatbot.

 

Appendix A: Background Information  

Natural Language Processing

Natural language processing (NLP) is how AI makes sense of human languages. Digital assistants, such as Google Assistant, Amazon Alexa, or Microsoft Cortana, rely on NLP to understand what we’re asking them to do and to provide us with feedback when they accomplish a task. Humans have a well-developed capacity for understanding and communicating with each other (even when we don’t share a common language!) and “reading between the lines”, but computers tend not to be as flexible, expecting well-structured inputs and clear instructions.

Computers don’t think in natural languages (like, for example, English and French) which makes it hard for them to understand if we try to communicate with them as we do our fellow human beings. The goal of NLP is to bridge the communication gap between humans and computers (and by extension, AI), by developing methods for computers to understand and learn from human languages as well as to help computers communicate with us in ways that we can easily understand.

YouTube: The Basis of Natural Language Processing

Chatterbot

In computer science, a library is a resource that can be used to help develop your code. It can make things easier for you by already having a lot of functionality built in. ChatterBot is a Python-specific library.

As described on ChatterBot’s website:

ChatterBot makes it easy to generate automated responses to a user’s input. ChatterBot uses a selection of machine learning algorithms to produce different types of responses. This makes it easy for developers to create chat bots and automate conversations with users. The language independent design of ChatterBot allows it to be trained to speak any language. Additionally, the machine-learning nature of ChatterBot allows an agent instance to improve its own knowledge of possible responses as it interacts with humans and other sources of informative data. ChatterBot is a Python library designed to make it easy to create software that can engage in conversation. An untrained instance of ChatterBot starts off with no knowledge of how to communicate. Each time a user enters a statement, the library saves the text that they entered and the text that the statement was in response to. As ChatterBot receives more input, the number of responses that it can reply with and the accuracy of each response in relation to the input statement increases. The program selects the closest matching response by searching for the closest matching known statement that matches the input. It then chooses a response from the selection of known responses to that statement.

 

Appendix B: Province/Territory Curriculum Links

Grade 10- Introduction to ComputerStudies(ISC2O)

Describe Fundamental Programming Concepts and Constructs(B1):

  • Participants will learn programming terminology and concepts, will learn about types of data, boolean operators and be able to define variables.

Grade 10- Introduction to ComputerStudies(ISC2O)

Describe Fundamental Programming Concepts and Constructs(B1):

  • Participants will learn programming terminology and concepts, will learn about types of data, boolean operators and be able to define variables.
    • Specifically participants will learn the terminology and concepts involving for loops, and variables.
    • There will be an explanation about how the computer can process and store text via database files and json files.

Plan and Write Simple Programs Using Fundamental Programming Concepts(B2):

  • Uses the IPO process, variables, expressions and assignment statements and loops
    • This project is centered around providing an input, reading how the computer is processing that data and why it prints out the output that it does. 
    • There is a decision structure that chooses between many options before deciding what the correct output is. 
    • Expressions and assignment statements are used for designations and data manipulation.
    • For loops are used in the advanced activity.

Describe Postsecondary Education and Career Prospects Related to Computer Studies(C4):

  • During the debrief of this project participants will explore how this relates to the real world not just in computer science but in non traditional computer related fields that technology is now branching into.

Grade 11- Introduction to ComputerStudies(ICS3C)

Demonstrate the Ability To Use Different Data Types In Expressions In Simple Computer Programs(A1)

  • In this project students use data types and expressions to achieve their goals and in doing so cover boolean and arithmetic operators.
    • Variables and strings are used in this project.
    • This project also delves into string manipulation by splitting the string into an array of tokens and analysing them to determine the output. 
    • Assignment statements are implemented correctly through updated variables and not reassigning them. 

Demonstrate The Ability To Use Control Structures and Simple Algorithms in Computer Programs(A2)

  • This project involves an extensive amount of user input and output and a complicated processing layer
  • There is a repetition control structure in the way the data is saved and processed. The more something is repeated, the stronger the bot will be in its convictions of that statement. 

Demonstrate the ability to use subprograms within computer programs(A3)

  • This project uses subprograms from the chatterbot library that is imported.

Design Software Solutions To Meet A Variety Of Challenges(B2)

  • Participants will touch on this part of the curriculum by using the skeleton template provided. This shows how there is a standard to be met and how to build upon it. 

Grade 11- Introduction to ComputerStudies(ICS3U)

Demonstrate The Ability To Use Different Data Types, Including One-dimensional Arrays, In Computer Programs(A1)

  • In this project students use data types and expressions to achieve their goals and in doing so cover boolean and arithmetic operators. They will also get first hand experience with 1D arrays.
    • Variables and strings are used in this project.
    • This project also delves into string manipulation by splitting the string into an array of tokens and analysing them to determine the output. 
    • Assignment statements are implemented correctly through updated variables and not reassigning them. 

Demonstrate the ability to use control structures and simple algorithms in computer programs(A2)

  • This project involves an extensive amount of user input and output and a complicated processing layer
  • There is a repetition control structure in the way the data is saved and processed. The more something is repeated, the stronger the bot will be in its convictions of that statement. 

Demonstrate the ability to use subprograms within computer programs(A3)

  • This project uses subprograms from the chatterbot library that is imported.

Design Software Solutions To Meet A Variety Of Challenges, Using A Set of Standards(B2)

  • Participants will touch on this part of the curriculum by using the skeleton template provided. This shows how there is a standard to be met and how to build upon it. 

Downloads

This website uses cookies to ensure you get the best user experience. By continuing to use this website, you consent to our use of cookies.
Accept