I am learning Hadoop MapReduce and I am following the WordCount [tutorial](https://hadoop.apache.org/docs/stable/hadoop-mapreduce-client/hadoop-mapreduce-client-core/MapReduceTutorial.html).

In the following piece of code, I understand that the `map` method, processes one line at a time, as provided by the specified `TextInputFormat`. It then splits the line into tokens separated by whitespaces, via the `StringTokenizer`, and emits a key-value pair of `[<word>, 1]`:

```
public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
    StringTokenizer itr = new StringTokenizer(value.toString());
    while (itr.hasMoreTokens()) {
        word.set(itr.nextToken());
        context.write(word, one);
    }
}

```

How can I edit this code in order to read a sentence instead of a line per time?

E.g. of input text:
`This is my first sentence. This is the second sentence.`

I want to read first `This is my first sentence.` and then `This is the second sentence.` instead of `This`, `is`, `my`, `first`, ...

and have as output:

```
1 This is my first sentence.
1 This is the second sentence.

```

because the sentence `This is my first sentence.` appears only one time in the input text and also the sentence `This is the second sentence.` appear one time in the text.

Suppose that the input text is like this:

`This is my first sentence. This is my first sentence. This is the second sentence.` 

then the output would be like this:

```
2 This is my first sentence.
1 This is the second sentence.

```

because the sentence `This is my first sentence.` appears two times in the input text and the sentence `This is the second sentence.` appears only one time in the text.

Fyi, the output of the WordCount is:

```
2 This
2 is
1 my
1 first
2 sentence
1 second

```

because the term `This` appears two time in the input text, the term `is` appeats two times in the text, the term `my` appears one time in the text etc..

**SOLUTION: conf.set("textinputformat.record.delimiter", ". "):**

As delimiter I set `". "` (with the space). Now my code recognises the sentences but the output file is wrong. With the following input file:

`This is my first sentence. This is my first sentence. This is the second sentence.`

The output file that it generates is like this (some white spaces and then the number 3):

```
            3

```

Instead of like this:

```
 2 This is my first sentence
 1 This is the second sentence

```

Here is my code:

```
 public class SentenceCount {

      public static class SentenceMapper extends Mapper<Object, Text, Text, IntWritable>{

           private final static IntWritable one = new IntWritable(1);
           private Text word = new Text();

           public void map(Object key, Text value, Context context) throws IOException, InterruptedException {
           //System.out.println("SENTENCE: " + value.toString());
           context.write(word, one);
     }
 }

 public static class IntSumReducer extends Reducer<Text,IntWritable,Text,IntWritable> {
      private IntWritable result = new IntWritable();

     public void reduce(Text key, Iterable<IntWritable> values, Context context) throws IOException, InterruptedException {
          int sum = 0;
          for (IntWritable val : values) {
               sum += val.get();
       }
       result.set(sum);
       context.write(key, result);
     }
 }

 public static void main(String[] args) throws Exception {
      Configuration conf = new Configuration();
      conf.set("textinputformat.record.delimiter", ". ");
      Job job = Job.getInstance(conf, "sentence count");
      job.setJarByClass(SentenceCount.class);
      job.setMapperClass(SentenceMapper.class);
      job.setCombinerClass(IntSumReducer.class);
      job.setReducerClass(IntSumReducer.class);
      job.setOutputKeyClass(Text.class);
      job.setOutputValueClass(IntWritable.class);
      FileInputFormat.addInputPath(job, new Path(args[0]));
      FileOutputFormat.setOutputPath(job, new Path(args[1]));
      System.exit(job.waitForCompletion(true) ? 0 : 1);
 }
 }      

```

Where am I wrong?