title: How can I count specific word using mapreduce?
body: <p>I am modifying normal word count program which counts every word to make it count only specific words.</p>
  
  <p>The reducer and map class are same as of normal word count. Not getting word count properly. I have multiple occurrences of same specific word in file but getting one as the count.</p>
  
  <pre><code>public class wordcountmapper extends MapReduceBase implements Mapper&lt;LongWritable, Tex, Text, IntWritable&gt;                       // mapper function implemented.
  {
      private final static IntWritable one = new IntWritable(1); // intwritable
      private Text word = new Text();
  
      public void map(LongWritable key, Text value, OutputCollector&lt;Text, IntWritable&gt; output, Reporter reporter) throws IOException {
          String line = value.toString();      // conversion in string
          StringTokenizer tokenizer = new StringTokenizer(line);
          while (tokenizer.hasMoreTokens()) {
              word.set(tokenizer.nextToken());
              if (line.compareTo("Cold") == 0) {  //cold is the specific word to get count for
                  output.collect(word, one);      // getting 1 as a count for 'cold' as if its counting only first line 'cold' and not going to next line.
              }
          }
      }
  }
  </code></pre>