Exemplo n.º 1
0
        //what about Id???
        public void Append(FeatureItem item)
        {
            item.Id = FeatureItemList.Count;    //update Id according to FeatureItemList numeration
            FeatureItemList.Add(item);
            AssignCluster(item);

            //Get items assigned to hyperClusters
            for (int i = 0; i < HyperClusterList.Count; i++)
            {
                HyperClusterList[i].GetHyperClusterItemList();
            }
        }
Exemplo n.º 2
0
        public void Append(ICollection <FeatureItem> itemCollection)
        {
            int currentCount = FeatureItemList.Count;

            FeatureItemList.AddRange(itemCollection);

            //start from 0 (Chin Xi) or from the currently added collection (RR) ? in my opinion it should be from currentCount, otherwise unecessary and redundant calculations
            for (int i = currentCount; i < FeatureItemList.Count; i++)
            {
                FeatureItemList[i].Id = i;          //update Id according to FeatureItemList numeration
                AssignCluster(FeatureItemList[i]);
            }

            //Get items assigned to hyperClusters
            for (int i = 0; i < HyperClusterList.Count; i++)
            {
                HyperClusterList[i].GetHyperClusterItemList();
            }
        }
Exemplo n.º 3
0
        public void Create(ICollection <FeatureItem> itemCollection)
        {
            FeatureItemList.AddRange(itemCollection);

            ClusterList.Clear();
            HyperClusterList.Clear();
            ItemToClusterMap.Clear();
            ClusterToHyperClusterMap.Clear();

            for (int i = 0; i < FeatureItemList.Count; i++)
            {
                FeatureItemList[i].Id = i;
                AssignCluster(FeatureItemList[i]);
            }

            //Get items assigned to hyperClusters
            for (int i = 0; i < HyperClusterList.Count; i++)
            {
                HyperClusterList[i].GetHyperClusterItemList();
            }
        }
Exemplo n.º 4
0
        public void LoadFile(string fileLocation)
        {
            string line;

            FeatureNameList.Clear();
            FeatureNameList.Add("Name");

            StreamReader file = new StreamReader(fileLocation);

            while ((line = file.ReadLine()) != null)
            {
                if (line == "ItemList")
                {
                    break;
                }
            }

            if (line == null)
            {
                throw new Exception("ART File does not have a section marked ItemList!");
            }
            else
            {
                while ((line = file.ReadLine()) != null)
                {
                    if (line == "--")
                    {
                        break;
                    }
                    else
                    {
                        FeatureNameList.Add(line);
                    }
                }
                FeatureItemSize = FeatureNameList.Count - 1;

                //Finished reading itemList, now read all the people
                int featureItemId = 0;
                while ((line = file.ReadLine()) != null)
                {
                    string featureName = line;
                    line = file.ReadLine();
                    double[] featureVector = new double[FeatureItemSize];
                    int      i             = 0;
                    while ((line != null) && (line != "--"))
                    {
                        featureVector[i] = Int32.Parse(line); /// 10.00; //here read the values, but normalize in other part.
                        ++i;
                        line = file.ReadLine();
                    }

                    if (line == "--")
                    {
                        if (i != FeatureItemSize)
                        {
                            //For those who don't have a fully specified prefList, fill with 0s for rest.
                            for (int j = i; j < FeatureItemSize; ++j)
                            {
                                featureVector[j] = 0;
                            }
                        }
                        FeatureItemList.Add(new FeatureItem(featureItemId, featureName, featureVector));
                        featureItemId++;
                    }
                }
            }

            file.Close();
        }