i have written following code so far.
But now i am stuck with one porblem.
I have made a loop that exactly modify Numeric Quasi identifier by one by one.
Now problem is:
I hv made loop that modifies exactly once,twice and all four Q.I.(Quasi IDentifier)
How can i make a loop that exactly modify 3 Q.I.?
Also suggest me how can i make this procedure iteratively.As i have made it sequentially.
package CSVRead;
import java.io.*;
import java.util.*;
//import java.util.concurrent.ConcurrentHashMap;
/**
* @author JAL
*/
public class NewClass {
public static HashMap<Integer,String[]> m1 = new HashMap<Integer,String[]>();
public static Map<Integer,String[]> asMap = new TreeMap<Integer,String[]>();
public static HashMap<Integer,String[]> temp = new HashMap<Integer, String[]>();
public static HashMap<Integer,String[]> temp2 = new HashMap<Integer, String[]>();
public static HashMap<Integer,String[]> temp3 = new HashMap<Integer, String[]>();
static int temp11;
public static void main(String args[]) throws IOException
{
//======================================================================
int q,i1,loc[],min[],max[],len[];
//DataInputStream din = new DataInputStream(System.in);
Scanner input=new Scanner(System.in);
System.out.println("Enter No. of Quasi Idenifier =");
//q=Integer.parseInt(din.readLine());
q=input.nextInt();
loc= new int[q];
min=new int[q];
max=new int[q];
len=new int[q];
for(i1=0;i1<q;i1++)
{
System.out.println("Enter "+i1+"th Quasi identifier location :");
//loc[i1]=Integer.parseInt(din.readLine());
loc[i1]=input.nextInt();
min[i1]=Integer.MAX_VALUE;
max[i1]=Integer.MIN_VALUE;
len[i1]=0;
}
System.out.println("Enter the value of K=");
int k=input.nextInt();
//=========================================================================================================
BufferedReader CSVFile = new BufferedReader(new FileReader("original dataset1.csv"));
String dataRow = CSVFile.readLine();
int count=1;
int count1 = 1;
while(dataRow!=null)
{
String dataArray[] = dataRow.split(",");
String dataArray1[] = dataRow.split(",");
m1.put(count, dataArray1);
temp.put(count1, dataArray);
count++;
count1++;
dataRow=CSVFile.readLine();
}
int a = m1.size();
//====== First Pass ============================================================
calc1(a,asMap,q,loc,k,temp);
//======FIND MIN AND MAX FROM REMAINING VALUE OF Temp========================================
int p1=temp.size();
System.out.println("length of map temp = "+p1);
Set s1=temp.keySet();
Iterator it=s1.iterator();
while(it.hasNext())
{
String[] aa1=temp.get(it.next());
for(int p=0;p<q;p++)
{
System.out.print(aa1[loc[p]]+"\t");
}
for(int p=0;p<q;p++)
{
if( min[p] > Integer.parseInt(aa1[loc[p]]))
{
min[p] = Integer.parseInt(aa1[loc[p]]);
}
if( max[p] < Integer.parseInt(aa1[loc[p]]))
{
max[p] = Integer.parseInt(aa1[loc[p]]);
}
if(min[p]<0)
{
len[p]=Integer.toString(min[p]).length()-1;
if(len[p]>Integer.toString(max[p]).length())
len[p]=Integer.toString(min[p]).length();
else
len[p]=Integer.toString(max[p]).length();
}
else
{
len[p]=Integer.toString(min[p]).length();
if(len[p]>Integer.toString(max[p]).length())
len[p]=Integer.toString(min[p]).length();
else
len[p]=Integer.toString(max[p]).length();
}
}
System.out.println();
}
for(int p=0;p<q;p++)
{
System.out.println("Quasi identifier "+loc[p]+" minimum value "+min[p]);
System.out.println("Quasi identifier "+loc[p]+" maximum value "+max[p]);
System.out.println("Quasi identifier "+loc[p]+" length is "+len[p]);
}
//======================================================================================
int ano=0,flag=1;
int ja[]= new int[q];
double[] anon_gain = new double[q];
ArrayList<Integer> arrskip = new ArrayList<Integer>();
for(int b=0;b<q;b++)
{
ano=0;
for(int r = 0;r<q;r++)
{
Set s = temp.keySet();
Iterator it1 = s.iterator();
int map_size = s.size();
System.out.println("\n"+s);
StringBuilder sb = null;
int rep=0;
if(arrskip.contains(r))
{
//break;
continue;
}
else
{
while(it1.hasNext())
{
String[] a1 = temp.get((Integer)it1.next());
System.out.println("\n /////////////////////////////////////////////////////////////////////////");
if(len[r]>2 && !(a1[loc[r]].endsWith("*")))
{
if(a1[loc[r]].length()==1)
{
sb = new StringBuilder(a1[loc[r]]);
sb.setCharAt(0,'*');
a1[loc[r]]=sb.toString();
}
else
{
sb = new StringBuilder(a1[loc[r]]);
rep = a1[loc[r]].length()-1;
sb.setCharAt(rep,'*');
a1[loc[r]]=sb.toString();
}
}
if(len[r]<=2)
{
int x = Integer.parseInt(a1[loc[r]]);
if(x>=0 && x<5){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[0-5]");}
if (x >= 5 && x < 10) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[5-10]");}
if (x >= 10 && x < 15) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[10-15]");}
if(x >= 15 && x < 20) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[15-20]");}
if(x >= 20 && x < 25) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[20-25]");}
if(x >= 25 && x < 30) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[25-30]");}
if(x >= 30 && x < 35) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[30-35]");}
if(x>=35 && x<40){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[35-40]");}
if(x>=40 && x<45){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[40-45]");}
if(x>=45 && x<50){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[45-50]");}
if(x>=50 && x<55){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[50-55]");}
if(x>=55 && x<60){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[55-60]");}
if(x>=60 && x<65){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[60-65]");}
if(x>=65 && x<70){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[65-70]");}
if(x>=70 && x<75){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[70-75]");}
if(x>=75 && x<80){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[75-80]");}
if(x>=80 && x<85){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[80-85]");}
if(x>=85 && x<90){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[85-90]");}
if(x>=90 && x<95){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[90-95]");}
if(x>=95 && x<100){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[95-100]");}
if(x>=100 && x<2000){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[100-2000]");}
}
for(int as=0;as<a1.length;as++)
{
System.out.print(a1[as]+" \t");
}
}
ja[r]=test(a,asMap,q,loc,k,temp);
ano=ano_gain(r,ja,loc,map_size,q,ano,anon_gain);
System.out.println("\nvalue to ano q.i = "+loc[ano]+" location is = "+ano);
replace(m1,temp);
}
}
vis(a,ano,temp,q,len,loc,k);
for(Map.Entry<Integer, String[]> mapEntry2 : temp.entrySet())
{
int key3 = mapEntry2.getKey();
//System.out.print("\nvalue of key3 = "+key3);
String[] aa5 = (String[]) temp.get(key3);
String[] newAA = new String[aa5.length]; // create a new array with the same length
System.arraycopy(aa5, 0, newAA, 0, aa5.length);
temp2.put(key3, newAA);
}
replace(m1,temp);
arrskip.add((Integer)ano);
}
//=========================================================================================
System.out.println("========== Map - asMap =============================================");
//=========================================================================================
//=================================================================================================
//2nd time
arrskip.clear();
for(int b=0;b<q;b++){
ano=0;
for(int r = 0;r<q;r++)
{
Set s = temp.keySet();
Iterator it1 = s.iterator();
int map_size = s.size();
System.out.println("\n"+s);
StringBuilder sb = null;
int rep=0;
if(arrskip.contains(r))
{
continue;
}
else
{
while(it1.hasNext())
{
String[] a1 = temp.get((Integer)it1.next());
System.out.println("\n /////////////////////////////////////////////////////////////////////////");
if(len[r]>2 && !(a1[loc[r]].endsWith("*")))
{
if(a1[loc[r]].length()==1)
{
sb = new StringBuilder(a1[loc[r]]);
//rep = a1[loc[r]].length()-1;
sb.setCharAt(0,'*');
a1[loc[r]]=sb.toString();
}
else
{
sb = new StringBuilder(a1[loc[r]]);
rep = a1[loc[r]].length()-1;
sb.setCharAt(rep,'*');
a1[loc[r]]=sb.toString();
}
}
if(len[r]<=2 && !(a1[loc[r]].endsWith("]")))
{
int x = Integer.parseInt(a1[loc[r]]);
if(x>=0 && x<5){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[0-5]");}
if (x >= 5 && x < 10) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[5-10]");}
if (x >= 10 && x < 15) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[10-15]");}
if(x >= 15 && x < 20) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[15-20]");}
if(x >= 20 && x < 25) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[20-25]");}
if(x >= 25 && x < 30) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[25-30]");}
if(x >= 30 && x < 35) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[30-35]");}
if(x>=35 && x<40){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[35-40]");}
if(x>=40 && x<45){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[40-45]");}
if(x>=45 && x<50){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[45-50]");}
if(x>=50 && x<55){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[50-55]");}
if(x>=55 && x<60){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[55-60]");}
if(x>=60 && x<65){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[60-65]");}
if(x>=65 && x<70){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[65-70]");}
if(x>=70 && x<75){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[70-75]");}
if(x>=75 && x<80){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[75-80]");}
if(x>=80 && x<85){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[80-85]");}
if(x>=85 && x<90){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[85-90]");}
if(x>=90 && x<95){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[90-95]");}
if(x>=95 && x<100){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[95-100]");}
if(x>=100 && x<2000){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[100-2000]");}
}
for(int as=0;as<a1.length;as++)
{
System.out.print(a1[as]+" \t");
}
}
}
ja[r]=test(a,asMap,q,loc,k,temp);
if(ja[r]>0){flag = 0;}else{flag = 1;}
ano=ano_gain(r,ja,loc,map_size,q,ano,anon_gain);
System.out.println("\nvalue to ano q.i = "+loc[ano]+" location is = "+ano);
replace(temp2,temp);
}
vis(a,ano,temp,q,len,loc,k);
for(Map.Entry<Integer, String[]> mapEntry2 : temp.entrySet())
{
int key3 = mapEntry2.getKey();
//System.out.print("\nvalue of key3 = "+key3);
String[] aa5 = (String[]) temp.get(key3);
String[] newAA = new String[aa5.length]; // create a new array with the same length
System.arraycopy(aa5, 0, newAA, 0, aa5.length);
temp3.put(key3, newAA);
}
replace(m1,temp);
arrskip.add((Integer)ano);
}
//3rd time*/
//**********************************************************
System.out.println("Size of temp map is = "+temp.size());
System.out.println("Size of temp asMap is = "+asMap.size());
System.out.println("Size of temp temp3 is = "+temp3.size());
//=================================0000==========================
for(Map.Entry<Integer, String[]> mapEntry1 : temp3.entrySet())
{
int key2 = mapEntry1.getKey();
String[] aaa=mapEntry1.getValue();
System.out.print("Key=> "+key2);
for(int p=0;p<aaa.length;p++)
{
System.out.print("\t"+aaa[p]+"\t");
}
System.out.println();
}
arrskip.clear();
replace(m1,temp);
for(int r=0;r<q;r++)
{
Set s = temp.keySet();
Iterator it1 = s.iterator();
int map_size = s.size();
System.out.println("\n"+s);
StringBuilder sb = null;
int rep=0;
if(arrskip.contains(r))
{
continue;
}
else
{
while(it1.hasNext())
{
String[] a1 = temp.get((Integer)it1.next());
System.out.println("\n /////////////////////////////////////////////////////////////////////////");
if(len[r]>2 && !(a1[loc[r]].endsWith("*")))
{
if(a1[loc[r]].length()==1)
{
sb = new StringBuilder(a1[loc[r]]);
sb.setCharAt(0,'*');
a1[loc[r]]=sb.toString();
}
else
{
sb = new StringBuilder(a1[loc[r]]);
rep = a1[loc[r]].length()-1;
sb.setCharAt(rep,'*');
a1[loc[r]]=sb.toString();
}
}
if(len[r]<=2 && !(a1[loc[r]].endsWith("]")))
{
int x = Integer.parseInt(a1[loc[r]]);
if(x>=0 && x<5){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[0-5]");}
if (x >= 5 && x < 10) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[5-10]");}
if (x >= 10 && x < 15) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[10-15]");}
if(x >= 15 && x < 20) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[15-20]");}
if(x >= 20 && x < 25) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[20-25]");}
if(x >= 25 && x < 30) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[25-30]");}
if(x >= 30 && x < 35) {a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x), "[30-35]");}
if(x>=35 && x<40){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[35-40]");}
if(x>=40 && x<45){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[40-45]");}
if(x>=45 && x<50){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[45-50]");}
if(x>=50 && x<55){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[50-55]");}
if(x>=55 && x<60){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[55-60]");}
if(x>=60 && x<65){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[60-65]");}
if(x>=65 && x<70){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[65-70]");}
if(x>=70 && x<75){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[70-75]");}
if(x>=75 && x<80){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[75-80]");}
if(x>=80 && x<85){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[80-85]");}
if(x>=85 && x<90){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[85-90]");}
if(x>=90 && x<95){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[90-95]");}
if(x>=95 && x<100){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[95-100]");}
if(x>=100 && x<2000){a1[loc[r]] = a1[loc[r]].replace(String.valueOf(x),"[100-2000]");}
}
for(int as=0;as<a1.length;as++)
{
System.out.print(a1[as]+" \t");
}
}
}
ja[r]=test(a,asMap,q,loc,k,temp);
if(ja[r]>0){flag = 0;}else{flag = 1;}
ano=ano_gain(r,ja,loc,map_size,q,ano,anon_gain);
System.out.println("\nvalue to ano q.i = "+loc[ano]+" location is = "+ano);
}
vis(a,ano,temp,q,len,loc,k);
System.out.println("Size of temp map is = "+temp.size());
System.out.println("Size of temp asMap is = "+asMap.size());
System.out.println("Size of temp temp3 is = "+temp3.size());
}
public static void replace(HashMap<Integer,String[]> m1,HashMap<Integer,String[]> temp)
{
for(Map.Entry<Integer, String[]> mapEntry2 : temp.entrySet())
{
int key3 = mapEntry2.getKey();
//System.out.print("\nvalue of key3 = "+key3);
String[] aa5 = (String[]) m1.get(key3);
String[] newAA = new String[aa5.length]; // create a new array with the same length
System.arraycopy(aa5, 0, newAA, 0, aa5.length);
temp.put(key3, newAA);
}
}
public static int ano_gain(int r,int[] ja,int[] loc,int map_size,int q,int an,double[] anon_gain)
{
System.out.println("\nValue inside ano_gain loop r = "+r);
anon_gain[r] = (ja[r]*100)/map_size;
System.out.println("\nAnonymity gain = "+anon_gain[r]+" %");
System.out.println("\nNo. of tuples anonymized at Q.I. "+loc[r]+" = "+ja[r]);
System.out.println("\ninside gain b4 Value of temp11="+temp11+" and value of an = "+an);
if(r==0){temp11=(int)anon_gain[0];}
if(r>0)
{
if((int)anon_gain[r]>temp11)
{
temp11 = (int) anon_gain[r];
an = r;
}
}
System.out.println("\ninside gain after Value of temp11="+temp11+" and value of an = "+an);
return an;
}
public static void disp(Map<Integer,String[]> m1,Map<Integer,String[]> asMap,Map<Integer,String[]> temp)
{
System.out.println("\n=============== MAP - m1============================================");
for(Map.Entry<Integer,String[]> mapEntry: m1.entrySet())
{
int key1 = mapEntry.getKey();
String[] aa4=(String[]) mapEntry.getValue();
System.out.print("Key=> "+key1);
for(int p=0;p<aa4.length;p++)
{
System.out.print("\t"+aa4[p]+"\t");
}
System.out.println();
}
System.out.println("========== Map - asMap =============================================");
//=========================================================================================
for(Map.Entry<Integer, String[]> mapEntry1 : asMap.entrySet())
{
int key2 = mapEntry1.getKey();
String[] aaa=mapEntry1.getValue();
System.out.print("Key=> "+key2);
for(int p=0;p<aaa.length;p++)
{
System.out.print("\t"+aaa[p]+"\t");
}
System.out.println();
}
//==========================================================================================
System.out.println("--------------- Map - temp ------------------------------------------");
for(Map.Entry<Integer, String[]> mapEntry2 : temp.entrySet())
{
int key3 = mapEntry2.getKey();
String[] aa5=mapEntry2.getValue();
System.out.print("Key=> "+key3);
for(int p=0;p<aa5.length;p++)
{
System.out.print("\t "+aa5[p]+"\t");
}
System.out.println();
}
}
public static void calc1(int a,Map asMap,int q,int loc[],int k,Map temp)
{
int am[]=new int[a];
int row[]=new int[a];
int remove[] = new int[a];
int flagp[] = new int[a];
int f1[] = new int[a];
for(int t=0;t<a;t++){am[t]=0; row[t]=0;remove[t]=0;flagp[t]=0;f1[t]=0;}
for(int j=1;j<=a;j++)
{
//System.out.println("Value of j = "+j);
int cnt1=0;
if(am[j-1]==1)
{
//break;
continue;
}
else
{
for(int p=j+1;p<=a;p++)
{
//System.out.println("Value of p = "+p);
//System.out.println("hello");
String[] aa2=null;
String[] aa3=null;
if(temp.containsKey(j))
{
aa2 = (String[]) temp.get(j);
}
else{continue;}
if(temp.containsKey(p))
{
aa3 = (String[]) temp.get(p);
}
else{continue;}
int h=0;
int cnt=0;
while(h<q)
{
if(aa2[loc[h]].equals(aa3[loc[h]]))
{
cnt++;
}
h++;
}
if(cnt==q)
{
remove[j-1]=1;
remove[p-1]=1;
cnt1++;
am[p-1]=1;
row[j-1]=cnt1+1;
}
}
if(row[j-1]>=k)
{
for(int p1=j-1;p1<a;p1++)
{
if(remove[p1]==1 && flagp[p1]==0)
{
flagp[p1]=1;
f1[p1]=p1+1;
asMap.put(p1+1,temp.get(p1+1));
}
}
}
}
}
for(int jj=0;jj<f1.length;jj++)
{
if(f1[jj]!=0)
if(temp.containsKey(f1[jj]))
{
temp.remove(f1[jj]);
}
else
{
System.out.println("No such key is found...so value doesn't deleted");
}
}
}
public static int test(int a,Map asMap,int q,int loc[],int k,Map temp)
{
int am[]=new int[a];
int row[]=new int[a];
int remove[] = new int[a];
int flagp[] = new int[a];
int f1[] = new int[a];
for(int t=0;t<a;t++){am[t]=0; row[t]=0;remove[t]=0;flagp[t]=0;f1[t]=0;}
for(int j=1;j<=a;j++)
{
int cnt1=0;
if(am[j-1]==1)
{
continue;
}
else
{
for(int p=j+1;p<=a;p++)
{
String[] aa2=null;
String[] aa3=null;
if(temp.containsKey(j))
{
aa2 = (String[]) temp.get(j);
}
else{continue;}
if(temp.containsKey(p))
{
aa3 = (String[]) temp.get(p);
}
else{continue;}
int h=0;
int cnt=0;
while(h<q)
{
if(aa2[loc[h]].equals(aa3[loc[h]]))
{
cnt++;
}
h++;
}
if(cnt==q)
{
remove[j-1]=1;
remove[p-1]=1;
cnt1++;
am[p-1]=1;
row[j-1]=cnt1+1;
}
}
if(row[j-1]>=k)
{
for(int p1=j-1;p1<a;p1++)
{
if(remove[p1]==1 && flagp[p1]==0)
{
flagp[p1]=1;
f1[p1]=p1+1;
}
}
}
}
}
int counter=0;
for(int jj=0;jj<f1.length;jj++)
{
if(f1[jj]!=0)
if(temp.containsKey(f1[jj]))
{
counter++;
}
else
{
System.out.println("No such key is found...so value doesn't deleted");
}
}
return counter;
}
private static void vis(int a,int ano, Map temp,int q,int[] len,int[] loc,int k) {
Set s = temp.keySet();
Iterator it1 = s.iterator();
StringBuilder sb = null;
int rep=0;
System.out.println("size of temp b4 anon = "+s.size());
while(it1.hasNext())
{
String[] a1 = (String[]) temp.get((Integer)it1.next());
if(len[ano]>2 && !(a1[loc[ano]].endsWith("*")))
{
if(a1[loc[ano]].length()==1)
{
sb = new StringBuilder(a1[loc[ano]]);
//rep = a1[loc[r]].length()-1;
sb.setCharAt(0,'*');
a1[loc[ano]]=sb.toString();
}
else
{
sb = new StringBuilder(a1[loc[ano]]);
rep = a1[loc[ano]].length()-1;
sb.setCharAt(rep,'*');
a1[loc[ano]]=sb.toString();
}
}
if(len[ano]<=2 && !(a1[loc[ano]].endsWith("]")))
{
int x = Integer.parseInt(a1[loc[ano]]);
if(x>=0 && x<5){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[0-5]");}
if (x >= 5 && x < 10) {a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x), "[5-10]");}
if (x >= 10 && x < 15) {a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x), "[10-15]");}
if(x >= 15 && x < 20) {a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x), "[15-20]");}
if(x >= 20 && x < 25) {a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x), "[20-25]");}
if(x >= 25 && x < 30) {a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x), "[25-30]");}
if(x >= 30 && x < 35) {a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x), "[30-35]");}
if(x>=35 && x<40){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[35-40]");}
if(x>=40 && x<45){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[40-45]");}
if(x>=45 && x<50){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[45-50]");}
if(x>=50 && x<55){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[50-55]");}
if(x>=55 && x<60){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[55-60]");}
if(x>=60 && x<65){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[60-65]");}
if(x>=65 && x<70){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[65-70]");}
if(x>=70 && x<75){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[70-75]");}
if(x>=75 && x<80){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[75-80]");}
if(x>=80 && x<85){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[80-85]");}
if(x>=85 && x<90){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[85-90]");}
if(x>=90 && x<95){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[90-95]");}
if(x>=95 && x<100){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[95-100]");}
if(x>=100 && x<2000){a1[loc[ano]] = a1[loc[ano]].replace(String.valueOf(x),"[100-2000]");}
}
}
calc1(a,asMap,q,loc,k,temp);
Set ss1=temp.keySet();
System.out.println("size of temp after anon = "+ss1.size());
}
}
Thanks
I have also attached dataset1.csv file that i have used.(just remove the .txt extension)
And when you run your program, input given is
No. of Q.I.
4
Location of Q.I. 0
1
Location of Q.I. 1
3
Location of Q.I. 2
4
Location of Q.I. 3
6
Value of k
3
please reply me as soon as possible.
Again thanks in advance.