EssayTools - Maple Help

 Essay Tools

Maple 17 includes a new package for linguistic analysis and grading of essays. The ability for a computer to successfully grade essays is inherently mathematical. Given a set of essays that have already been graded by hand, the computer looks for patterns in the essays and tries to weight them according to the given scores. Things like key words, sentence structure, length, and variation of words tend to have a significant correlation to good or bad scores. Maple's scoring model can pick from up to 20 algorithms, each measuring dozens of properties to formulate a model that can be used to predict scores for new essays. 

The EssayTools package contains functions for:

 • Plagiarism detection and similarity comparisons
 • Analysis of English word forms and sentence reduction
 • Checking spelling

The grading commands are best used in an advisory capacity. They are great for giving insight into student responses for homework and practice. They are also effective as a double-check in high-stakes testing where many markers are utilized. For example, any essay where the human score disagrees with the computer score by more than one or two points could be flagged and re-graded by an independent human.

To get good predictions it is best to seed your model with hundreds of scored essays. The more the better. For the purposes of this overview, we will use examples that have insufficient data in order to illustrate the form of the commands as well as some of the pitfalls and limitations of technology like this.

Consider a wide open short-answer question like "Why is the sky blue?". Gather several responses and put them in an array. Here, we call the array Answers. Provide a second array with a grade for each of the answers. In this example, we call the second array Scores. In practice, these responses and grades could be read in from a .csv file using one of the ImportVector or ExcelTools:-Import commands.

 > with(EssayTools);
 $\left[{\mathrm{AppendToWordList}}{,}{\mathrm{BinaryCosineCoefficient}}{,}{\mathrm{BinaryDiceCoefficient}}{,}{\mathrm{BinaryJaccardCoefficient}}{,}{\mathrm{BuildScoreModel}}{,}{\mathrm{CosineCoefficient}}{,}{\mathrm{CountMisspellings}}{,}{\mathrm{CountUseOfAllWords}}{,}{\mathrm{CountUseOfEachWord}}{,}{\mathrm{DetectPlagiarism}}{,}{\mathrm{DiceCoefficient}}{,}{\mathrm{IsAdjective}}{,}{\mathrm{IsAdverb}}{,}{\mathrm{IsConjunction}}{,}{\mathrm{IsDefiniteArticle}}{,}{\mathrm{IsIndefiniteArticle}}{,}{\mathrm{IsInterjection}}{,}{\mathrm{IsIntransitiveVerb}}{,}{\mathrm{IsNominative}}{,}{\mathrm{IsNoun}}{,}{\mathrm{IsNounPhrase}}{,}{\mathrm{IsPlural}}{,}{\mathrm{IsPreposition}}{,}{\mathrm{IsPronoun}}{,}{\mathrm{IsTransitiveVerb}}{,}{\mathrm{IsUsuallyParticipleVerb}}{,}{\mathrm{IsVerb}}{,}{\mathrm{JaccardCoefficient}}{,}{\mathrm{Lemma}}{,}{\mathrm{Misspellings}}{,}{\mathrm{PartOfSpeech}}{,}{\mathrm{QuadraticWeightedKappa}}{,}{\mathrm{Reduce}}{,}{\mathrm{Score}}{,}{\mathrm{SetWordList}}{,}{\mathrm{SimilarityScore}}{,}{\mathrm{SpellCorrectWord}}{,}{\mathrm{WordUse}}\right]$ (1)
 > Question := "Why is the sky blue?":
 > Answers := Array(): Scores := Array():
 > Answers(1) := "The blue color of the sky is due to Rayleigh scattering. As light moves through the atmosphere, most of the longer wavelengths pass straight through. Little of the red, orange and yellow light is affected by the air. However, much of the shorter wavelength light is absorbed by the gas molecules. The absorbed blue light is then radiated in different directions. It gets scattered all around the sky. Whichever direction you look, some of this scattered blue light reaches you. Since you see the blue light from everywhere overhead, the sky looks blue. ":
 > Answers(2) := "Sunlight reaches Earth's atmosphere and is scattered in all directions by all the gases and particles in the air. Blue light is scattered in all directions by the tiny molecules of air in Earth's atmosphere. Blue is scattered more than other colors because it travels as shorter, smaller waves. This is why we see a blue sky most of the time.":
 > Scores(2) := 10: #spaceplace.nasa.gov/blue-sky
 > Answers(3) := "A clear cloudless day-time sky is blue because molecules in the air scatter blue light from the sun more than they scatter red light.":
 > Scores(3) := 8: #math.ucr.edu/home/baez/physics/General/BlueSky/blue_sky.html
 > Answers(4) := "The blue color of the sky is due to Rayleigh scattering. As light moves through the atmosphere, most of the longer wavelengths pass straight through. Little of the red, orange and yellow light is affected by the air.  However, much of the shorter wavelength light is absorbed by the gas molecules. The absorbed blue light is then radiated in different directions. It gets scattered all around the sky. Whichever direction you look, some of this scattered blue light reaches you. Since you see the blue light from everywhere overhead, the sky looks blue.":
 > Answers(5) := "Sunlight is a mix of all the colours of the rainbow. Light is a spectrum of light of different wavelengths, from the shorter blue to the longer red  wavelengths.  When sunlight enters the atmosphere, the molecules in the air are the right size to scatter the blue wavelengths of the sunlight, which sort of paints the sky blue.":
 > Answers(6) := "Blue light is scattered by the air molecules in the atmosphere (referred to as Rayleigh scattering). The blue wavelength is scattered more, because the scatteing effect increases with the inverse of the fourth power of the incident wavelength. ":
 > Answers(7) := "The sky is blue because of a reflection of the sea.":
 > Scores(7) := 0:
 > Answers(8) := "The sky is blue because the sun is yellow and the grass is green. Yellow and green make blue.":
 > Scores(8) := 0:
 > Answers(9) := "These days, the atmosphere is mostly nitrogen and oxygen. Sunlight is made up of all the colors of the rainbow (as well as many wavelengths we can't see); as it jostles through air molecules, blue light is most efficiently reflected, so our eyes end up experiencing a beautiful azure shade":
 > Scores(9) := 10: #news.discovery.com/earth/no-seriously-why-is-the-sky-blue.html

Use the BuildScoreModel command from the EssayTools package to generate a model.



 > model := BuildScoreModel(Answers, Scores, questionText = Question);
 ${\mathrm{model}}{:=}\left[\begin{array}{c}{\mathrm{Scoring Model}}\\ {\mathrm{9 Responses}}\end{array}\right]$ (2)



This model could be saved, for example, by calling LibraryTools:-Save(model,"blue_sky.mla");. Later, when you have more responses, you can just point libname := libname, "blue_sky.mla"; and the variable, model, will implicitly be available for use.



Now, let's examine a previously unseen response:



 > NewResponse := "Blue and violet wavelengths, on the other hand, are absorbed by the gas molecules and scattered across the sky. Your eye sees these reflected wavelengths as blue.": #wonderopolis.org/wonder/why-is-the-sky-blue/
 > Score(NewResponse,model);
 ${7}$ (3)

Other EssayTools commands can be used to get an idea of what goes on behind the scenes. First, let's look at the words that occur with high frequency in the model answers.



 > WordUse(Answers, showcount, mincount = 3);
 $\left[{"the"}{=}{56}{,}{"of"}{=}{24}{,}{"blue"}{=}{24}{,}{"is"}{=}{24}{,}{"light"}{=}{19}{,}{"sky"}{=}{11}{,}{"in"}{=}{9}{,}{"scattered"}{=}{9}{,}{"air"}{=}{8}{,}{"as"}{=}{7}{,}{"atmosphere"}{=}{7}{,}{"all"}{=}{7}{,}{"and"}{=}{7}{,}{"molecules"}{=}{7}{,}{"by"}{=}{7}{,}{"wavelengths"}{=}{6}{,}{"a"}{=}{6}{,}{"you"}{=}{6}{,}{"through"}{=}{5}{,}{"sunlight"}{=}{5}{,}{"because"}{=}{5}{,}{"to"}{=}{5}{,}{"see"}{=}{4}{,}{"it"}{=}{4}{,}{"shorter"}{=}{4}{,}{"from"}{=}{4}{,}{"most"}{=}{4}{,}{"wavelength"}{=}{4}{,}{"yellow"}{=}{4}{,}{"absorbed"}{=}{4}{,}{"directions"}{=}{4}{,}{"red"}{=}{4}{,}{"reaches"}{=}{3}{,}{"scattering"}{=}{3}{,}{"this"}{=}{3}{,}{"longer"}{=}{3}{,}{"more"}{=}{3}{,}{"scatter"}{=}{3}{,}{"rayleigh"}{=}{3}{,}{"different"}{=}{3}\right]$ (4)



Let's use some of these high-frequency words to form nonsense answers.



 > Score("The is of blue light sky in scattered air.", model);
 ${5}$ (5)
 > Score("Blue light sky scattered air molecules.", model);
 ${6}$ (6)

This model gives a disproportionate weight to the use of the word, "molecules", which always appears in good answers, but does not appear in low-scoring answers. This emphasizes the need to have a large sample of data to build the model with.



Reduction techniques can be used to simplify the essay by dropping unimportant words, coalescing words with similar meaning, and splitting the response into smaller idea-phrases.



 > ModifiedResponse := Reduce(NewResponse);
 ${\mathrm{ModifiedResponse}}{:=}\left[{"blue violet wavelength hand be absorbed gas molecule scatter sky"}{,}{"eye see reflected wavelength blue"}\right]$ (7)



An important tool in this process is the use of word lemmas.



 > Lemma("is");
 ${"be"}$ (8)
 > Lemma("are");
 ${"be"}$ (9)
 > Lemma("flew");
 ${"fly"}$ (10)
 > Lemma("flies");
 ${"fly"}$ (11)

Knowing where to split a sentence requires that each sub-part usually have at least a noun and verb, and be split at a conjunction.



 > TwoIdeas := "the sky is blue because it scatters sunlight.";
 ${\mathrm{TwoIdeas}}{:=}{"the sky is blue because it scatters sunlight."}$ (12)
 > map(PartOfSpeech, StringTools:-Words(TwoIdeas));
 $\left[\left[{"Definite Article"}{,}{"Adverb"}\right]{,}\left[{"Noun"}{,}{"Verb \left(usually participle\right)"}\right]{,}\left[{"Verb \left(usually participle\right)"}\right]{,}\left[{"Noun"}{,}{"Adjective"}{,}{"Verb \left(usually participle\right)"}\right]{,}\left[{"Conjunction"}\right]{,}\left[{"Pronoun"}{,}{"Noun"}\right]{,}{\mathrm{FAIL}}{,}\left[{"Noun"}\right]\right]$ (13)



Part-of-speech information is not available for all words; as you can see, "scatters" is not known and returns FAIL. The Reduce command will attempt to use the Lemma command to get the root word.

 > Lemma("scatters");
 ${"scatter"}$ (14)
 > PartOfSpeech(%);
 $\left[{"Verb \left(transitive\right)"}{,}{"Noun"}{,}{"Verb \left(usually participle\right)"}\right]$ (15)
 > Reduce(TwoIdeas);
 $\left[{"sky be blue"}{,}{"sky scatter sunlight"}\right]$ (16)

Another technique for scoring essays is to find the most similar essay or essays in the model set. There are many ways to compute similarity scores.



 $\left[\begin{array}{ccccccccc}{0.1818181818}& {0.2200000000}& {0.1621621622}& {0.1818181818}& {0.1489361702}& {0.1666666667}& {0.1428571429}& {0.1666666667}& {0.1851851852}\end{array}\right]$ (17)



According to the default similarity metric, BinaryJaccardCoefficient, the second essay is most similar, receiving a score of .22.



 > SimilarityScore(NewResponse, Answers, methods = [CosineCoefficient]);
 $\left[\begin{array}{ccccccccc}{0.5687043153}& {0.5075459214}& {0.4181210050}& {0.5687043153}& {0.5408420486}& {0.5304958918}& {0.3108809143}& {0.5017452060}& {0.4717820977}\end{array}\right]$ (18)
 > SimilarityScore(NewResponse, Answers, methods = [DiceCoefficient]);
 $\left[\begin{array}{ccccccccc}{0.3652694611}& {0.4285714286}& {0.4166666667}& {0.3652694611}& {0.3820224719}& {0.4958677686}& {0.2692307692}& {0.5000000000}& {0.4504504505}\end{array}\right]$ (19)

The CosineCoefficient  metric instead picks answers one and four; while the DiceCoefficient metric picks essay eight. Each of these metrics, and their binary counterparts, measure similarity in a different way.

When a similarity score exceeds a certain minimum, it indicates that there is a good chance those essays are copies of each other in part or in whole.

 $\left[\left[{1}{,}{4}{,}{1.}\right]{,}\left[{7}{,}{8}{,}{0.3529411765}\right]\right]$ (20)

The DetectPlagiarism command compares all given essays with each other and flags those that exceed a minimum similarity score. In this case we see that essays 1 and 4 are certainly copies of each other, as indicated by a similarity score of 1. Essays 7 and 8 are flagged as possible copies since they are both short, and start with exactly the same 5 words.