Can a computer recognise your sentiment?
About this lesson
This lesson plan enables students to explore how Natural Language Processing (NLP), a subset of Artificial Intelligence (AI), is used to assess and categorise a user’s online comments. (AI is the ability of machines to mimic human capabilities in a way that we would consider 'smart'.)
Year band: 5-6
Curriculum Links AssessmentCurriculum Links
Links with Digital Technologies Curriculum Area.
Year | Content Description |
---|---|
5–6 |
Define problems with given or co-developed design criteria and by creating user stories (AC9TDI6P01) Design algorithms involving multiple alternatives (branching) and iteration (AC9TDI6P02) Implement algorithms as visual programs involving control structures, variables and input (AC9TDI6P05) Select and use appropriate digital tools effectively to create, locate and communicate content, applying common conventions (AC9TDI6P07) Evaluate existing and student solutions against the design criteria and user stories and their broader community impact (AC9TDI6P06) |
Links with English Curriculum Area.
Year | Content Description |
---|---|
Language: Expressing and developing ideas | |
5–6 |
Investigate how vocabulary choices, including evaluative language can express shades of meaning, feeling and opinion (ACELA1525) |
Assessment
Teacher assessment
Choose the task that will best suit your students from these suggested assessment approaches.
Suggested approaches and tasks | Relevant content description(s) |
---|---|
Describe the data required and stored in a program that is used to classify user sentiment. |
|
Explain how your program works that classifies user sentiment. Describe any limitations of the programming.
|
|
This type of AI uses text recognition. How is this type of AI used in our daily lives? List some examples. How would you prefer this type of AI be used? What issues might arise? |
Suggested steps
Unplugged activity
This task explores systems that use NLP to classify a reviewer’s online text as positive, neutral or negative, based on words that might appear in the text. This is often referred to as ‘sentiment analysis’.
- Provide a range of online reviews for students to view and decide if they are positive, neutral or negative. What words provide students with that overall impression?
- Provide students with the worksheet, Positive, neutral or negative.
- Task 1 asks the students to classify words as positive, neutral or negative.
- Task 2 asks students to write and share a review, with their partner working out if the overall impression of the review is positive, neutral or negative.
Discussion
Sentiment analyses aren’t always reliable. When training an AI, words and combinations of words would be classified as positive, neutral or negative through the process of supervised learning. Supervised learning is the process of the human providing the program with lots of examples of what it is we are wanting it to identify along with a label.
What combinations of words may produce an inaccurate sentiment analysis?
Answer:
- A negative word combined with a positive word, ie no good, don’t like, not bad, etc.
- A paragraph that contains both positive and negative words.
Plugged activity
Use these suggested activities to explore NLP and sentiment analysis.
The activity has been levelled to enable differentiation.
Book or movie review (skill level: easy)
This task enables students to explore sentiment analysis via an online tool that uses NLP to classify text as positive, neutral or negative, based on words that appear in the text.
- Choose a book or movie you recently read or viewed. Type a brief review into an online sentiment analysis tool.
- Explore, using different combinations of descriptive words, including those in the unplugged task.
- How well did the sentiment analysis tool work?
- Was the categorisation accurate?
Code your own sentiment analysis program (skill level: medium)
In this task, students code their own program using a visual programming language such as Scratch to demonstrate sentiment analysis. The program identifies a word contained in the user’s input (string). If that word is recognised then a particular response is given else provide a generic response. The program incorporates:
- user input, using an ask block
- branching, using if/then/else blocks
- iteration, using a forever block.
- Present students with the challenge of creating a program that classifies a user’s review of something as positive, neutral or negative.
- Discuss possible ways to program a response based on the user’s input text.
One possible solution is as follows:
-
To start the program, use ‘When flag clicked’.
-
Use an ask block to initiate user input.
-
The user’s input is classed as ‘answer’.
-
Show the operator block ‘apple contains a?’
-
Explain how this block can be changed, by adding text, e.g. if the user’s answer contains the word ‘like’.
-
Use the if/then/else block:
If the user’s text contains ‘like’, then use ‘say’ block to say, ‘That is positive’ for ‘2’ seconds:
For else say something generic such as ‘I’m not sure if you liked it or not’. The block would look something like:
-
Repeat the process for a word that is classified as negative language such as ‘hate’. The subsequent if/then/else blocks can each be nested in the previous block’s ‘else’ position.
Image: Screen capture of Scratch program showing nested if/then/else blocks
Remix the existing program
Challenge students to remix the existing Scratch programs provided:
For students with:
- limited programming skills, provide a completed Scratch program to explore: AI sentiment.
- good programming skills, provide an incomplete Scratch program to use: AI sentiment: one response.
- very good programming skills, provide the introductory explanation and let them create their own code and design their own sentiment analysis tool.
- advanced programming skills, two lists separated out, with the program looking for the provided key word in each list (positive or negative).
Students can remix the program and:
- change the items being reviewed by changing the text in the backdrops
- add code blocks to increase the number of words that trigger a sentiment response
- change the keywords that trigger the sentiment response (positive, neutral or negative)
- add a count of the number of positive, neutral or negative responses
- design and create their own program, based on their chosen context.
Discussion
Question: Do you think this simple keyword system is foolproof?
Answer: While this system can make some guesses as to a positive or negative tone, it is not foolproof. For a start, it has a very limited vocabulary, and it does not deal with the use of modifiers like ‘not’ and ‘very’.
Exploring an AI
Refer to the related lesson plan on the topic of Anti-bullying with AI and visit the My computer brain’s anti-bullying experiment to explore the inner workings of the AI for this scenario. It is a useful example to show how an AI can recognise text.
Discussion
Have students share what they have learned about AI and how ‘smart’ a computer can be.
- Look at how the AI tool worked, compared with the program you created in Scratch.
- Could your program be improved to better mimic AI?
- How might companies use sentiment analysis to help them provide a useful service for their customers?
Why is this relevant?
This lesson focuses on:
- text recognition
- text classification.
Algorithms and programming are essential to developing machines powered by AI.
In conventional programming, the computer is provided with a set of instructions for a defined set of scenarios. In this lesson, students hardcode a program that is based on identifying a word contained in the user’s input (string). If that word is recognised, then a particular response is given. Else provides a generic response.
The downside with this programming is that every possible option needs to be hardcoded to ensure the text is correctly categorised. Also, the order that the word appears in the text affects the categorising. In an AI, a similar problem arises. We need to teach the AI each individual word, however the AI is good at solving all sorts of word combinations. So, we really want to point out that the conventional programming method struggles with the myriad of possible word combinations. An AI-based tool using NLP is better able to provide a correct categorisation as it has been trained on large amounts of data.
Resources
- AI tool: sentiment analysis tool.
- Visual programming environment: Scratch 3.0
- My computer brain's anti-bullying