コード例 #1
0
ファイル: Filter.cs プロジェクト: mlnotes/correlation
        private CountObj[] countEachProperty(DataProvider provider, int criterionAttr)
        {
            provider.startTraverse();

            // get name of each attribute
            int attributeCount = provider.getAttributeCount();
            this.attributeNames = new String[attributeCount];
            for (int i = 0; i < attributeCount; ++i)
            {
                attributeNames[i] = provider.getAttributeName(i);
            }

            // get name of each property
            int propertyCount = provider.getPropertyCount();
            this.propertyNames = new String[propertyCount];
            for (int i = 0; i < propertyCount; ++i)
            {
                propertyNames[i] = provider.getPropertyName(i);
            }

            Hashtable valCounter = new Hashtable();
            this.totalRecords = 0;
            while (provider.next())
            {
                totalRecords += 1;
                int key = provider.getAttributeVal(criterionAttr);
                if (!valCounter.ContainsKey(key))
                {
                    valCounter.Add(key, new CountObj(attributeCount, propertyCount));
                }
                CountObj counter = (CountObj)valCounter[key];
                counter.addCount();

                // count each attribute value
                for (int i = 0; i < attributeCount; ++i)
                {
                    int val = provider.getAttributeVal(i);
                    counter.addAttributeCount(i, val);
                }

                // count each property value
                for (int i = 0; i < propertyCount; ++i)
                {
                    if (provider.getPropertyVal(i))
                    {
                        counter.addPropertyCount(i);
                    }
                }
            }
            provider.endTraverse();

            // get each attribute's val count
            //            this.criterion = new int[valCounter.Count];
            //            this.criterionSupport = new int[valCounter.Count];
            CountObj[] values = new CountObj[valCounter.Count];

            IEnumerator e = valCounter.Keys.GetEnumerator();
            int index = 0;
            while (e.MoveNext())
            {
            //                criterion[index] = (int)e.Current;
                values[index] = (CountObj)valCounter[e.Current];
            //                criterionSupport[index] = values[index].getCount();
                index += 1;
            }

            return values;
        }
コード例 #2
0
ファイル: Filter.cs プロジェクト: mlnotes/correlation
        private CountObj[] countEachProperty(DataProvider provider, int criterionAttr)
        {
            provider.startTraverse();

            // get name of each attribute
            int attributeCount = provider.getAttributeCount();

            this.attributeNames = new String[attributeCount];
            for (int i = 0; i < attributeCount; ++i)
            {
                attributeNames[i] = provider.getAttributeName(i);
            }

            // get name of each property
            int propertyCount = provider.getPropertyCount();

            this.propertyNames = new String[propertyCount];
            for (int i = 0; i < propertyCount; ++i)
            {
                propertyNames[i] = provider.getPropertyName(i);
            }

            Hashtable valCounter = new Hashtable();

            this.totalRecords = 0;
            while (provider.next())
            {
                totalRecords += 1;
                int key = provider.getAttributeVal(criterionAttr);
                if (!valCounter.ContainsKey(key))
                {
                    valCounter.Add(key, new CountObj(attributeCount, propertyCount));
                }
                CountObj counter = (CountObj)valCounter[key];
                counter.addCount();

                // count each attribute value
                for (int i = 0; i < attributeCount; ++i)
                {
                    int val = provider.getAttributeVal(i);
                    counter.addAttributeCount(i, val);
                }

                // count each property value
                for (int i = 0; i < propertyCount; ++i)
                {
                    if (provider.getPropertyVal(i))
                    {
                        counter.addPropertyCount(i);
                    }
                }
            }
            provider.endTraverse();

            // get each attribute's val count
//            this.criterion = new int[valCounter.Count];
//            this.criterionSupport = new int[valCounter.Count];
            CountObj[] values = new CountObj[valCounter.Count];

            IEnumerator e     = valCounter.Keys.GetEnumerator();
            int         index = 0;

            while (e.MoveNext())
            {
//                criterion[index] = (int)e.Current;
                values[index] = (CountObj)valCounter[e.Current];
//                criterionSupport[index] = values[index].getCount();
                index += 1;
            }

            return(values);
        }