1 Reply Latest reply: May 14, 2012 7:17 AM by plk RSS

    SOME LOGICAL ERROR

    925053
      sir i write code for finding freuent pattern but it give some logical error plz see that and correct that

      i send the complete information to u my input file my project code my output file and my actual output that i need ......plz sir chek it where is he logical mistak in code i completely chek lots of time i m not able to find where is the logical mistak plz sir help me

      input file "transactions.xml"

      <?xml version="1.0" standalone="yes"?>
      <transactions>
      <transaction id="1">
      <items>
      <item>a</item>
      <item>d</item>
      <item>e</item>
      </items>
      </transaction>
      <transaction id="2">
      <items>
      <item>b</item>
      <item>c</item>
      <item>d</item>
      </items>
      </transaction>
      <transaction id="3">
      <items>
      <item>a</item>
      <item>c</item>
      <item>e</item>
      </items>
      </transaction>
      <transaction id="4">
      <items>
      <item>b</item>
      <item>c</item>
      <item>d</item>
      </items>
      </transaction>
      <transaction id="5">
      <items>
      <item>a</item>
      <item>b</item>

      </items>
      </transaction>
      </transactions>

      coding :=

      xquery version "1.0";
      declare namespace local = "http://www.w3.org/2003/11/xpath-local-functions";

      declare function local:join($X as element()*, $Y as element()*) as element()* {
      let $items := (for $item in $Y
      where every $i in $X satisfies
      $i != $item
      return $item)
      return $X union $items
      };

      declare function local:commonIts($X as element()*, $Y as element()*) as element()* {
      for $item in $X
      where some $i in $Y satisfies $i = $item
      return $item
      };

      declare function local:removeIts($X as element()*, $Y as element()*) as element()* {
      for $item in $X
      where every $i in $Y satisfies $i != $item
      return $item
      };

      declare function local:candidateGen($l as element()*) as element()* {
      for $freqSet1 in $l
      let $items1 := $freqSet1//items/*
      for $freqSet2 in $l
      let $items2 := $freqSet2//items/*
      where $freqSet2 >> $freqSet1 and
      count($items1)+1 = count($items1 union $items2)
      and local:prune(local:join($items1,$items2), $l)
      return
      <items>{local:join($items1,$items2)}</items>
      };

      declare function local:prune($X as element()*, $Y as element()*) as xs:boolean
      {
      every $item in $X satisfies
      some $items in $Y//items satisfies
      count(local:commonIts(local:removeIts($X,$item),$items/*))
      = count($X) - 1
      };

      declare function local:removeDuplicate($C as element()*) as element()*
      {
      for $itemset1 in $C
      let $items1 := $itemset1/*
      let $items :=(for $itemset2 in $C
      let $items2 := $itemset2/*
      where $itemset2>>$itemset1 and
      count($items1) =
      count(local:commonIts($items1, $items2))
      return $items2)
      where count($items) = 0
      return $itemset1
      };

      declare function local:getLargeItemsets($C as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()*) as element()*
      {
      for $items in $C
      let $trans := (for $tran in $src
      where every $item1 in $items/* satisfies
      some $item2 in $tran/*
      satisfies $item1 = $item2
      return $tran)
      let $sup := (count($trans) * 1.00) div $total
      where $sup >= $minsup
      return <largeItemset> {$items}
      <support> {$sup} </support>
      </largeItemset>
      };

      declare function local:fp-growth($l as element()*, $L as element()*, $minsup as xs:decimal, $total as xs:decimal, $src as element()*) as element()*
      {
      let $C := local:removeDuplicate(local:candidateGen($l))
      let $l := local:getLargeItemsets($C, $minsup, $total, $src)
      let $L := $l union $L
      return if (empty($l)) then
      $L
      else
      local:fp-growth($l, $L, $minsup, $total, $src)
      };

      let $src := doc("transactions.xml")//items

      let $minsup := 0.5
      let $total := count($src) * 1.00
      let $C := distinct-values($src/*)
      let $l :=(for $itemset in $C
      let $items := (for $item in $src/*
      where $itemset = $item
      return $item)
      let $sup := (count($items) * 1.00) div $total
      where $sup >= $minsup
      return <largeItemset>
      <items> {$itemset} </items>
      <support> {$sup} </support>
      </largeItemset>)
      let $L := $l
      return <largeItemsets> { local:fp-growth($l, $L,$minsup, $total, $src) }
      </largeItemsets>

      output that is get for running the query:=
      <?xml version="1.0" encoding="UTF-8"?>
      <largeItemsets>
      <largeItemset>
      <items>a</items>
      <support>0.6</support>
      </largeItemset>
      <largeItemset>
      <items>d</items>
      <support>0.6</support>
      </largeItemset>
      <largeItemset>
      <items>b</items>
      <support>0.6</support>
      </largeItemset>
      <largeItemset>
      <items>c</items>
      <support>0.6</support>
      </largeItemset>
      </largeItemsets>

      but sir i want my output like that:=

      <?xml version="1.0" standalone="yes"?>
      <largeItemsets>
      <largeItemset>
      <Items>
      <item>a</item>
      </Items>
      <support>0.6</support>
      </largeItemset>

      <largeItemset>
      <Items>
      <item>d</item>
      </Items>
      <support>0.6</support>
      </largeItemset>

      <largeItemset>
      <Items>
      <item>b</item>
      </Items>
      <support>0.6</support>
      </largeItemset>

      <largeItemset>
      <Items>
      <item>c</item>
      </Items>
      <support>0.6</support>
      </largeItemset>

      <largeItemset>
      <Items>
      <item>d</item>
      <item>b</item>
      </Items>
      <support>0.4</support>
      </largeItemset>

      <largeItemset>
      <Items>
      <item>b</item>
      <item>c</item>
      </Items>
      <support>0.4</support>
      </largeItemset>

      <largeItemset>
      <Items>
      <item>d</item>
      <item>c</item>
      <item>b</item>
      </Items>
      <support>0.4</support>
      </largeItemset>
      </largeItemsets>


      sir i want that output which i shown last help me sir how i sort out this problem
      thank i advance


      SIR PLZ HELP ME WHAT I DO HOW I SOLVE THAT PROBLEM PLZ ANY ONE HELP ME

      Edited by: MAXIMUM on Apr 9, 2012 10:43 PM