hey freiends,,this blog is for Apriory programme which can help you to find frequent itemset.....so just see it
i guess this time you like it....
package apriority;
import java.io.*;
import java.util.*;
/**
*
* @author MAHI
*/
public class APriority {
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Number Of Transaction:");
String s1=br.readLine();
int nt=Integer.parseInt(s1);
int i=0,j=0,k=0,l=0,s=0,x=0,u=0,ms=0,count1=0,count2=0,count3=0,sno=0;
int z1=0,y1=1,l1=0,z2=0,y2=1,l2=0,z3=0,y3=1,l3=0,z4=0,y4=1,l4=0;
String t[][]=new String[100][100];
String Id[]=new String[100];
String m1[]=new String[50];
String m2[]=new String[50];
HashSet hs=new HashSet();
HashSet hs1=new HashSet();
HashSet hs2=new HashSet();
HashSet hs3=new HashSet();
HashSet hs4=new HashSet();
//this part for getting data from user
String temp[]=new String[30];
for(i=0;i<nt;i++)
{
System.out.println("Enter TransactionId:");
Id[i]=br.readLine();
System.out.println("Enter Number Of Items you want to add in this transaction:");
String s3=br.readLine();
int per=Integer.parseInt(s3);
System.out.println("Enter Items:");
for(j=0;j<per;j++)
{
t[i][j]=br.readLine();
temp[k]=t[i][j];
k++;
}
}
int m=k;
System.out.println("Enter Static Number:");
String s4=br.readLine();
sno=Integer.parseInt(s4);
l=1;
int y=0;
//this part is for getting data for C1
for(k=0;k<m;k++)
{
count1=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{y=0;
if(temp[k].equals(t[i][j]))
{
count1++;
if(count1>sno-1)
{
m1[l]=temp[k];
l++;
}
}
j++;
}
}
}
i=1;
y=1;
int q=1;
System.out.println("C1:");
//this part for displaying c1
while(m1[i]!=null)
{
for(j=1;j<i;j++)
{ if(m1[i].equals(m1[j]))
{
y=0;
break;
}
else
{
y=1;
}
}
if(y==1)
{
m2[q]=m1[i];
System.out.print(m1[i]+", ");
q++;
}
i++;
}
if(m2.length<=1)
{
System.out.println("your frequnt itemset is C1:");
return;
}
else
{
ms=1;
//HashSet is used for remove duplicate values
//this loop for gatting data for C2
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
count2=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{ k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
count2++;
if(count2>sno-1)
{
if(m2[s].equals(m2[x]))
{}
else
{
hs.add(m2[s]+m2[x]);
ms++;
break;
}
}
}
k++;
}
}
j++;
}
}
}
}
System.out.println("\nC2:");
Iterator it=hs.iterator();
i=0;
//this loop for printin C2
while(it.hasNext())
{
System.out.print(it.next()+", ");
}
System.out.print("\n");
}
if(hs.size()<=1)
{
System.out.print("your frequnt itemset is C2:");
Iterator it=hs.iterator();
while(it.hasNext())
{
System.out.print(it.next()+", ");
}
return;
}
else
{
//this loop for gettin data for C3
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
z1=x+1;
for(y1=z1;y1<q;y1++)
{
count3=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{
k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
l1=0;
while(t[i][l1]!=null)
{
if(m2[y1].equals(t[i][l1]))
{
count3++;
if(count3>sno-1)
{
hs1.add(m2[s]+m2[x]+m2[y1]);
break;
}
}
l1++;
}
}
k++;
}
}
j++;
}
}
}
}
}
System.out.println("C3:");
Iterator it1=hs1.iterator();
//this loop printin data for C3:
while(it1.hasNext())
{
System.out.print(it1.next()+", ");
}
System.out.print("\n");
}
if(hs1.size()<=1)
{
System.out.print("your frequnt itemset is C3:");
Iterator it1=hs1.iterator();
while(it1.hasNext())
{
System.out.print(it1.next()+", ");
}
return;
}
else
{
//this loop for gettin data for C4
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
z1=x+1;
for(y1=z1;y1<q;y1++)
{
z2=y1+1;
for(y2=z2;y2<q;y2++)
{
count3=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{
k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
l1=0;
while(t[i][l1]!=null)
{
if(m2[y1].equals(t[i][l1]))
{ l2=0;
while(t[i][l2]!=null)
{
if(m2[y2].equals(t[i][l2]))
{
count3++;
if(count3>sno-1)
{
hs2.add(m2[s]+m2[x]+m2[y1]+m2[y2]);
break;
}
}
l2++;
}
}
l1++;
}
}
k++;
}
}
j++;
}
}
}
}
}
}
System.out.println("C4:");
Iterator it2=hs2.iterator();
//this loop printin data for C4:
while(it2.hasNext())
{
System.out.print(it2.next()+", ");
}
System.out.print("\n");
}
if(hs2.size()<=1)
{
System.out.print("your frequnt itemset is C4:");
Iterator it2=hs2.iterator();
while(it2.hasNext())
{
System.out.print(it2.next()+", ");
}
return;
}
else
{
//this loop for gettin data for C5
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
z1=x+1;
for(y1=z1;y1<q;y1++)
{
z2=y1+1;
for(y2=z2;y2<q;y2++)
{
z3=y2+1;
for(y3=z3;y3<q;y3++)
{
count3=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{
k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
l1=0;
while(t[i][l1]!=null)
{
if(m2[y1].equals(t[i][l1]))
{ l2=0;
while(t[i][l2]!=null)
{
if(m2[y2].equals(t[i][l2]))
{ l3=0;
while(t[i][l3]!=null)
{
if(m2[y3].equals(t[i][l3]))
{
count3++;
if(count3>sno-1)
{
hs3.add(m2[s]+m2[x]+m2[y1]+m2[y2]+m2[y3]);
break;
}
}
l3++;
}
}
l2++;
}
}
l1++;
}
}
k++;
}
}
j++;
}
}
}
}
}
}
}
System.out.println("C5:");
Iterator it3=hs3.iterator();
//this loop printin data for C5:
while(it3.hasNext())
{
System.out.print(it3.next()+", ");
}
System.out.print("\n");
}
if(hs3.size()<=1)
{
System.out.print("your frequnt itemset is C5:");
Iterator it3=hs3.iterator();
while(it3.hasNext())
{
System.out.print(it3.next()+", ");
}
return;
}
else
{
//this loop for gettin data for C6
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
z1=x+1;
for(y1=z1;y1<q;y1++)
{
z2=y1+1;
for(y2=z2;y2<q;y2++)
{
z3=y2+1;
for(y3=z3;y3<q;y3++)
{ z4=y3+1;
for(y4=z4;y4<q;y4++)
{
count3=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{
k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
l1=0;
while(t[i][l1]!=null)
{
if(m2[y1].equals(t[i][l1]))
{ l2=0;
while(t[i][l2]!=null)
{
if(m2[y2].equals(t[i][l2]))
{ l3=0;
while(t[i][l3]!=null)
{
if(m2[y3].equals(t[i][l3]))
{
l4=0;
while(t[i][l4]!=null)
{
if(m2[y4].equals(t[i][l4]))
{
count3++;
if(count3>sno-1)
{
hs4.add(m2[s]+m2[x]+m2[y1]+m2[y2]+m2[y3]+m2[y4]);
break;
}
}
l4++;
}
}
l3++;
}
}
l2++;
}
}
l1++;
}
}
k++;
}
}
j++;
}
}
}
}
}
}
}
}
System.out.println("C6:");
Iterator it4=hs4.iterator();
//this loop printin data for C6:
while(it4.hasNext())
{
System.out.print(it4.next()+", ");
}
System.out.print("\n");
}
if(hs4.size()<=1)
{
System.out.print("your frequnt itemset is C6:");
Iterator it4=hs4.iterator();
while(it4.hasNext())
{
System.out.print(it4.next()+", ");
}
return;
}
}
}
i know its very complex....but its work.. if any problem with getting code then tell me i will help you...
thnx for visit....
i guess this time you like it....
package apriority;
import java.io.*;
import java.util.*;
/**
*
* @author MAHI
*/
public class APriority {
public static void main(String args[])throws IOException
{
BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
System.out.println("Enter Number Of Transaction:");
String s1=br.readLine();
int nt=Integer.parseInt(s1);
int i=0,j=0,k=0,l=0,s=0,x=0,u=0,ms=0,count1=0,count2=0,count3=0,sno=0;
int z1=0,y1=1,l1=0,z2=0,y2=1,l2=0,z3=0,y3=1,l3=0,z4=0,y4=1,l4=0;
String t[][]=new String[100][100];
String Id[]=new String[100];
String m1[]=new String[50];
String m2[]=new String[50];
HashSet hs=new HashSet();
HashSet hs1=new HashSet();
HashSet hs2=new HashSet();
HashSet hs3=new HashSet();
HashSet hs4=new HashSet();
//this part for getting data from user
String temp[]=new String[30];
for(i=0;i<nt;i++)
{
System.out.println("Enter TransactionId:");
Id[i]=br.readLine();
System.out.println("Enter Number Of Items you want to add in this transaction:");
String s3=br.readLine();
int per=Integer.parseInt(s3);
System.out.println("Enter Items:");
for(j=0;j<per;j++)
{
t[i][j]=br.readLine();
temp[k]=t[i][j];
k++;
}
}
int m=k;
System.out.println("Enter Static Number:");
String s4=br.readLine();
sno=Integer.parseInt(s4);
l=1;
int y=0;
//this part is for getting data for C1
for(k=0;k<m;k++)
{
count1=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{y=0;
if(temp[k].equals(t[i][j]))
{
count1++;
if(count1>sno-1)
{
m1[l]=temp[k];
l++;
}
}
j++;
}
}
}
i=1;
y=1;
int q=1;
System.out.println("C1:");
//this part for displaying c1
while(m1[i]!=null)
{
for(j=1;j<i;j++)
{ if(m1[i].equals(m1[j]))
{
y=0;
break;
}
else
{
y=1;
}
}
if(y==1)
{
m2[q]=m1[i];
System.out.print(m1[i]+", ");
q++;
}
i++;
}
if(m2.length<=1)
{
System.out.println("your frequnt itemset is C1:");
return;
}
else
{
ms=1;
//HashSet is used for remove duplicate values
//this loop for gatting data for C2
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
count2=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{ k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
count2++;
if(count2>sno-1)
{
if(m2[s].equals(m2[x]))
{}
else
{
hs.add(m2[s]+m2[x]);
ms++;
break;
}
}
}
k++;
}
}
j++;
}
}
}
}
System.out.println("\nC2:");
Iterator it=hs.iterator();
i=0;
//this loop for printin C2
while(it.hasNext())
{
System.out.print(it.next()+", ");
}
System.out.print("\n");
}
if(hs.size()<=1)
{
System.out.print("your frequnt itemset is C2:");
Iterator it=hs.iterator();
while(it.hasNext())
{
System.out.print(it.next()+", ");
}
return;
}
else
{
//this loop for gettin data for C3
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
z1=x+1;
for(y1=z1;y1<q;y1++)
{
count3=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{
k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
l1=0;
while(t[i][l1]!=null)
{
if(m2[y1].equals(t[i][l1]))
{
count3++;
if(count3>sno-1)
{
hs1.add(m2[s]+m2[x]+m2[y1]);
break;
}
}
l1++;
}
}
k++;
}
}
j++;
}
}
}
}
}
System.out.println("C3:");
Iterator it1=hs1.iterator();
//this loop printin data for C3:
while(it1.hasNext())
{
System.out.print(it1.next()+", ");
}
System.out.print("\n");
}
if(hs1.size()<=1)
{
System.out.print("your frequnt itemset is C3:");
Iterator it1=hs1.iterator();
while(it1.hasNext())
{
System.out.print(it1.next()+", ");
}
return;
}
else
{
//this loop for gettin data for C4
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
z1=x+1;
for(y1=z1;y1<q;y1++)
{
z2=y1+1;
for(y2=z2;y2<q;y2++)
{
count3=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{
k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
l1=0;
while(t[i][l1]!=null)
{
if(m2[y1].equals(t[i][l1]))
{ l2=0;
while(t[i][l2]!=null)
{
if(m2[y2].equals(t[i][l2]))
{
count3++;
if(count3>sno-1)
{
hs2.add(m2[s]+m2[x]+m2[y1]+m2[y2]);
break;
}
}
l2++;
}
}
l1++;
}
}
k++;
}
}
j++;
}
}
}
}
}
}
System.out.println("C4:");
Iterator it2=hs2.iterator();
//this loop printin data for C4:
while(it2.hasNext())
{
System.out.print(it2.next()+", ");
}
System.out.print("\n");
}
if(hs2.size()<=1)
{
System.out.print("your frequnt itemset is C4:");
Iterator it2=hs2.iterator();
while(it2.hasNext())
{
System.out.print(it2.next()+", ");
}
return;
}
else
{
//this loop for gettin data for C5
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
z1=x+1;
for(y1=z1;y1<q;y1++)
{
z2=y1+1;
for(y2=z2;y2<q;y2++)
{
z3=y2+1;
for(y3=z3;y3<q;y3++)
{
count3=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{
k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
l1=0;
while(t[i][l1]!=null)
{
if(m2[y1].equals(t[i][l1]))
{ l2=0;
while(t[i][l2]!=null)
{
if(m2[y2].equals(t[i][l2]))
{ l3=0;
while(t[i][l3]!=null)
{
if(m2[y3].equals(t[i][l3]))
{
count3++;
if(count3>sno-1)
{
hs3.add(m2[s]+m2[x]+m2[y1]+m2[y2]+m2[y3]);
break;
}
}
l3++;
}
}
l2++;
}
}
l1++;
}
}
k++;
}
}
j++;
}
}
}
}
}
}
}
System.out.println("C5:");
Iterator it3=hs3.iterator();
//this loop printin data for C5:
while(it3.hasNext())
{
System.out.print(it3.next()+", ");
}
System.out.print("\n");
}
if(hs3.size()<=1)
{
System.out.print("your frequnt itemset is C5:");
Iterator it3=hs3.iterator();
while(it3.hasNext())
{
System.out.print(it3.next()+", ");
}
return;
}
else
{
//this loop for gettin data for C6
for(s=1;s<q;s++)
{
u=s+1;
for(x=u;x<q;x++)
{
z1=x+1;
for(y1=z1;y1<q;y1++)
{
z2=y1+1;
for(y2=z2;y2<q;y2++)
{
z3=y2+1;
for(y3=z3;y3<q;y3++)
{ z4=y3+1;
for(y4=z4;y4<q;y4++)
{
count3=0;
for(i=0;i<nt;i++)
{
j=0;
while(t[i][j]!=null)
{
if(m2[s].equals(t[i][j]))
{
k=0;
while(t[i][k]!=null)
{
if(m2[x].equals(t[i][k]))
{
l1=0;
while(t[i][l1]!=null)
{
if(m2[y1].equals(t[i][l1]))
{ l2=0;
while(t[i][l2]!=null)
{
if(m2[y2].equals(t[i][l2]))
{ l3=0;
while(t[i][l3]!=null)
{
if(m2[y3].equals(t[i][l3]))
{
l4=0;
while(t[i][l4]!=null)
{
if(m2[y4].equals(t[i][l4]))
{
count3++;
if(count3>sno-1)
{
hs4.add(m2[s]+m2[x]+m2[y1]+m2[y2]+m2[y3]+m2[y4]);
break;
}
}
l4++;
}
}
l3++;
}
}
l2++;
}
}
l1++;
}
}
k++;
}
}
j++;
}
}
}
}
}
}
}
}
System.out.println("C6:");
Iterator it4=hs4.iterator();
//this loop printin data for C6:
while(it4.hasNext())
{
System.out.print(it4.next()+", ");
}
System.out.print("\n");
}
if(hs4.size()<=1)
{
System.out.print("your frequnt itemset is C6:");
Iterator it4=hs4.iterator();
while(it4.hasNext())
{
System.out.print(it4.next()+", ");
}
return;
}
}
}
i know its very complex....but its work.. if any problem with getting code then tell me i will help you...
thnx for visit....