code: @Override
      public double[] feature(T[] x) {
          double[] bag = new double[features.size()];
  
          if (binary) {
              for (T word : x) {
                  Integer f = features.get(word);
                  if (f != null) {
                      bag[f] = 1.0;
                  }
              }
          } else {
              for (T word : x) {
                  Integer f = features.get(word);
                  if (f != null) {
                      bag[f]++;
                  }
              }
          }
  
          return bag;
      }
docs: Returns the bag-of-words features of a document. The features are real-valued
  in convenience of most learning algorithms although they take only integer
  or binary values.