예제 #1
0
        public static double countAtribValueOccuran(List <TreeData> dataList, string attributeValue, string attributeType)  // Returns the number of occurances of the given value of given given type within the given data list
        {
            List <string> ValuesList = new List <string>();

            foreach (TreeData data in dataList)
            {
                TreeAtrib attribute = data.GetAttributeByType(attributeType);
                ValuesList.Add(attribute.Atrib_Val);
            }
            int count = ((from temp in ValuesList where temp.Equals(attributeValue) select temp).Count());

            return(count);
        }
예제 #2
0
        public static List <string> GetPossAtribValues(List <TreeData> dList, string atribType)  // Returns a list of possible values for a given attributeType from the given data list
        {
            List <string> ValuesList = new List <string>();

            foreach (TreeData data in dList)
            {
                TreeAtrib atrib = data.GetAttributeByType(atribType);
                ValuesList.Add(atrib.Atrib_Val);
            }

            List <string> distin_valList = ValuesList.Distinct().ToList();

            return(distin_valList);
        }
예제 #3
0
        public static double countSuccessByAtribVal(List <TreeData> dataList, string attributeValue, string attributeType)
        {
            double c = 0;           //count

            foreach (TreeData data in dataList)
            {
                TreeAtrib attribute = data.GetAttributeByType(attributeType); //Get attribute from the given data
                if (attribute.Atrib_Val.Equals(attributeValue))               //Is the attribute's value equals to the value we are counting?
                {
                    if (data.isSuccess)                                       //if this data failed with the given attribute value, increment count
                    {
                        c++;
                    }
                }
            }
            return(c);
        }
예제 #4
0
        public static List <TreeData> exData(string fName, string outcomeName, string successlOutName, out List <string> possTypes)   //extract data
        {
            List <TreeData> outp = new List <TreeData>();

            StreamReader sr   = new StreamReader(fName);
            string       line = "";

            possTypes = new List <string>();

            while ((line = sr.ReadLine()) != null)
            {
                line = line.Replace(",", string.Empty); //Remove Commas
                string[] words = line.Split(' ');


                if (possTypes.Count == 0)  //Only true for the first loop
                {
                    for (int i = 0; i < words.Length; i++)
                    {
                        possTypes.Add(words[i]);
                    }
                }
                else
                {
                    List <TreeAtrib> attList = new List <TreeAtrib>();
                    for (int i = 0; i < words.Length; i++)
                    {
                        TreeAtrib attribute = new TreeAtrib(words[i], possTypes[i]);
                        attList.Add(attribute);
                    }
                    TreeData data = new TreeData(attList, outcomeName, successlOutName);
                    outp.Add(data);
                }
            }
            return(outp);
        }