Salut a tous ,
voici un bout de code de mon programme
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82
|
// for every attribute not mentioned in the rule
enumAtt = ruleE.enumerateAttributes();
while (enumAtt.hasMoreElements())
{
Attribute attr = (Attribute) enumAtt.nextElement();
if (isMentionedIn(attr, r.m_test)) {continue;}
int M = attr.numValues();
for (int val = 0; val < M; val ++) // ... for each value of this attribute
{
PrismRule cr = addRule(null , new PrismRule(data, r.m_classification));
for(int l=0 ; l< r.testSet.size();l++){ cr.testSet.add( r.testSet.get(l)); }
Test Tst3 =new Test() ;
Tst3.m_attr=attr.index();
Tst3.m_val=val;
cr.testSet.add(Tst3);
if(cr.testSet.size()==1) { cr.m_test = cr.testSet.get(0);}
else if (cr.testSet.size()>1 ) { // il faut au moins 2 règles pour qu'il y ait un lien entre règles
cr.m_test = cr.testSet.get(0);
Test g=cr.m_test;
for(int i=1; i<cr.testSet.size(); i++) { // on commence à la 2ème règle dans la liste (la première c'est previous);
g.m_next =cr.testSet.get(i); // la suivante de previous, c'est la règle courante de l'itération
g=g.m_next; // la nouvelle règle qu'on va traiter l'itération suivante, est la suivante de celle qu'on vient de traiter.
}
}
System.out.println("regle added ==== "+cr);
CR.add(cr);
}
}
for(int m=0;m<CR.size();m++){System.out.println("regle num ["+m+"]==== "+CR.get(m));}
List<PrismRule> CR1= new ArrayList<PrismRule>();
CR1=CR;
System.out.print("les regle "+CR.get(4).toString());
return CR ;
} |
la ligne
System.out.println("regle added ==== "+cr);
me donne :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26
| regle added ==== If length = small
and color = Red then True
regle added ==== If length = small
and color = Green then True
regle added ==== If length = small
and color = Blue then True
regle added ==== If length = small
and age = young then True
regle added ==== If length = small
and age = old then True
regle added ==== If length = small
and neighbors = 1 then True
regle added ==== If length = small
and neighbors = 2-to-4 then True
regle added ==== If length = small
and neighbors = 5-to-9 then True
regle added ==== If length = small
and neighbors = more-than-10 then True |
par contre la ligne
1 2
|
for(int m=0;m<CR.size();m++){System.out.println("regle num ["+m+"]==== "+CR.get(m));} |
m'affiche :
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29
| regle num [0]==== If length = small
and neighbors = more-than-10 then True
regle num [1]==== If length = small
and neighbors = more-than-10 then True
regle num [2]==== If length = small
and neighbors = more-than-10 then True
regle num [3]==== If length = small
and neighbors = more-than-10 then True
regle num [4]==== If length = small
and neighbors = more-than-10 then True
regle num [5]==== If length = small
and neighbors = more-than-10 then True
regle num [6]==== If length = small
and neighbors = more-than-10 then True
regle num [7]==== If length = small
and neighbors = more-than-10 then True
regle num [8]==== If length = small
and neighbors = more-than-10 then True
les regle If length = small
and neighbors = more-than-10 then True |
je comprend pas pourquoi , car en princice CR qui est la liste "afficher en 2eme position" n'est que les cr "afficher en 1ere position" collecter ,
pourqoi CR ne contient que la derniere cr calculer !!!!
Partager