code: @Override
      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 (x.length != p) {
              throw new IllegalArgumentException("Invalid input vector size: " + x.length);
          }
          
          if (model == Model.MULTINOMIAL) {
              for (int i = 0; i < p; i++) {
                  ntc[y][i] += x[i];
                  nt[y] += x[i];
              }
          } else if (model == Model.POLYAURN) {
              for (int i = 0; i < p; i++) {
                  ntc[y][i] += x[i] * 2;
                  nt[y] += x[i] * 2;
              }
          } else {
              for (int i = 0; i < p; i++) {
                  if (x[i] > 0) {
                      ntc[y][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.
  @param y training label in [0, k), where k is the number of classes.