code: public void learn(double[][] 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 (int i = 0; i < x.length; i++) {
                  if (x[i].length != p) {
                      throw new IllegalArgumentException("Invalid input vector size: " + x[i].length);
                  }
  
                  for (int j = 0; j < p; j++) {
                      ntc[y[i]][j] += x[i][j];
                      nt[y[i]] += x[i][j];
                  }
  
                  n++;
                  nc[y[i]]++;
              }
          } else if (model == Model.POLYAURN) {
              for (int i = 0; i < x.length; i++) {
                  if (x[i].length != p) {
                      throw new IllegalArgumentException("Invalid input vector size: " + x[i].length);
                  }
  
                  for (int j = 0; j < p; j++) {
                      ntc[y[i]][j] += x[i][j] * 2;
                      nt[y[i]] += x[i][j] * 2;
                  }
  
                  n++;
                  nc[y[i]]++;
              }
          } else {
              for (int i = 0; i < x.length; i++) {
                  if (x[i].length != p) {
                      throw new IllegalArgumentException("Invalid input vector size: " + x[i].length);
                  }
  
                  for (int j = 0; j < p; j++) {
                      if (x[i][j] > 0) {
                          ntc[y[i]][j]++;
                      }
                  }
  
                  n++;
                  nc[y[i]]++;
              }
          }
  
          update();
      }
docs: Online learning of naive Bayes classifier on sequences,
  which are modeled as a bag of words. Note that this method is NOT
  applicable for naive Bayes classifier with general generation model.
  
  @param x training instances.
  @param y training labels in [0, k), where k is the number of classes.