fig1 is a schematic , pictorial illustration of a system 20 for ocr , in accordance with an embodiment of the present invention . an input device 22 , such as a scanner , captures an image of a document 24 on which characters are written or printed . a processor , typically a computer 26 , processes the image , using methods of pattern recognition known in the art , in order to identify the characters and assign them the proper character codes . computer 26 then applies a string matching algorithm to correct ocr errors , as described hereinbelow , and outputs the ocr results to an output device , such as a display monitor 28 , or stores the results in memory for further processing . in order to identify and correct ocr errors , computer 26 checks the strings of character codes that it has generated in the pattern recognition stage against a directory 30 of known words , which is held in a memory . alternatively , the pattern recognition and error correction functions may be performed by separate computers . in either case , in the error correction stage the computer typically applies an approximate string matching algorithm to a modified string , in which certain sequences of character codes are replaced by corresponding extension character codes in both the pattern recognition output of computer 26 and in directory 30 . the use of the extension character codes permits the computer to correct segmentation errors simply and accurately , as described further hereinbelow . computer 26 typically performs these error correction functions under the control of software , which may be downloaded to the computer in electronic form , over a network , for example , or may alternatively be provided on tangible media , such as cd - rom . fig2 is a flow chart that schematically illustrates a method for ocr that is implemented in system 20 , in accordance with an embodiment of the present invention . upon receiving the image of document 24 , computer 26 first segments the image in order to identify the individual characters , at a segmentation step 40 . this step commonly involves determining the layout of the document , identifying lines of text and segmenting the lines into words and characters . various segmentation algorithms , as are known in the art , may be used at this stage . such algorithms are aimed at dividing the text area of the image into segments such that each segment contains a single character . errors in the segmentation algorithm , however , almost inevitably result in some characters being split into multiple segments , or in multiple characters being combined into a single segment . therefore , it can be said that the result of segmentation step 40 is that each segment contains approximately one character . computer 26 next applies pattern recognition to assign a character code , such as an ascii code , to each character , at a classification step 42 . any suitable ocr engine known in the art may be used for this purpose . the ocr engine generates an input string of character codes corresponding to each word in the image , with one character code for each segment . before proceeding to compare the strings of character codes generated by ocr at step 42 to the words in directory 30 , computer 26 replaces certain critical combinations of character codes with predetermined extension character codes , at a preprocessing step 44 . “ critical combinations ” in this context are sequences of two or more character codes in the ocr output that are known to result frequently from improper segmentation of some other character , such as “ rn ” resulting from “ m ”, or “ 13 ” resulting from “ b ”, or “ cl ” resulting from “ d ”. other critical combinations will be apparent to those skilled in the art . although for the sake of simplicity , only two - character critical combinations are considered here , the methods of the present invention are also applicable when an original character may be incorrectly segmented into three characters . sequences of characters that are subject to pair substitution , as described by seni et al ., may also be treated as critical combinations . the “ extension characters ” have character codes that are not used in the ordinary ocr output . for example , when the ascii code set is used , conventional ocr engines are typically not programmed to use all of the possible 256 character codes in the input strings that they generate . the codes corresponding to the greek letters α , β , etc ., may be unused in the ocr output . in this case , at step 44 , occurrences of “ rn ” in the ocr - generated string may be replaced by the code for “ α ”, “ 13 ” may be replaced by the code for “ β ”, and so forth . the word “ barn ” in the ocr output would thus be replaced at this step with the modified string “ baα ”. alternatively or additionally , new character codes may be added to represent the extension characters , beyond the basic 256 codes in the conventional code set . directory 30 is also extended to include aliases corresponding to valid words that contain critical combinations of characters . for example , “ baα ” would be added to the directory as an alias for “ barn ”. a word containing multiple critical combinations will have multiple aliases in the extended directory . typically , for a word containing q critical combinations , the directory will include 2 q entries . after substituting extension characters into the ocr - generated words , computer 26 looks up each modified string in directory 30 , at a lookup step 46 . if an exact match is found for a given string , error detection may terminate , at a matching step 48 . in this case , the computer outputs the matching word , at an exact match output step 50 . any extension character in the matching word is converted back into the actual characters that the extension character represents . thus , “ α ” would be converted back into “ rn ”, and so forth . alternatively , steps 48 and 50 may be omitted , and all ocr - generated strings may be subjected to approximate matching against directory 30 , as described below . computer 26 uses an approximate string matching technique to find the closest word in directory 30 for each modified string , at an approximate matching step 52 . the best match is typically found on the basis of an edit distance computation . any suitable method known in the art may be used for this purpose , such as the method of wagner and fischer that is described in the background of the invention . existing string matching engines may be used at this step with only minor modifications , or with no modification at all as long as the character codes of the extension characters have the same sort of binary representation ( for example , as eight - bit binary numbers ) as do the ordinary character codes generated by the ocr engine . to compute the edit distances according to the method of wagner and fischer , it is necessary to assign a cost γ to each edit operation . string matching engines known in the art typically use a “ confusion matrix ” c for this purpose . c has one row for each possible input character a in the ocr - generated string , and one column for each possible output character b in the string found in directory 30 . c also includes a row and a column for the null character λ . each entry in c represents the cost γ of transforming a into b , including deletions ( a → λ ) and insertions ( λ → b ). c is not necessarily symmetrical . the entries in c may be derived , for example , on the basis of statistical analysis of differences between raw ocr results ( without error correction ) on a corpus of sample text and human - generated transcription of the same text . frequent substitutions of one character for another in the ocr results will generally lead to a small cost γ in the corresponding entry in c , and vice versa . in an embodiment of the present invention , c is extended to give an extended confusion matrix c ′, with additional rows and columns corresponding to the extension characters . the following rules generally apply to these added rows and columns : the cost of transforming an extension character into the non - segmented character from which it may have been erroneously derived is generally zero . in other words , taking a as the extension character for “ rn ”, γ ( α → m )= 0 . this means that the edit distance from an ocr output of “ barn ” to an entry “ barn ” in directory 30 will be effectively zero . the reverse transformation , such as ( m → α ), may likewise have zero or low cost , to facilitate correction of segmentation errors caused by conjoining multiple characters into one . segmentation errors that occur only infrequently , however , may have a non - zero cost . the cost of transforming an extension character into a normal character is typically the sum of costs of two edit operations ( substitution and deletion ). transforming an extension character into a similar pair of normal characters ( such as α ( rn )→ rh ), can be treated , when necessary , as a transformation of one extension character into another , as described below . the cost of transforming a normal character into an extension character reflects the cost of a single edit operation . clearly , the entries in the confusion matrix will provide a low cost for transformation of one of the constituent normal characters of an extension character into the extension character itself , such as r → α ( rn ), and will provide higher costs for other transformations . the cost of transforming one extension character into another is the cost of a single edit operation ( with sufficiently high costs assigned to unlikely transformations , such as α ( rn )→ β ( 13 )). thus , at step 52 , the edit distances between the modified ocr string , with extension characters added at step 44 , and the words listed in extended directory 30 are computed using the costs given by the extended confusion matrix c ′. the word in directory 30 that is found to have the shortest edit distance from the modified ocr string is selected as the correct reading of the string , at a matching step 54 . when the selected word is an alias , containing one or more extension characters , these extension characters are replaced by the corresponding normal characters . for example , if “ baα ” is the closest match , computer 28 replaces the α with “ rn ” and outputs the word “ barn ”. although the method of fig2 makes use of the dynamic - programming approach of wagner and fischer in computing edit distances at step 52 , the principles of the present invention — particularly the use of extension characters as described hereinabove — may similarly be applied using other methods of string matching known in the art . these principles are applicable not only in correcting ocr errors , but also in other fields in which sequences of known elements , such as dna sequences , must be analyzed and identified . therefore , the terms “ character ” and “ string ” as used herein should be understood to comprise not only alphanumeric characters and strings of such characters , but also other predefined elements and sequences of such elements that are given to computerized analysis . it will thus be appreciated that the embodiments described above are cited by way of example , and that the present invention is not limited to what has been particularly shown and described hereinabove . rather , the scope of the present invention includes both combinations and subcombinations of the various features described hereinabove , as well as variations and modifications thereof which would occur to persons skilled in the art upon reading the foregoing description and which are not disclosed in the prior art .