11.07.2015 Views

Encyclopedia of Computer Science and Technology

Encyclopedia of Computer Science and Technology

Encyclopedia of Computer Science and Technology

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

optical character recognition 355the value <strong>of</strong> the SubTotal Tax is multiplied by the value <strong>of</strong>the variable Tax_Rate, the result is added to the value <strong>of</strong>SubTotal, <strong>and</strong> the result <strong>of</strong> the entire expression is storedin the variable Total. Compilers generally parse arithmeticexpressions by converting them from an “infix” form (as inA + B) to a “postfix” form (as in + A B), resolving them intoa simple form that is ready for conversion to machine code.Operator PrecedenceThe preceding example raises an important question. Howdoes one know that the subtotal is to be multiplied by thetax rate <strong>and</strong> then the result added to the subtotal, as opposedto adding the subtotal <strong>and</strong> tax <strong>and</strong> multiplying the result bythe tax rate? The former procedure is intuitively correct tohuman observers, but since computers lack intuition, specificrules <strong>of</strong> precedence are defined for operators. Theserules, which are similar for all computer languages, tell thecompiler that when code is generated for arithmetic operations,multiplications <strong>and</strong> divisions are carried out first(moving from left to right), <strong>and</strong> then additions <strong>and</strong> subtractionsare resolved in the same way. The rules <strong>of</strong> precedencedo become more complex when the relational, logical, <strong>and</strong>assignment operators are included. Finally, expressions canbe enclosed in parentheses to overrule precedence <strong>and</strong> forcethem to be evaluated. Thus in the expression (A + B) * C theaddition will be carried out before the multiplication.Generally speaking, the levels <strong>of</strong> precedence for mostlanguages are as follows:1. scope resolution operators (specify local v. globalversions <strong>of</strong> a variable)2. invoking a method from a class, array subscript,function call, increment or decrement3. size <strong>of</strong> (gets number <strong>of</strong> bytes in an object), address<strong>and</strong> pointer dereference, other unary operators(such as “not” <strong>and</strong> complement); creation <strong>and</strong> deallocationfunctions; type castsA compiler or interpreter processes a program statement by applyingits operators in order <strong>of</strong> precedence. Here the multiplication isdone first, <strong>and</strong> then its result is used in the addition. The assignment(=) operator has the lowest precedence <strong>and</strong> is applied last,assigning the value <strong>of</strong> the entire expression to the variable Total.4. class member selection through a pointer5. multiplication, division, <strong>and</strong> modulus6. addition <strong>and</strong> subtraction7. left <strong>and</strong> right shift operators8. less than <strong>and</strong> greater than9. equal <strong>and</strong> not equal operators10. bitwise operators (AND, then exclusive OR, inclusiveOR)11. logical operators (AND, then OR)12. assignment statementsThe basic arithmetic operators are built into each programminglanguage, but many <strong>of</strong> the newer object-orientedlanguages such as C++ allow for programmer-defined operators<strong>and</strong> a process called overloading in which the sameoperator can be defined to work with several different kinds<strong>of</strong> data. Thus the + operator can be extended so that if it isgiven character strings instead <strong>of</strong> numbers, it will “add” thestrings by combining (concatenating) them.Further Reading“Operators in C <strong>and</strong> C++.” Wikipedia. Available online. URL:http://en.wikipedia.org/wiki/Operators_in_C_<strong>and</strong>_C++.Accessed August 16, 2007.Sebesta, Robert W. Concepts <strong>of</strong> Programming Languages. 8th ed.Upper Saddle River, N.J.: Addison-Wesley, 2007.Stroustrup, Bjarne C. The C++ Programming Language. 3rd ed.Reading, Mass.: Addison-Wesley, 1997. See chap. 6 “Expressions<strong>and</strong> Statements” <strong>and</strong> chap. 11 “Operator Overloading.”“Summary <strong>of</strong> Operators.” Java Tutorials. Available online. URL:http://java.sun.com/docs/books/tutorial/java/nuts<strong>and</strong>bolts/opsummary.html. Accessed August 16, 2007.“Summary <strong>of</strong> Operators in Java.” Available online. URL: http://sunsite.ccu.edu.tw/java/tutorial/java/nuts<strong>and</strong>bolts/opsummary.html.optical character recognition (OCR)Today it is easy to optically scan text or graphics printed onpages <strong>and</strong> convert it into a graphical representation for storagein the computer (see scanner). However, a shape suchas a letter c doesn’t mean anything in particular as a graphic.Optical character recognition (OCR) is the process <strong>of</strong> identifyingthe letter or other document element that correspondsto a given part <strong>of</strong> the scanned image <strong>and</strong> converting it tothe appropriate character (see characters <strong>and</strong> strings). Ifthe process is successful, the result is a text document thatcan be manipulated in a word processor, database, or otherprogram that h<strong>and</strong>les text. Raymond Kurzweil (1948– )marketed the first commercially practicable general-purposeoptical character recognition system in 1978.Once the document page has been scanned into an imageformat, there are various ways to identify the characters.One method is to use stored templates that indicate the pattern<strong>of</strong> pixels that should correspond to each character. Generally,a threshold <strong>of</strong> similarity is defined so that an exactmatch is not necessary to classify a character: The templatemost similar to the character is chosen. Some systems storea set <strong>of</strong> templates for each <strong>of</strong> the fonts most commonly foundin printed text. (Recognizing cursive writing is a much morecomplex process: See h<strong>and</strong>writing recognition.)

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!