예제 #1
0
 /// <summary>
 /// Creates a closure (a derivation, according to Ganter) of this attribute and an attribute set, based on give formal context.
 /// The closure is formed as an intent of the extent of the union of this attribute and all attributes in the attribute set, that
 ///  have smaller lectic position.
 /// </summary>
 /// <param name="setA">The attribute set, to form a closure.</param>
 /// <param name="formalContext">The formal context, into which both the attribute and the attribute set belong.</param>
 /// <returns>The Ganter closure for given attribute, attribute set and formal context.</returns>
 public List<Attribute> Closure(List<Attribute> setA, FormalContext formalContext)
 {
     List<Attribute> lecticSet = FormLecticSet(setA);
     return formalContext.Intent(formalContext.Extent(lecticSet)).ToList();
 }
예제 #2
0
        /// <summary>
        /// Creates a closure (a derivation, according to Ganter) of this attribute and an attribute set, based on give formal context.
        /// The closure is formed as an intent of the extent of the union of this attribute and all attributes in the attribute set, that
        ///  have smaller lectic position.
        /// </summary>
        /// <param name="setA">The attribute set, to form a closure.</param>
        /// <param name="formalContext">The formal context, into which both the attribute and the attribute set belong.</param>
        /// <returns>The Ganter closure for given attribute, attribute set and formal context.</returns>
        public List <Attribute> Closure(List <Attribute> setA, FormalContext formalContext)
        {
            List <Attribute> lecticSet = FormLecticSet(setA);

            return(formalContext.Intent(formalContext.Extent(lecticSet)).ToList());
        }
예제 #3
0
        private void GenerateOutput(FormalContext context)
        {
            ganterStop.Start();
            var ganterResult = context.PerformAlgorithm();
            ganterStop.Stop();
            lblTimeGanter.Text = "Ganter algorithm: " + ganterStop.Elapsed.ToString("G");

            outputStop.Start();

            SaveIntoFile(context, ganterResult);
            outputStop.Stop();
            lblTimeOutput.Text = "Output creation: " + outputStop.Elapsed.ToString("G");
            lblTimeTotal.Text = "Total time: " + (inputStop.Elapsed + ganterStop.Elapsed + outputStop.Elapsed).ToString("G");

            inputStop.Reset();
            ganterStop.Reset();
            outputStop.Reset();
        }
예제 #4
0
        private void SaveIntoFile(FormalContext context, List<List<Algorithm.Attribute>> ganterResult)
        {
            if (string.IsNullOrWhiteSpace(txtOutputPath.Text))
            {
                MessageBox.Show("Output folder cannot be empty!", "Warning!", MessageBoxButtons.OK, MessageBoxIcon.Warning);
                return;
            }

            if (!Directory.Exists(txtOutputPath.Text))
            {
                Directory.CreateDirectory(txtOutputPath.Text);
            }

            string filePath = Path.Combine(txtOutputPath.Text, new string(DateTime.Now.ToString().Where(c => char.IsLetterOrDigit(c)).ToArray()));
            filePath += ".txt";

            using (StreamWriter stream = new StreamWriter(filePath))
            {
                //using (BinaryWriter writer = new BinaryWriter(stream.BaseStream))
                //{
                //    context.WriteOutput(writer, ganterResult, rbTranReduction.Checked, chkAttributes.Checked, chkItems.Checked, txtSeparator.Text);
                //}

                context.WriteOutput(stream, ganterResult, rbTranReduction.Checked, chkAttributes.Checked, chkItems.Checked, txtSeparator.Text);
            }

            Process.Start(filePath);
        }
예제 #5
0
        private void btnManual_Click(object sender, EventArgs e)
        {
            inputStop.Start();
            List<Item> items = GetItems();
            List<Algorithm.Attribute> attributes = GetAttributes();
            bool[,] matrix = GetMatrix(items.Count, attributes.Count);

            try
            {
                FormalContext context = new FormalContext(attributes, items, matrix, true);
                inputStop.Stop();
                lblInputTime.Text = "Input processing: " + inputStop.Elapsed.ToString("G");
                GenerateOutput(context);
            }
            catch (Exception ex)
            {
                inputStop.Stop();
                MessageBox.Show(ex.Message, "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                return;
            }
        }