public void cutoff(int threshold) {
    List<Integer> ls = new ArrayList<Integer>();
    int dim = this.bags[0].length;
    ls.add(0);                  // oov
    for ( int j = 1; j < dim; ++j ) {
      boolean allzero = true;
      for ( int i = 0; i < this.bags.length; ++i ) {
        if ( this.bags[i][j] > threshold ) {
          allzero = false;
          break;
        }
      }
      if ( !allzero ) {
        ls.add(j);
      }
    }
    if ( ls.size() > 0 ) {
      for ( int i = 0; i < this.bags.length; ++i ) {
        int[] a = new int [ls.size()];
        int n = 0;
        for ( int j: ls) {
          a[n] = this.bags[i][j];
          n++;
        }
        this.bags[i] = a;
      }
      List<Metrics> a = new ArrayList<Metrics>();
      Map<Metrics, Integer> b = new TreeMap<Metrics,Integer>();
      List<Double> c = new ArrayList<Double>();
      for ( int j: ls) {
        a.add(this.codes.get(j));
        b.put(this.codes.get(j), b.size());
        c.add(this.weights.get(j));
      }
      this.codes = a;
      this.codeIndex = b;
      this.weights = c;
    }
  }