<commit_before>public class Model {
  private final Map<String, long> wordList;

  public Model() {
    wordList = new HashMap<>();
  }

  public void addWord(String word) {
    if (wordList.containtKey(word)) {
      long count = wordList.get(word);
      wordList.put(word, ++count);
    } else {
      wordList.put(word, 1);
    }
  }

  public Map<String, long> getWordList() {
    return this.wordList();
  }

  public long getCountForWord(String word) {
    if (wordList.containsKey(word)) {
      return wordList.get(word);
    } else {
      return 0;
     }
  }

  public void addSentence(String sentence) {
    String[] words = sentence.split(' ');
    if (words.length > 0) {
      for (String word : words) {
        addWord(word);
      }
    }
  }
}<commit_msg>Implements listener support in model<commit_after>public class Model {
  private final Map<String, long> wordList;
  private final Set<OnModelDataChangedListener> listeners;

  public Model() {
    wordList = new HashMap<>();
    listeners = new HashSet<>();
  }

  public void addWord(String word) {
    if (wordList.containtKey(word)) {
      long count = wordList.get(word);
      wordList.put(word, ++count);
    } else {
      wordList.put(word, 1);
    }
  }

  public Map<String, long> getWordList() {
    return this.wordList();
  }

  public long getCountForWord(String word) {
    if (wordList.containsKey(word)) {
      return wordList.get(word);
    } else {
      return 0;
     }
  }

  public void addSentence(String sentence) {
    String[] words = sentence.split(' ');
    if (words.length > 0) {
      for (String word : words) {
        addWord(word);
      }
    }
  }

  public void addListener(OnModelDataChangedListener listener) {
    if (listener != null) {
      listeners.add(listener);
    } else {
      throw new IllegalArgumentException("Listener can't be null");
    }
  }

  public void removeListener(OnModelDataChangedListener listener) {
    if (listeners.contains(listener)) {
      listeners.remove(listener);
    } else {
      throw new IllegalArgumentException("Listener is already removed");
    }
  }

  public isListenerAdded(OnModelDataChangedListener listener) {
    return listeners.contains(listener);
  }

  private void notifyListeners(String word, long newCount, long oldCount) {
    for (OnModelDataChangedListener l : listeners) {
      l.onModelDataChanged(word, newCount, oldCount);
    }
  }

  public interface OnModelDataChangedListener {
    void onModelDataChanged(String word, long newCount, long oldCount);
  } 
}
{'fraction_non_alphanumeric': 0.11568627450980393, 'fraction_numerical': 0.002352941176470588, 'mean_word_length': 2.992175273865415, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 13, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '863183', 'n_tokens_mistral': 786, 'n_tokens_neox': 766, 'n_words': 188}