Text Summariser
In this activity we will look at writing a basic text summariser using JavaScript
The goal of this activity is to create a script which will accept a block of text as input and summarise the text based on our algorithm. The algorithm that we will use to do this is outlined below:
Break our text into sentences
Break out sentences into words
filter out stopwords (a starter list of stopwords will be provided)
normalise the words
remove any punctuation
make everything lowercase
index how many instances of each word we have
iterate through the sentences
assign each sentence a base score according to how early it appears in the text (earlier sentences are weighted higher)
add to the base score according to the cumulative scores of all of the words in the sentence (we will use our index for this)
store the sentence and its score
fetch the 5 highest scoring sentences
display them
This basic algorithm will provide us with a summary of the input text based on how frequently words in the sentence appeared, and how early the sentence occurred.
Let's get started 🚀
Last updated