<commit_before>/**
 * 
 */
package cs2020;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;

/**
 * @author vishnu
 *
 */
public class PremPS5 {

	/**
	 * 
	 */
	public PremPS5() {
		// TODO Auto-generated constructor stub
	}

	public static void main(String[] args) {
		StopWatch sw = new StopWatch();
		sw.start();
		HashMap<Integer, Pair> hm = new HashMap<Integer, Pair>();
		try {
			FileReader dataFile = new FileReader(args[0]);
	        BufferedReader bufferedDataFile = new BufferedReader(dataFile);
	        bufferedDataFile.readLine(); // discarding size
	        
	        String line;
	        
	        while ((line = bufferedDataFile.readLine()) != null) {
	        	String sLine = line;
	        	Pair p;
	        	p = hm.get(sLine.length());
	        	if(p==null) {
	        		p = new Pair(new HashSet<StringComparator>(), 0);
	        		hm.put(sLine.length(), p);
	        	}
	        	
	        	if(p.hs.contains(new StringComparator(sLine))) p.count++;
	        	else p.hs.add(new StringComparator(sLine));
			}
	        int count = 0;
	        for(Pair p : hm.values()) {
	        	if(p.count==0) continue;
	        	count += (p.count*(p.count+1))/2;
	        }
	        sw.stop();
	        System.out.println(count + " " + sw.getTime());
		} catch (Exception e) {
			System.out.println(e);
		}
	}
}

class Pair {
	HashSet<StringComparator> hs; int count;
	public Pair(HashSet<StringComparator> hs, int count) {
		this.hs = hs;
		this.count = count;
	}
}

class StringComparator {
	String str;
	public StringComparator(String str) {
		this.str = stringSort(str);
	}
	/* (non-Javadoc)
	 * @see java.lang.Object#equals(java.lang.Object)
	 */
	@Override
	public boolean equals(Object obj) {
		StringComparator sc = (StringComparator) obj;
		return str.equals(sc.str);
	}
	
	@Override
	public int hashCode() {
		// TODO Auto-generated method stub
		return str.hashCode();
	}
	private static String stringSort(String str) {
		char[] a = str.toCharArray();
		Arrays.sort(a);
		return new String(a);
	}
}<commit_msg>Revert "Stringcomparator method"<commit_after>/**
 * 
 */
package cs2020;

import java.io.BufferedReader;
import java.io.FileReader;
import java.util.Arrays;
import java.util.Comparator;
import java.util.HashMap;
import java.util.HashSet;

/**
 * @author vishnu
 *
 */
public class PremPS5 {

	/**
	 * 
	 */
	public PremPS5() {
		// TODO Auto-generated constructor stub
	}

	public static void main(String[] args) {
		StopWatch sw = new StopWatch();
		sw.start();
		HashMap<Integer, Pair> hm = new HashMap<Integer, Pair>();
		try {
			FileReader dataFile = new FileReader(args[0]);
	        BufferedReader bufferedDataFile = new BufferedReader(dataFile);
	        bufferedDataFile.readLine(); // discarding size
	        
	        String line;
	        
	        while ((line = bufferedDataFile.readLine()) != null) {
	        	String sLine = stringSort(line);
	        	Pair p;
	        	p = hm.get(sLine.length());
	        	if(p==null) {
	        		p = new Pair(new HashSet<String>(), 0);
	        		hm.put(sLine.length(), p);
	        	}
	        	
	        	if(p.hs.contains(sLine)) p.count++;
	        	else p.hs.add(sLine);
			}
	        int count = 0;
	        for(Pair p : hm.values()) {
	        	if(p.count==0) continue;
	        	count += (p.count*(p.count+1))/2;
	        }
	        sw.stop();
	        System.out.println(count + " " + sw.getTime());
		} catch (Exception e) {
			System.out.println(e);
		}
	}
	
	private static String stringSort(String str) {
		char[] a = str.toCharArray();
		Arrays.sort(a);
		return new String(a);
	}
}

class Pair {
	HashSet<String> hs; int count;
	public Pair(HashSet<String> hs, int count) {
		this.hs = hs;
		this.count = count;
	}
}

	/* (non-Javadoc)
	 * @see java.util.Comparator#compare(java.lang.Object, java.lang.Object)
	 */
	@Override
	public int compare(String o1, String o2) {
		if(o1.length() < o2.length()) return -1;
		else if(o1.length() > o2.length()) return 1;
		return 0;
	}
	
}
{'fraction_non_alphanumeric': 0.1465917419985341, 'fraction_numerical': 0.008062545809919374, 'mean_word_length': 2.499145299145299, 'pattern_counts': {'":': 0, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7120075', 'n_tokens_mistral': 1528, 'n_tokens_neox': 1397, 'n_words': 305}