code: public void learn(SparseArray x, int y) {
          if (model == Model.GENERAL) {
              throw new UnsupportedOperationException("General-mode Naive Bayes classifier doesn't support online learning.");
          }
  
          if (model == Model.MULTINOMIAL) {
              for (SparseArray.Entry e : x) {
                  ntc[y][e.i] += e.x;
                  nt[y] += e.x;
              }
          } else if (model == Model.POLYAURN) {
              for (SparseArray.Entry e : x) {
                  ntc[y][e.i] += e.x * 2;
                  nt[y] += e.x * 2;
              }
          } else {
              for (SparseArray.Entry e : x) {
                  if (e.x > 0) {
                      ntc[y][e.i]++;
                  }
              }
          }
  
          n++;
          nc[y]++;
          update();
      }
docs: Online learning of naive Bayes classifier on a sequence,
  which is modeled as a bag of words. Note that this method is NOT
  applicable for naive Bayes classifier with general generation model.
  
  @param x training instance in sparse format.
  @param y training label in [0, k), where k is the number of classes.