The word count is the number of words in a document or passage of text. Word counting may be needed when a text is required to stay within certain numbers of words. This may particularly be the case in academia, legal proceedings, journalism and advertising. Word count is commonly used by translators to determine the price for the translation job. Word counts may also be used to calculate measures of readability and to measure typing and reading speeds (usually in words per minute). When converting character counts to words, a measure of 5 or 6 characters to a word is generally used.
WordCount example reads text files and counts how often words occur. The input is text files and the output is text files, each line of which contains a word and the count of how often it occured, separated by a tab or space.
Variations in the operational definitions of how to count the words can occur (namely, what "counts as" a word, and which words "don't count" toward the total). However, especially since the advent of widespread word processing, there is a broad consensus on these operational definitions (and hence the bottom-line integer result). The consensus is to accept the text segmentation rules generally found in most word processing software (including how word boundaries are determined, which depends on how word dividers are defined). The first trait of that definition is that a space (any of various whitespace characters, such as a "regular" word space, an em space, or a tab character) is a word divider. Usually a hyphen or a slash is, too. Different word counting programs may give varying results, depending on the text segmentation rule details, and on whether words outside the main text (such as footnotes, endnotes, or hidden text) are counted. But the behavior of most major word processing applications is broadly similar.
Source : WikiPedia