import java.util.*;

public class Main {

    public static void main(String[] args) {

        String text = "hello hadoop hello world hadoop";

        String[] words = text.split(" ");

        HashMap<String, Integer> count = new HashMap<>();

        // Mapper + Reducer logic
        for (String word : words) {
            if (count.containsKey(word)) {
                count.put(word, count.get(word) + 1);
            } else {
                count.put(word, 1);
            }
        }

        // Output
        for (String word : count.keySet()) {
            System.out.println(word + " : " + count.get(word));
        }
    }
}
