code: public static <TERM> Map<TERM, Double> tf(Collection<TERM> document, TfType type)
      {
          Map<TERM, Double> tf = new HashMap<TERM, Double>();
          for (TERM term : document)
          {
              Double f = tf.get(term);
              if (f == null) f = 0.0;
              tf.put(term, f + 1);
          }
          if (type != TfType.NATURAL)
          {
              for (TERM term : tf.keySet())
              {
                  switch (type)
                  {
                      case LOGARITHM:
                          tf.put(term, 1 + Math.log(tf.get(term)));
                          break;
                      case BOOLEAN:
                          tf.put(term, tf.get(term) == 0.0 ? 0.0 : 1.0);
                          break;
                  }
              }
          }
          return tf;
      }
docs: 单文档词频
  
  @param document 词袋
  @param type     词频计算方式
  @param <TERM>   词语类型
  @return 一个包含词频的Map