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-6Curriculum Links Assessment
Links with Digital Technologies Curriculum Area.
Define problems in terms of data and functional requirements drawing on previously solved problems (ACTDIP017)
Design a user interface for a digital system (ACTDIP018)
Design, modify and follow simple algorithms involving sequences of steps, branching, and iteration (repetition) (ACTDIP019)
Implement digital solutions as simple visual programs involving branching, iteration (repetition), and user input (ACTDIP020)
Explain how student solutions and existing information systems are sustainable and meet current and future local community needs (ACTDIP021)(ACTDIP021)
Plan, create and communicate ideas and information, including collaboratively online, applying agreed ethical, social and technical protocols (ACTDIP022)
Links with English Curriculum Area.
|Language: Expressing and developing ideas|
Investigate how vocabulary choices, including evaluative language can express shades of meaning, feeling and opinion (ACELA1525)
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?
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.
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?
- 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.
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.
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’.
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.