예제 #1
0
        /// <summary>
        /// fully set arff instance, used by ArffLoader
        /// </summary>
        /// <param name="headers"></param>
        /// <param name="datasets"></param>
        /// <param name="skipIntCheck"></param>
        public ArffInstance(Library headers, Library datasets, bool skipIntCheck = false)
            : this()
        {
            if (headers == null || datasets == null)
                throw new CekaException("can not pass null for library values of an ArffInstance");

            this.Headers = headers;
            this.Datasets = datasets;

            Headers.CleanUp();
            Datasets.CleanUp();

            this.Relation = Headers.getRelationName(); //grab name out of it
            Headers.removeRelation(); //and delete it afterwards, we dont need it, as we want clean Libraries

            //running the int-check
            if (!skipIntCheck)
                this.integrityCheck();
        }
예제 #2
0
 /// <summary>
 /// returns a deep copy of this library
 /// </summary>
 /// <returns></returns>
 public Library toCopy()
 {
     Library nl = new Library();
     Story[] cc = new Story[this.content.Count];
     this.content.CopyTo(cc);
     nl.content = new List<Story>(cc);
     return nl;
 }
예제 #3
0
        /// <summary>
        /// checking if the size of a single story-dataset differs from the size of the defined headers
        /// </summary>
        /// <param name="header"></param>
        /// <returns></returns>
        public bool integretyCheck(Library header)
        {
            int hs = header.headerSize();

            foreach (Story s in this.content)
            {
                if (s.getDatasetSize() != hs)
                {
                    Helpers.Utils.Debug("size (" + s.getDatasetSize() + ") of dataset l." + s.arffFileLine + " differs from header size (" + hs + ").");
                    return false;
                }
            }

            return true;
        }
예제 #4
0
        /// <summary>
        /// checking if the values of each single story-dataset element are allowed as they have to be defined in the headers
        /// </summary>
        /// <param name="header"></param>
        /// <returns></returns>
        public bool deepIntegretyCheck(Library header)
        {
            int sti = 0;
            //run through all stories
            foreach (Story st in this.content)
            {
                //run through every single story-dataset element
                for (int i = 0; i < st.Data.Length; i++)
                {
                    //check if the appropriat header attribute definition contains the value of the dataset:

                    if (header.content[i].isNumeric)
                        continue; //skip this entry because it belongs to an numeric attribute type

                    if(!header.content[i].Values.Contains(st.Data[i]))
                    {
                        if (string.CompareOrdinal(st.Data[i], ArffFile.ATT_EMPTY_VALUE.ToString()) == 0)
                        {
                            Helpers.Utils.Debug(String.Format("ignored row {0} column {1} as the value was empty={2}.", sti, i, ArffFile.ATT_EMPTY_VALUE));
                            continue;
                        }
                        Helpers.Utils.Debug("dataset(" + i + ") element (" + st.Data[i] + ") does not fit to the defined range of attribute (" + header.content[i].Name + ").");
                        return false;
                    }
                }

                sti++;
            }

            return true;
        }