Exemplo n.º 1
0
        public static Proposition Parse(string Proposition)
        {
            Proposition Prop = new Proposition();
            string sprop = Proposition;

            #region Quality and Type if Possible
            if (sprop.StartsWith("All"))
            {
                Prop.Quantity = Quantity.All;
                Prop.Type = PredicateType.A;
                sprop = sprop.Substring(4);
            }
            else if (sprop.StartsWith("No"))
            {
                Prop.Quantity = Quantity.No;
                Prop.Type = PredicateType.E;
                Prop.Quality = false;
                sprop = sprop.Substring(3);
            }
            else if (sprop.StartsWith("Some"))
            {
                Prop.Quantity = Quantity.Some;
                Prop.Type = PredicateType.Undefined;
                sprop = sprop.Substring(5);
            }
            else
            {
                throw new FormatException("Proposition must start with \"All\", \"Some\", or \"No\"\nCheck your proposition for errors.");
            }
            #endregion

            if (sprop.StartsWith("["))
            {
                sprop = sprop.Substring(1);
                Prop.Subject = sprop.Substring(0, sprop.IndexOf(']'));
                sprop = sprop.Substring(sprop.IndexOf(']') + 2);
            }
            else { throw new FormatException("Proposition does not follow correct input format.\nCheck your proposition for errors."); }

            if (sprop.StartsWith("are"))
            {
                Prop.CopulaWord = "are";
                sprop = sprop.Substring(4);
            }
            else if (sprop.StartsWith("is"))
            {
                Prop.CopulaWord = "is";
                sprop = sprop.Substring(3);
            }
            else { throw new FormatException("Copula must start with \"is\" or \"are\".\nCheck your proposition for errors."); }

            if (sprop.StartsWith("not"))
            {
                Prop.Quality = false;
                if (Prop.Type == PredicateType.Undefined)
                {
                    Prop.Type = PredicateType.O;
                }
                sprop = sprop.Substring(4);
            }
            else
            {
                if (Prop.Type == PredicateType.Undefined)
                {
                    Prop.Type = PredicateType.I;
                }
                if (Prop.Type != PredicateType.E)
                {
                    Prop.Quality = true;
                }
            }

            if (sprop.StartsWith("["))
            {
                sprop = sprop.Substring(1);
            }
            else { throw new FormatException("Proposition does not follow correct input format.\nCheck your proposition for errors."); }

            if (sprop.StartsWith("tw are"))
            {
                Prop.twi = "tw are";
                sprop = sprop.Substring(7);
            }
            else if (sprop.StartsWith("twi a"))
            {
                Prop.twi = "twi a";
                sprop = sprop.Substring(6);
            }
            else if (sprop.StartsWith("twi"))
            {
                Prop.twi = "twi";
                sprop = sprop.Substring(4);
            }
            else if (sprop.StartsWith("tw"))
            {
                Prop.twi = "tw";
                sprop = sprop.Substring(3);
            }

            if (sprop.StartsWith("non-"))
            {
                Prop.nonPredicate = true;
                sprop = sprop.Substring(4);
            }
            else
            {
                Prop.nonPredicate = false;
            }

            Prop.Predicate = sprop.Substring(0, sprop.IndexOf(']'));
            sprop = sprop.Substring(sprop.IndexOf(']') + 1);
            return Prop;
        }
Exemplo n.º 2
0
        private void setOutputData(Proposition output)
        {
            dgvOutput.Rows.Clear();

            string sprop = (!string.IsNullOrEmpty(output.twi) ? output.twi + " " : "");
            sprop += output.nonPredicate ? "non-" : "";
            sprop += output.Predicate;

            dgvOutput.Rows.Add("Type", output.Type.ToString());
            dgvOutput.Rows.Add("Quantity", (output.Quantity == Quantity.Some ? "Particular" : "Universal") + " (" + output.Quantity.ToString() + ")");
            dgvOutput.Rows.Add("Quality", output.Quality ? "Positive" : "Negitive");
            dgvOutput.Rows.Add("Inverted Predicate", output.nonPredicate ? "Yes (\"non-\")" : "No");
            dgvOutput.Rows.Add("Subject", output.Subject);
            dgvOutput.Rows.Add("Predicate", sprop);
        }
Exemplo n.º 3
0
 private Proposition Clone()
 {
     Proposition P = new Proposition();
     P.Quality = this.Quality;
     P.Quantity = this.Quantity;
     P.CopulaWord = this.CopulaWord;
     P.nonPredicate = this.nonPredicate;
     P.Predicate = this.Predicate;
     P.Subject = this.Subject;
     P.twi = this.twi;
     P.Type = this.Type;
     return P;
 }
Exemplo n.º 4
0
 private Proposition ProcessAndGetIncoming()
 {
     Proposition Incoming = new Proposition();
     try
     {
         Incoming = Proposition.Parse(txtInput.Text);
         txtOutput.Text = Incoming.ToString();
         setInputData(Incoming);
     }
     catch (FormatException E)
     {
         MessageBox.Show(E.Message, "Error");
     }
     listBox1.Items.Clear();
     listBox1.Items.Add(Incoming.ToString());
     return Incoming;
 }