public Map<Integer, Integer> compact() {
		Map<Integer, Integer> equiv = new HashMap<Integer, Integer>();

		TreeMap<Integer, int[]> newIndex2docfreq = new TreeMap<Integer, int[]>();

		// iterate on the map token -> Id and change the latter
		Iterator<Entry<String, int[]>> iter = tokenForm2index.entrySet().iterator();
		nextAttributeID = 1;
		while (iter.hasNext()) {
			Entry<String, int[]> entry = iter.next();
			int oldIndex = entry.getValue()[0];
			int newIndex = nextAttributeID;
			entry.setValue(new int[] { newIndex });
			// store the equivalence in the map
			equiv.put(oldIndex, newIndex);
			// populate the doc freq
			int[] docFreq = index2docfreq.get(oldIndex);
			newIndex2docfreq.put(newIndex, docFreq);
			nextAttributeID++;
		}

		// swap the doc freq
		index2docfreq = newIndex2docfreq;

		return equiv;
	}
public Map < Integer , Integer > compact ( ) { Map < Integer , Integer > equiv = new HashMap < Integer , Integer > ( ) ; TreeMap < Integer , int [ ] > newIndex2docfreq = new TreeMap < Integer , int [ ] > ( ) ; Iterator < Entry < String , int [ ] > > iter = tokenForm2index . entrySet ( ) . iterator ( ) ; nextAttributeID = 1 ; while ( iter . hasNext ( ) ) { Entry < String , int [ ] > entry = iter . next ( ) ; int oldIndex = entry . getValue ( ) [ 0 ] ; int newIndex = nextAttributeID ; entry . setValue ( new int [ ] { newIndex } ) ; equiv . put ( oldIndex , newIndex ) ; int [ ] docFreq = index2docfreq . get ( oldIndex ) ; newIndex2docfreq . put ( newIndex , docFreq ) ; nextAttributeID ++ ; } index2docfreq = newIndex2docfreq ; return equiv ; }
Adjust the indices of the attributes so that maxAttributeID ==
getAttributesNum. Returns a Map containing the mapping between the old
indices and the new ones.