<?xml version="1.0"?><!DOCTYPE article SYSTEM "/project/take/software/searchbench_offline_processing/paperxml_generator/aclextractor/src/python/../resource/dtd/paperxml.dtd"><article><header><firstpageheader><page local="1" global="1241"/><title>Real-Word Spelling Correction using Google Web 1T 3-grams</title><author surname="Islam" givenname="Aminul"><org  name="University of Ottawa" country="Canada" city="Ottawa"/></author><author surname="Inkpen" givenname="Diana"><org  name="University of Ottawa" country="Canada" city="Ottawa"/></author></firstpageheader><frontmatter><p><b>Real-Word Spelling Correction using Google Web IT 3-grams</b></p><p><b>Aminul Islam</b></p><p>Department of Computer Science</p><p>University of Ottawa Ottawa, ON, KIN 6N5, Canada</p><p>mdislam@site.uottawa.ca</p><p><b>Diana Inkpen</b></p><p>diana@site.uottawa.ca</p></frontmatter><abstract>We present a method for detecting and correcting multiple real-word spelling er­rors using the Google Web IT 3-gram data set and a normalized and modified ver­sion of the Longest Common Subsequence (LCS) string matching algorithm. Our method is focused mainly on how to im­prove the detection recall (the fraction of errors correctly detected) and the correc­tion recall (the fraction of errors correctly amended), while keeping the respective precisions (the fraction of detections or amendments that are correct) as high as possible. Evaluation results on a standard data set show that our method outperforms two other methods on the same task. </abstract></header><body><section number="1" title="Introduction"><p>Real-word spelling errors are words in a text that occur when a user mistakenly types a correctly spelled word when another was intended. Errors of this type may be caused by the writer's igno­rance of the correct spelling of the intended word or by typing mistakes. Such errors generally go unnoticed by most spellcheckers as they deal with words in isolation, accepting them as correct if they are found in the dictionary, and flagging them as errors if they are not. This approach would be sufficient to detect the non-word error <i>myss </i>in "It doesn't know what the <i>myss </i>is all about." but not the real-word error <i>muss </i>in "It doesn't know what the <i>muss </i>is all about." To detect the latter, the spell-checker needs to make use of the sur­rounding context such as, in this case, to recog­nise that <i>fuss </i>is more likely to occur than <i>muss </i>in the context of <i>all about. </i>Ironically, errors of this type may even be caused by spelling checkers in the correction of non-word spelling errors when the <i>auto-correct </i>feature in some word-processing software sometimes silently change a non-word to the wrong real word (Hirst and Budanitsky, 2005), and sometimes when correcting a flagged error, the user accidentally make a wrong selection from the choices offered (Wilcox-O'Hearn et al., 2008).</p><p>An extensive review of real-word spelling cor­rection is given in (Pedler, 2007; Hirst and Budan­itsky, 2005) and the problem of spelling correction more generally is reviewed in (Kukich, 1992).</p><p>The Google Web IT data set (Brants and Franz, 2006), contributed by Google Inc., contains En­glish word n-grams (from unigrams to 5-grams) and their observed frequency counts calculated over 1 trillion words from web page text col­lected by Google in January 2006. The text was tokenised following the Penn Treebank tokenisa-tion, except that hyphenated words, dates, email addresses and URLs are kept as single tokens. The sentence boundaries are marked with two spe­cial tokens &lt;S&gt; and &lt;/S&gt;. Words that occurred fewer than 200 times were replaced with the spe­cial token &lt;UNK&gt;. Table 1 shows the data sizes of the Web IT corpus. The n-grams themselves must appear at least 40 times to be included in the Web IT corpus<footnote anchor="1"/>. It is expected that this data will be useful for statistical language modeling, e.g.,</p><footnote label="1">Details of the Google Web IT data set can be found at www.ldc.upenn.edu/Catalog/docs/LDC2006T13/readme.txt</footnote><doubt alpha="0.0" length="4" tooSmall="False" monospace="0.0">1241</doubt><p><i>Proceedings of the 2009 Conference on Empirical Methods in Natural Language Processing, </i>pages 1241-1249, Singapore, 6-7 August 2009. ©2009 ACL and AFNLP<page local="2" global="1242"/></p><table class="main" frame="box" rules="all" border="0" regular="False"><tr class="row"><td class="cell"></td><td class="cell"></td><td class="cell"></td><td class="cell"></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>Table 1</p></td><td class="cell"><p>: Google Web IT Data Sizes</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>Number of</p></td><td class="cell"><p>Number</p></td><td class="cell"><p>Size on disk</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p></p></td><td class="cell"><p></p></td><td class="cell"><p>(in KB)</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>Tokens</p></td><td class="cell"><p>1,024,908,267,229</p></td><td class="cell"><p>N/A</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>Sentences</p></td><td class="cell"><p>95,119,665,584</p></td><td class="cell"><p>N/A</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>Unigrams</p></td><td class="cell"><p>13,588,391</p></td><td class="cell"><p>185,569</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>Bigrams</p></td><td class="cell"><p>314,843,401</p></td><td class="cell"><p>5,213,440</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>Trigrams</p></td><td class="cell"><p>977,069,902</p></td><td class="cell"><p>19,978,540</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>4-grams</p></td><td class="cell"><p>1,313,818,354</p></td><td class="cell"><p>32,040,884</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>5-grams</p></td><td class="cell"><p>1,176,470,663</p></td><td class="cell"><p>33,678,504</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"></td><td class="cell"></td><td class="cell"></td><td class="cell"></td></tr></table><p>for machine translation or speech recognition, as well as for other uses.</p><p>In this paper, we present a method for detecting and correcting multiple real-word spelling errors using the Google Web IT 3-gram data set, and a normalized and modified version of the Longest Common Subsequence (LCS) string matching al­gorithm (details are in section 3.1). By <i>multiple </i>er­rors, we mean that if we have <i>n </i>words in the input sentence, then we try to detect and correct at most <i>n-\ </i>errors. We do not try to detect and correct an error, if any, in the first word as it is not compu­tationally feasible to search in the Google Web IT 3-grams while keeping the first word in the 3-gram as a variable. Our intention is to focus on how to improve the detection recall (the fraction of errors correctly detected) or correction recall (the frac­tion of errors correctly amended) while maintain­ing the respective precisions (the fraction of de­tections or amendments that are correct) as high as possible. The reason behind this intention is that if the recall for any method is around 0.5, this means that the method fails to detect or correct around 50 percent of the errors. As a result, we can not com­pletely rely on these type of methods, for that we need some type of human interventions or sugges­tions to detect or correct the rest of the undetected or uncorrected errors. Thus, if we have a method that can detect or correct almost 80 percent of the errors, even generating some extra candidates that are incorrect is more helpful to the human.</p><p>This paper is organized as follow: Section 2 presents a brief overview of the related work. Our proposed method is described in Section 3. Eval­uation and experimental results are discussed in Section 4. We conclude in Section 5.</p></section><section number="2" title="Related Work"><p>Work on real-word spelling correction can roughly be classified into two basic categories: methods based on semantic information or human-made lexical resources, and methods based on machine learning or probability information. Our proposed method falls into the latter category.</p><subsection number="2.1" title="Methods Based on Semantic Information"><p>The 'semantic information' approach first pro­posed by Hirst and St-Onge (1998) and later devel­oped by Hirst and Budanitsky (2005) detected se­mantic anomalies, but was not restricted to check­ing words from predefined confusion sets. This approach was based on the observation that the words that a writer intends are generally seman-tically related to their surrounding words, whereas some types of real-word spelling errors are not, such as (using Hirst and Budanitsky's example), "It is my sincere hole (hope) that you will recover swiftly." Such "malapropisms" cause "a pertur­bation of the cohesion (and coherence) of a text." Hirst and Budanitsky (2005) use semantic distance measures in WordNet (Miller et al., 1993) to de­tect words that are potentially anomalous in con­text - that is, semantically distant from nearby words; if a variation in spelling results in a word that was semantically closer to the context, it is hypothesized that the original word is an error (a "malapropism") and the closer word is its correc­tion.</p></subsection><subsection number="2.2" title="Methods Based on Machine Learning"><p>Machine learning methods are regarded as lexical disambiguation tasks and confusion sets are used to model the ambiguity between words. Normally, the machine learning and statistical approaches rely on pre-defined confusion sets, which are sets (usually pairs) of commonly confounded words, such as <i>{their, there, they're} </i>and <i>{principle, prin­cipal}. </i>The methods learn the characteristics of typical context for each member of the set and de­tect situations in which one member occurs in con­text that is more typical of another. Such meth­ods, therefore, are inherently limited to a set of common, predefined errors, but such errors can in­clude both content and function words. Given an occurrence of one of its confusion set members, the spellchecker's job is to predict which mem­ber of that confusion set is the most appropriate in the context. Golding and Roth (1999), an exam­ple of a machine-learning method, combined the Winnow algorithm with weighted-majority voting, using nearby and adjacent words as features. An­other example of a machine-learning method is that of Carlson etal. (2001).</p></subsection><subsection number="2.3" title="Methods Based on Probability Information"><p>Mays et al. (1991) proposed a statistical method using word-trigram probabilities for detecting and correcting real-word errors without requiring pre­defined confusion sets. In this method, if the trigram-derived probability of an observed sen­tence is lower than that of a sentence obtained by replacing one of the words with a spelling variation, then we hypothesize that the original is an error and the variation is what the user intended.<page local="3" global="1243"/></p><doubt alpha="0.0" length="4" tooSmall="False" monospace="0.0">1242</doubt><p>Wilcox-O'Hearn et al. (2008) analyze the ad­vantages and limitations of Mays et al. (1991)'s method, and present a new evaluation of the al­gorithm, designed so that the results can be com­pared with those of other methods, and then con­struct and evaluate some variations of the algo­rithm that use fixed-length windows. They con­sider a variation of the method that optimizes over relatively short, fixed-length windows instead of over a whole sentence (except in the special case when the sentence is smaller than the window), while respecting sentence boundaries as natural breakpoints. To check the spelling of a span of <i>d </i>words requires a window of length <i>d+4 </i>to ac­commodate all the trigrams that overlap with the words in the span. The smallest possible window is therefore 5 words long, which uses 3 trigrams to optimize only its middle word. They assume that the sentence is bracketed by two <i>BoS </i>and two <i>EoS </i>markers (to accommodate trigrams involving the first two and last two words of the sentence). The window starts with its left-hand edge at the first <i>BoS </i>marker, and the Mays et al. (1991)'s method is run on the words covered by the tri­grams that it contains; the window then moves <i>d </i>words to the right and the process repeats until all the words in the sentence have been checked. As Mays et al. (1991)'s algorithm is run separately in each window, potentially changing a word in each, Wilcox-O'Hearn et al. (2008)'s method as a side-effect also permits multiple corrections in a single sentence.</p><p>Wilcox-O'Hearn et al. (2008) show that the trigram-based real-word spelling-correction method of Mays et al. (1991) is superior in per­formance to the WordNet-based method of Hirst and Budanitsky (2005), even on content words ("malapropisms"), especially when supplied with a realistically large trigram model. Wilcox-O'Hearn et al. (2008) state that their attempts to improve the method with smaller windows and with multiple corrections per sentence were not successful, because of excessive false positives.</p><p>Verberne (2002) proposed a trigram-based method for real-word errors without explicitly us­ing probabilities or even localizing the possible er­ror to a specific word. This method simply as­sumes that any word trigram in the text that is attested in the British National Corpus (Burnard, 2000) is correct, and any unattested trigram is a likely error. When an unattested trigram is ob­served, the method then tries the spelling varia­tions of all words in the trigram to find attested trigrams to present to the user as possible correc­tions. The evaluation of this method was carried out on only 7100 words of the Wall Street Journal corpus, with 31 errors introduced (i.e., one error in every approximately 200 words) obtaining a re­call of 0.33 for correction, a precision of 0.05 and a F-measure of 0.086.</p></subsection></section><section number="3" title="Proposed Method"><p>The proposed method first tries to determine some probable candidates and then finds the best one among the candidates or sorts them based on some weights. We consider a string similarity function and a normalized frequency value function in our method. The following sections present a detailed description of each of these functions followed by the procedure to determine some probable candi­dates along with the procedure to sort the candi­dates.</p><subsection number="3.1" title="Similarity between Two Strings"><p>We use the longest common subsequence (LCS) (Allison and Dix, 1986) measure with some nor­malization and small modifications for our string similarity measure. We use the same three differ­ent modified versions of LCS that we (Islam and Inkpen, 2008) used, along with another modified version of LCS, and then take a weighted sum of these<footnote anchor="2"/>. Kondrak (2005) showed that edit distance and the length of the longest common subsequence are special cases of n-gram distance and similarity, respectively. Melamed (1999) normalized LCS by dividing the length of the longest common subse­quence by the length of the longer string and called it longest common subsequence ratio (LCSR). But LCSR does not take into account the length of the shorter string which sometimes has a significant impact on the similarity score.</p><p>Islam and Inkpen (2008) normalized the <i>longest common subsequence </i>so that it takes into account the length of both the shorter and the longer string and called it <i>normalized longest common subse-</i><page local="4" global="1244"/></p><footnote label="2">We (Islam and Inkpen, 2008) use modified versions be­cause in our experiments we obtained better results (precision and recall) for schema matching on a sample of data than when using the original LCS, or other string similarity mea­sures.</footnote><doubt alpha="0.0" length="4" tooSmall="False" monospace="0.0">1243</doubt><p><i>quence </i>(NLCS) which is:</p><p><i>len(LCS</i><b><i>(si</i></b><i>,Sj</i><b><i>)Y</i></b> <i>len(si) </i>x <i>len(sj)</i></p><doubt alpha="0.0" length="3" tooSmall="False" monospace="0.0">(1)</doubt><p>While in classical LCS, the common subse­quence needs not be consecutive, in spelling cor­rection, a consecutive common subsequence is im­portant for a high degree of matching. We (Is­lam and Inkpen, 2008) used <i>maximal consecutive longest common subsequence </i>starting at charac­ter 1, <i>MCLCS\ </i>and <i>maximal consecutive longest common subsequence </i>starting at any character <i>n, </i><i>MCLCSn. MCLCSi </i>takes two strings as input and returns the shorter string or maximal consec­utive portions of the shorter string that consecu­tively match with the longer string, where match­ing must be from first character (character 1) for both strings. <i>MCLCSn </i>takes two strings as in­put and returns the shorter string or maximal con­secutive portions of the shorter string that con­secutively match with the longer string, where matching may start from any character (char­acter <i>n) </i>for both of the strings. We normal­ized <i>MCLCSi </i>and <i>MCLCSn </i>and called it <i>nor­malized </i><i>MC LCS i (NMCLCSi) </i>and <i>normalized </i><i>MCLCSn (NMCLCSn), </i>respectively.</p><p><i>v2 =NMCLCSi(si</i><i>,Sj)</i></p><p><i>len</i><i>(MCLCSi(si</i><i>,Sj</i><b><i>)Y</i></b></p><doubt alpha="63.2" length="19" tooSmall="False" monospace="0.0">v3=NMCLCSn(si,sj) =</doubt><doubt alpha="61.1" length="18" tooSmall="False" monospace="0.0">len(si)xlen(sj)(3)</doubt><p>Islam and Inkpen (2008) did not consider consecu­tive common subsequences ending at the last char­acter, though <i>MCLCSn </i>sometimes covers this, but not always. We argue that the consecutive common subsequence ending at the last character is as significant as the consecutive common sub­sequence starting at the first character. So, we introduce the <i>maximal consecutive longest com­mon subsequence </i>ending at the last character, <i>MCLCSZ </i>(Algorithm 1). Algorithm 1, takes two strings as input and returns the shorter string or the maximal consecutive portions of the shorter string that consecutively matches with the longer string, where matching must end at the last character for both strings. We normalize <i>MCLCSZ </i>and call it <i>normalized MCLCSZ (NMCLCSZ).</i></p><doubt alpha="63.2" length="19" tooSmall="False" monospace="0.0">v4=NMCLCSz(si,Sj) =</doubt><p><i>len(MCLCS</i><i>z(si,Sj</i><b><i>)Y </i></b><i>len(si) </i>x <i>len(sj) </i>(4)</p><p>We take the weighted sum of these individual values <i>Vi,</i><i> </i><i>V2, </i><i>Vs,</i><i> </i>and <i>V4 </i>to determine string simi­larity score, where <i>a </i><b>1,</b><b> 0:2, 0:3, 0:4 </b>are weights and <i>oti </i><b>+ CK2 + </b><i>as </i><b>+ CK4 </b>= 1. Therefore, the similarity of the two strings, <i>S </i>G [0,1] is:</p><doubt alpha="41.2" length="34" tooSmall="False" monospace="0.0">S(si,sj)= aivi+(12V2+a3v3+ a4v4(5)</doubt><doubt alpha="61.1" length="357" tooSmall="False" monospace="0.0">We heuristically set equal weights for our ex­periments3. Theoretically,v3&gt;V2andvs &gt;V4.To give an example, considerSi= albastruandSj= alabastern,thenLCS(si,Sj)= albastru MCLCSi{si, Sj)= al MCLCSn(si, Sj)= bast MCLCSz{si, Sj)= ru NLCS{si,Sj) =82/(8x 10) = 0.8NMCLCSi{si, Sj) =22/(8x 10) = 0.05NMCLCSn{si,Sj) =42/(8x 10) = 0.2NMCLCSz{si,Sj) =22/(8x 10) = 0.05</doubt><doubt alpha="34.6" length="104" tooSmall="False" monospace="0.0">The string similarity,S=aiVi+a2V2+asVs + a4v4=0.25 x 0.8+ 0.25 x 0.05 + 0.25 x 0.2 + 0.25 x 0.05 = 0.275</doubt></subsection><subsection number="3.2" title="Normalized Frequency Value"><p>We determine the normalized frequency value of each candidate word for a single position with re­spect to all other candidates for the same position. If we find <i>n </i>replacements of a word <i>Wi </i>which are <i>{wn,Wi2,--- </i>&gt; <i>wij&gt; ' ' ' &gt; win}, </i>and their frequen­cies {/a, <i>M, ••• ,fij,-- - , </i><i>fin},</i><i> </i>where <i>fa </i>is the frequency of a 3-gram (where any candidate word <i>Wij </i>is a member of the 3-gram), then we determine the normalized frequency value of any candidate word <i>Wij, </i>represented as <i>F</i><i>(wij) </i>G (0,1], as the frequency of the 3-gram having <i>Wij </i>over the maxi­mum frequency among all the candidate words for that position:</p><doubt alpha="66.7" length="3" tooSmall="False" monospace="0.0">F(w</doubt><doubt alpha="100.0" length="2" tooSmall="False" monospace="0.0">vi</doubt><doubt alpha="40.6" length="32" tooSmall="False" monospace="0.0">Hiax(/ii,fi2,■ ■ ■ ,fa,--- ,fin)</doubt><doubt alpha="0.0" length="3" tooSmall="False" monospace="0.0">(6)</doubt></subsection><subsection number="3.3" title="Determining Candidate Words"><p>Our task is to correct real-word spelling error from an input text using Google Web IT 3-gram data set. Let us consider an input text <i>W </i>which</p><footnote label="3">We use equal weights in several places in this paper in order to keep the system unsupervised. If development data would be available, we could adjust the weights.</footnote><doubt alpha="0.0" length="4" tooSmall="False" monospace="0.0">1244</doubt><p><i>len{MCLCS</i><i>n{si, Sj)f</i><page local="5" global="1245"/></p><p><b>Algorithm 1: </b><i>MCLCSZ</i><i> </i>( Maximal Consec­utive LCS ending at the last character)</p><p><b>input : </b><i>Si,</i><i> </i><i>Sj</i><i> </i><i>/*</i><i> </i><i>Si</i><i> </i>and <i>Sj</i><i> </i>are input strings where <i>\si\</i><i> </i><i>&lt;</i><i> </i><i>\sj\</i><i> */</i></p><p><b>output: </b><i>str</i><i> /* </i><i>str</i><i> </i>is the Maximal Consecutive LCS ending at the last character */</p><subsubsection number="3.3.1" title="Determining Candidate Words for Wi"><doubt alpha="25.0" length="8" tooSmall="False" monospace="0.0">(2 &lt;i&lt;m)</doubt><p>We use the following steps:</p><p>1. We define the term <i>cut</i><i> </i><i>off</i><i> </i><i>frequency</i><i> </i>for word <i>Wi </i>or word <i>Wi+\ </i>as the frequency of the 3-gram <i>Wi-\ </i><i>w% </i>i«i+i in the Google Web IT 3-grams, if the said 3-gram exists. Otherwise, we set the <i>cut</i><i> </i><i>off</i><i> </i><i>frequency</i><i> </i>of <i>Wi</i><i> </i>as 0. The intuition behind using the <i>cut</i><i> </i><i>off</i><i> </i><i>frequency</i><i> </i>is the fact that, if the word is misspelled, then the correct one should have a higher fre­quency than the misspelled one. Thus, using the <i>cut</i><i> </i><i>off</i><i> </i><i>frequency,</i><i> </i>we isolate a large num­ber of candidates that we do not need to pro­cess.</p><p>2. We find all the 3-grams (where only <i>Wi </i>is changed while <i>Wi-\ </i>and <i>Wi+\ </i>are un­changed) having frequency greater than the <i>cut</i><i> </i><i>off</i><i> </i><i>frequency</i><i> </i>of <i>Wi </i>(determined in step 1). Let us consider that we find <i>n </i>replacements of <i>Wi </i>which are <i>R\ = </i><i>{wn,</i><i> </i><i>Wi2, </i><i>■ ■ ■ , Win} </i>and their frequencies <b>^1</b><b> </b><b>=</b><b> </b><i>{hi, fa, </i><i>■■■</i><i> , fin} </i>where <i>hj </i>is the fre­quency of the 3-gram <i>Wi-\ </i><i>w^ </i><i>Wi+\.</i></p><p>3. We determine the <i>cut</i><i> </i><i>off</i><i> </i><i>frequency</i><i> </i>for word <i>Wi-\ </i>or word <i>Wi </i>as the frequency of the 3-gram <i>Wi</i><i>-2 </i><i>Wi-\ Wi </i>in the Google Web IT 3-grams, if the said 3-gram exists. Otherwise, we set the <i>cut</i><i> </i><i>off</i><i> </i><i>frequency</i><i> </i>of <i>Wi </i>as 0.</p><p>4. We find all the 3-grams (where only <i>Wi </i>is changed while <i>Wi</i><i>-2 </i>and <i>Wi-\ </i>are un­changed) having frequency greater than the <i>cut</i><i> </i><i>off</i><i> </i><i>frequency</i><i> </i>of <i>w% </i>(determined in step 3). Let us consider that we find <i>n </i>replacements of <i>Wi </i>which are <i>R2 = </i><i>{wn,</i><i> </i><i>Wi2, </i><i>■ ■ ■ , Win} </i>and their frequencies<page local="6" global="1246"/></p><doubt alpha="0.0" length="4" tooSmall="False" monospace="0.0">1245</doubt><p>We use the following steps:</p><p>2. We find all the 3-grams (where only <i>wm</i>is changed while <i>w</i><i>m-2</i><i> </i>and <i>w</i><i>m-i </i>are un­changed) having frequency greater than the <i>cut off frequency </i>of <i>wm </i>(determined in step 1). Let us consider that we find <i>n </i>replacements of <i>wm </i>which are <i>R2 = </i><i>{wmi,</i><i> w</i><i>m2, </i>• • • , <i>wmn} </i>and their frequencies</p><p><i>F2</i><i> = {fa, fi2, </i><i>• • • , fin} </i>where is the fre­quency of the 3-gram <i>Wi-2 Wi-\ </i><i>w^.</i></p><p>3. For each <i>w</i><i>mj </i>G <i>R2,</i><i> </i>we calculate the string similarity between <i>w</i><i>mj </i>and <i>wm </i>using equa­tion (5) and then assign a weight using the following equation only to the words that re­turn the string similarity value greater than 0.5.</p><doubt alpha="57.6" length="33" tooSmall="False" monospace="0.0">weight =ßS(wi,Wij)+(l—ß)F(wij)(7)</doubt><p>Equation (7) is used to ensure a balanced weight between the string similarity function and the normalized frequency value function where <i>ß </i>refers to how much importance we give to the string similarity function with re­spect to the normalized frequency value func­tion<footnote anchor="5"/>.</p><p>7. We sort the words found in step 5 and in step 6 that were given weights, if any, in descend­ing order by the assigned weights and keep only one word as candidate word<footnote anchor="6"/>.</p></subsubsection><subsubsection number="3.3.2" title="Determining Candidate Words for io 2"><p>1. We determine the <i>cut off frequency </i>for word <i>W2 </i>as the frequency of the 3-gram <i>w</i><i>\W2W^ </i>in the Google Web IT 3-grams, if the said 3-gram exists. Otherwise, we set the <i>cut off frequency </i>of 102 as 0.</p><doubt alpha="65.7" length="289" tooSmall="False" monospace="0.0">2. We find all the 3-grams (where only102is changed whilew\and103are unchanged) having frequency greater than thecut off fre­quencyofW2(determined in step 1). Let us consider that we findnreplacements of102which areR\ ={1021,1022, • • • ,W2n},and their frequenciesF1={/21, /22, • • •,f2n},</doubt><footnote label="5">We give more importance to string similarity function with respect to frequency value function throughout the sec­tion of 'determining candidate words' to have more candidate words so that the chance of including the target word into the set of candidate words gets higher. For this reason, we heuris-tically set ß=0.S5 in equation (7) instead of setting ,9=0.5.</footnote><footnote label="6">Sometimes the top candidate word might be either a plu­ral form or a past participle form of the original word. Or even it might be a high frequency function word (e.g., the). We omit these type of words from the candidacy.</footnote><p>where <i>f2j </i>is the frequency of the 3-gram <i>w\</i></p><p><i>W2j W3.</i></p><doubt alpha="50.0" length="30" tooSmall="False" monospace="0.0">weight =ßS(w2,W2j)+(1—ß)F{w2j)</doubt><p>4. We sort the words found in step 3 that were given weights, if any, in descending order by the assigned weights and keep only one word as candidate word.</p></subsubsection><subsubsection number="3.3.3" title="Determining Candidate Words for w m"><p>1. We determine the <i>cut off frequency </i>for word <i>wm </i>as the frequency of the 3-gram <i>w</i><i>m-2</i><i> </i><i>w</i><i>m-i </i><i>wm </i>in the Google Web IT 3-grams, if the said 3-gram exists. Otherwise, we set the <i>cut off frequency </i>of <i>wm </i>as 0.</p><doubt alpha="61.3" length="31" tooSmall="False" monospace="0.0">F2={fml,fm2,-••,fmn},wherefmjIS</doubt><p>the frequency of the 3-gram <i>w</i><i>m-2</i><i> </i><i>Wm</i><i>-i</i></p><p><i>Wmj.</i></p><doubt alpha="60.0" length="30" tooSmall="False" monospace="0.0">weight =ßS(wm,wmj)+(1-ß)F(wmj)</doubt><p>4. We sort the words found in step 3 that were given weights, if any, in descending order by the assigned weights and keep only one word as the candidate word.</p><doubt alpha="0.0" length="4" tooSmall="False" monospace="0.0">1246</doubt><page local="7" global="1247"/></subsubsection></subsection></section><section number="1" title="str  ^NULL"><doubt alpha="20.0" length="5" tooSmall="False" monospace="0.0">2C&lt;—1</doubt><p><b>3 </b><b>while </b><b>I </b>Si <b>I </b>&gt; c <b>do</b></p><p>4 <i>x</i><i> </i>&lt;— SubStr(Si, <b>— </b>c, 1)      /* returns cth character of <i>Si</i><i> </i>from the end */</p><p>s      <i>y</i><i> </i><i>&lt;—</i><i> </i>SubStr(sj, <b>— </b>c, 1)      /* returns cth character of <i>Sj</i><i> </i>from the end */</p><p>6 <b>if </b><i>x</i><i> </i><i>=</i><i> </i><i>y</i><i> </i><b>then</b></p><doubt alpha="66.7" length="27" tooSmall="False" monospace="0.0">7str&lt;— SubStr(si,—c,c)selse</doubt></section><section number="9" title="return str"><doubt alpha="60.0" length="5" tooSmall="False" monospace="0.0">10end</doubt><p><b>h      </b>increment c <b>i2 </b><b>end</b></p><p>after tokenization<footnote anchor="4"/> has m words, i.e., = <i>{wi,W2, </i>• • •, Our method aims to correct</p><p>m-1 spelling errors, for all m-1 word positions, except for the first word position, as we do not try to correct the first word. We use a slight differ­ent way to correct the first word (i.e., 102) and the last word (i.e., <i>wm) </i>among those m-1 words, than for the rest of the words. First, we discuss how we find the candidates for a word (say <i>Wi, </i>where <i>2&lt;i&lt;m) </i>which is not either <i>W2 </i>or <i>wm. </i>Then, we discuss the procedure to find the candidates for ei­ther <i>W2 </i>or <i>wm. </i>Our method could have worked for the first word too. We did not do it here due</p><footnote label="4">We need to tokenize the input sentence to make the 3-grams formed using the tokens returned after the tokeniza­tion consistent with the Google 3-grams. The input sentence is tokenized in a manner similar to the tokenization of the Wall Street Journal portion of the Penn Treebank. Notable exceptions include the following:</footnote><p>- Hyphenated word are usually separated, and hyphen­ated numbers usually form one token.</p><p>- Sequences of numbers separated by slashes (e.g., in dates) form one token.</p><p>- Sequences that look like urls or email addresses form one token.</p><p>to efficiency reasons. Google 3-grams are sorted based on the first word, then the second word, and so on. Based on this sorting, all Google 3-grams are stored in 97 different files. All the 97 Google 3-gram files could have been needed to access a single word, instead of accessing just one 3-gram file as we do for any other words. This is because when the first word needs to be corrected, it might be in any file among those 97 Google 3-gram files. No error appears in the first position among 1402 inserted malapropisms. The errors start appearing from the second position till the last position.</p></section><section number="4" title="Evaluation and Experimental Results"><p>We used as test data the same data that Wilcox-O'Hearn et al. (2008) used in their evaluation of Mays et al. (1991) method, which in turn was a replication of the data used by Hirst and St-Onge (1998) and Hirst and Budanitsky (2005) to evalu­ate their methods.</p><p>The data consisted of 500 articles (approxi­mately 300,000 words) from the 1987-89 <i>Wall Street Journal </i>corpus, with all headings, identi­fiers, and so on removed; that is, just a long stream of text. It is assumed that this data contains no er­rors; that is, the <i>Wall Street Journal </i>contains no malapropisms or other typos. In fact, a few typos (both non-word and real-word) were noticed dur­ing the evaluation, but they were small in number compared to the size of the text.</p><p>Malapropisms were randomly induced into this text at a frequency of approximately one word in 200. Specifically, any word whose base form was listed as a noun in WordNet (but regardless of whether it was used as a noun in the text; there was no syntactic analysis) was potentially replaced by any spelling variation found in the lexicon of the <i>ispell </i>spelling checker<footnote anchor="7"/>. A <i>spelling variation </i>was defined as any word with an <i>edit distance </i>of 1 from the original word; that is, any single-character in­sertion, deletion, or substitution, or the transposi­tion of two characters, that results in another real word. Thus, none of the induced malapropisms were derived from closed-class words, and none were formed by the insertion or deletion of an apostrophe or by splitting a word. The data con­tained 1402 inserted malapropisms.</p><p>Because it had earlier been used for evaluat­ing Mays et al. (1991)'s trigram method, which operates at the sentence level, the data set had been divided into three parts, without regard for article boundaries or text coherence: sen­tences into which no malapropism had been in­duced; the original versions of the sentences that received malapropisms; and the malapropized sentences. In addition, all instances of num­bers of various kinds had been replaced by tags such as &lt;INTEGER&gt;, &lt;DOLLAR VALUE&gt;, and PERCENTAGE VALUE&gt;. Actual (ran­dom) numbers or values were restored for these tags. Some spacing anomalies around punctuation marks were corrected. A detailed description of this data can be found in (Hirst, 2008; Wilcox-O'Hearn et al., 2008).</p><footnote label="7">Ispell is a fast screen-oriented spelling checker that shows you your errors in the context of the original file, and suggests possible corrections when it can figure them out. The original was written in PDP-10 assembly in 1971, by R. E. Gorin. The C version was written by Pace Willisson of MIT. Geoff Kuenning added the international support and created the current release.</footnote><p>SUCCESSFUL CORRECTION:</p><p>The Iran revelations were particularly disturbing to the Europeans because they came on the heels of the Reykjavik summit between President Rea­gan and Soviet <i>reader </i>—&gt; leader [leader] Mikhail Gorbachev.</p><p>Even the now sainted Abraham Lincoln was of­ten reviled while in <i>officer </i>—&gt; office [office], some­times painted by cartoonists and editorial writers as that baboon in the White House. FALSE POSITIVE:</p><p>• by such public displays of interest in <i>Latinos </i>—&gt; Latin [Latinos], many undocumented • • •</p><p>The southeast Asian nation was one reported <i>contributor </i>—&gt; contribution [contributor] to the Nicaraguans. FALSE NEGATIVE:</p><p>Kevin Mack, Geldermann president and chief executive officer, didn't return calls for comment on the Clayton <i>purchaser </i>[purchase].</p><p>U.S. <i>manufactures </i>[manufacturers], in short, again are confronting a ball game in which they will be able to play.</p><p>TRUE POSITIVE DETECTION, FALSE POSI-TIVE CORRECTION:</p><p>Hawkeye also is known to <i>rear </i>—&gt; reader [fear] that a bankruptcy-law filing by the parent com­pany, which theoretically shouldn't affect the op­erations of its member banks, would spark runs on the banks that could drag down the whole entity.</p><p>The London Daily News has quoted sources saying as many as 23 British mercenaries were en­listed by KMS to <i>lid </i>—&gt; slide [aid] the Contras.</p><p>Table 2: Examples of successful and unsuccessful corrections. Italics indicate observed word, arrow indicates correction, square brackets indicate in­tended word.</p><p>Some examples of successful and unsuccessful corrections using our proposed method are shown in Table 2.</p><p>Table 3 shows our method's results on the de­scribed data set compared with the results for the trigram method of Wilcox-O'Hearn et al. (2008)<page local="8" global="1248"/></p><doubt alpha="0.0" length="4" tooSmall="False" monospace="0.0">1247</doubt><p>Detection correction</p><p>Table 3: A comparison of recall, precision, and <i>F\ </i>score for three methods of malapropism detection and correction on the same data set.</p><p>and the lexical cohesion method of Hirst and Bu­danitsky (2005). The data shown here for tri­gram method are not from (Wilcox-O'Hearn et al., 2008), but rather are later results following some corrections reported in (Hirst, 2008). We have not tried optimizing our adjustable parameters: <i>ß </i>and as, because the whole data set was used as test­ing set by the other methods we compare with. To keep the comparison consistent, we did not use any portion of the data set for training purpose. Having optimized parameters could lead to a bet­ter result. The performance is measured using <i>Re­call </i><i>(R), </i><i>Precision </i><i>(P)</i><i> </i>and <i>F\\</i></p><p>true positives true positives + false negatives</p><p>true positives true positives + false positives</p><doubt alpha="40.0" length="5" tooSmall="False" monospace="0.0">P + R</doubt><p>The fraction of errors correctly detected is the de­tection <i>recall </i>and the fraction of detections that are correct is the detection <i>precision. </i>Again, the fraction of errors correctly amended is the correc­tion <i>recall </i>and the fraction of amendments that are correct is the correction <i>precision. </i>To give an example, consider a sentence from the data set: "The Philippine president, in her commencement address at the academy, complained that the U.S. was <i>living </i>—&gt; giving [giving] advice instead of the <i>aid </i>—&gt; said [aid] it pledged.", where italics indi­cate the observed word, arrow indicates the correc­tion and the square brackets indicate the intended word. The detection <i>recall </i>of this sentence is 1.0 and the <i>precision </i>is 0.5. The correction <i>recall </i>of this sentence is 1.0 and the <i>precision </i>is 0.5. For both cases, the <i>F\ </i>score is 0.667.</p><p>We loose some precision because our method tries to detect and correct errors for all the words (except the first word) in the input sentence, and, as a result, it generates more false positives than the other methods. Even so, we get better <i>F\ </i>scores than the other competing methods. Ac­cepting 8.3 percents extra incorrect detections, we get 34.6 percents extra correct detections of errors, and similarly, accepting 12.2 percents extra incor­rect amendments, we get 27.2 percents extra cor­rect amendments of errors compared with the tri­grams method (Wilcox-O'Hearn et al., 2008)<footnote anchor="8"/>.</p></section><section number="5" title="Conclusion"><p>The Google 3-grams proved to be very useful in detecting real-word errors, and finding the correc­tions. We did not use the 4-grams and 5-grams because of data sparsity. When we tried with 5-grams the results were lower than the ones pre­sented in Section 4. Having sacrificed a bit the precision score, our proposed method achieves a very good detection recall (0.89) and correction recall (0.76). Our attempts to improve the detec­tion recall or correction recall, while maintaining the respective precisions as high as possible are helpful to the human correctors who post-edit the output of the real-word spell checker. If there is no postediting, at least more errors get corrected automatically. Our method could also detect and correct misspelled words, not only malapropisms, without any modification. In future work, we plan to extend our method to allow for deleted or in­serted words, and to find the corrected strings in the Google Web IT n-grams. In this way we will be able to correct grammar errors too. We also plan more experiments using the 5-grams, but backing off to 4-grams and 3-grams when needed.</p></section><section title="Acknowledgments"><p>This work is funded by the Natural Sciences and Engineering Research Council of Canada. We want to thank Professor Graeme Hirst from the Department of Computer Science, University of Toronto, for providing the evaluation data set.</p><footnote label="8">We can run our algorithm on subsets of data to check for variance in the results. We cannot test statistical significance compared to the related work (i-test), because we do not have the system from related work to run it on subsets of the data.</footnote><doubt alpha="0.0" length="4" tooSmall="False" monospace="0.0">1248</doubt><table class="main" frame="box" rules="all" border="1" regular="False"><tr class="row"><td class="cell"></td><td class="cell"></td><td class="cell"></td><td class="cell"></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p><i>R</i></p></td><td class="cell"><p><i>P       Fx       R P</i></p></td><td class="cell"><p><i>Fi</i></p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p></p></td><td class="cell"><p><b>Lexical cohesion</b></p></td><td class="cell"><p></p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p></p></td><td class="cell"><p>(Hirst and Budanitsky, 2005)</p></td><td class="cell"><p></p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>0.306</p></td><td class="cell"><p>0.225   0.260   0.281 0.207</p></td><td class="cell"><p>0.238</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p></p></td><td class="cell"><p><b>Trigrams</b></p></td><td class="cell"><p></p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p></p></td><td class="cell"><p>(Wilcox-O'Hearn et al., 2008)</p></td><td class="cell"><p></p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>0.544</p></td><td class="cell"><p>0.528   0.536   0.491 0.503</p></td><td class="cell"><p>0.497</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p><b>Multiple 3-grams</b></p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"><p>0.890</p></td><td class="cell"><p>0.445   0.593   0.763 0.381</p></td><td class="cell"><p>0.508</p></td><td class="cell"></td></tr><tr class="row"><td class="cell"></td><td class="cell"></td><td class="cell"></td><td class="cell"></td><td class="cell"></td></tr></table><page local="9" global="1249"/></section><references><p>L. Allison and T.I. Dix. 1986. A bit-string longest-common-subsequence algorithm. <i>Information Pro­cessing Letters, </i>23:305-310.</p><p>Thorsten Brants and Alex Franz. 2006. Web IT 5-gram corpus version 1.1. Technical report, Google Research.</p><p>Lou Burnard, 2000. <i>Reference Guide for the British National Corpus (World Edition), </i>October. www.natcorp.ox.ac.uk/docs/userManual/urg.pdf.</p><p>Andrew J. Carlson, Jeffrey Rosen, and Dan Roth. 2001. Scaling up context-sensitive text correction.</p><p>In <i>Proceedings of the Thirteenth Conference on In­novative Applications of Artificial Intelligence Con­ference, </i>pages 45-50. AAAI Press.</p><p>Andrew R. Golding and Dan Roth. 1999. A winnow-based approach to context-sensitive spelling correc­tion. <i>Machine Learning, </i>34(1-3):107-130.</p><p>Graeme Hirst and Alexander Budanitsky. 2005. Cor­recting real-word spelling errors by restoring lex­ical cohesion. <i>Natural Language Engineering, </i>11(1):87-111, March.</p><p>Graeme Hirst and David St-Onge, 1998. <i>WordNet: An electronic lexical database, </i>chapter Lexical chains as representations of context for the detection and correction of malapropisms, pages 305-332. The MIT Press, Cambridge, MA.</p><p>Graeme Hirst. 2008. An evaluation of the contextual spelling checker of microsoft office word 2007, Jan­uary. http://ftp.cs.toronto.edu/pub/gh/Hirst-2008-Word.pdf.</p><p>Aminul Islam and Diana Inkpen. 2008. Semantic text similarity using corpus-based word similarity and string similarity. <i>ACM Transactions on Knowledge Discovery from Data, </i>2(2): 1-25.</p><p>G. Kondrak. 2005. N-gram similarity and distance. In <i>Proceedings of the 12h International Conference on String Processing and Information Retrieval, </i>pages 115-126, Buenos Aires, Argentina.</p><p>Karen Kukich. 1992. Technique for automatically correcting words in text. <i>ACM Comput. Surv., </i>24(4):377^139.</p><p>Eric Mays, Fred J. Damerau, and Robert L. Mercer. 1991. Context based spelling correction. <i>Informa­tion Processing and Management, </i>27(5):517-522.</p><p>I. D. Melamed. 1999. Bitext maps and alignment via pattern recognition. <i>Computational Linguistics, </i>25(1): 107-130.</p><p>G.A. Miller, R. Beckwith, C. Fellbaum, D. Gross, and K.J. Miller. 1993. Introduction to wordnet: An on-line lexical database. Technical Report 43, Cognitive Science Laboratory, Princeton University, Princeton, NJ.</p><p>Jennifer Pedler. 2007. <i>Computer Correction of Real-word Spelling Errors in Dyslexic Text. </i>Ph.D. thesis, Birkbeck, London University.</p><p>Suzan Verberne. 2002. Context-sensitive spell check­ing based on word trigram probabilities. Master's thesis, University of Nijmegen, February-August.</p><p>L. Amber Wilcox-O'Hearn, Graeme Hirst, and Alexan­der Budanitsky. 2008. Real-word spelling correc­tion with trigrams: A reconsideration of the mays, damerau, and mercer model. In Alexander Gel-bukh, editor, <i>Proceedings, 9th International Con­ference on Intelligent Text Processing and Compu­tational Linguistics (CICLing-2008) (Lecture Notes in Computer Science 4919, Springer-Verlag), </i>pages 605-616, Haifa, February.</p><doubt alpha="0.0" length="4" tooSmall="False" monospace="0.0">1249</doubt></references></body></article>