code: public static <TERM> Map<TERM, Double> idf(Iterable<Iterable<TERM>> documentVocabularies,
                                                 boolean smooth, boolean addOne)
      {
          Map<TERM, Integer> df = new HashMap<TERM, Integer>();
          int d = smooth ? 1 : 0;
          int a = addOne ? 1 : 0;
          int n = d;
          for (Iterable<TERM> documentVocabulary : documentVocabularies)
          {
              n += 1;
              for (TERM term : documentVocabulary)
              {
                  Integer t = df.get(term);
                  if (t == null) t = d;
                  df.put(term, t + 1);
              }
          }
          Map<TERM, Double> idf = new HashMap<TERM, Double>();
          for (Map.Entry<TERM, Integer> e : df.entrySet())
          {
              TERM term = e.getKey();
              double f = e.getValue();
              idf.put(term, Math.log(n / f) + a);
          }
          return idf;
      }
docs: 一系列文档的倒排词频
  
  @param documentVocabularies 词表
  @param smooth               平滑参数，视作额外有一个文档，该文档含有smooth个每个词语
  @param addOne               tf-idf加一平滑
  @param <TERM>               词语类型
  @return 一个词语->倒排文档的Map