Example #1
0
 public override void ToStringBuilder(IStringBuilder writer)
 {
     writer.Append(Selector);
     writer.Append(" { ");
     writer.Append(Styles);
     writer.AppendLine(" }");
 }
Example #2
0
        /**
         * Returns a string representation of the environment
         *
         * @return a string representation of the environment
         */
        public override string ToString()
        {
            IStringBuilder builder = TextFactory.CreateStringBuilder("{");

            foreach (KeyValuePair <string, VacuumEnvironment.LocationState> entity in state)
            {
                if (builder.GetLength() > 2)
                {
                    builder.Append(", ");
                }
                builder.Append(entity.GetKey()).Append("=").Append(entity.GetValue());
            }
            int i = 0;

            foreach (KeyValuePair <IAgent, string> entity in agentLocations)
            {
                if (builder.GetLength() > 2)
                {
                    builder.Append(", ");
                }
                builder.Append("Loc").Append(++i).Append("=").Append(entity.GetValue());
            }
            builder.Append("}");
            return(builder.ToString());
        }
        /// <summary>
        /// Takes an exact count of characters from the input stream
        /// </summary>
        /// <param name="count">The number of characters to take</param>
        /// <param name="sb">The buffer to append the characters to</param>
        /// <param name="includeCurrent">Pass true to include the current character in
        /// the output buffer. Pass false to start taking characters from the next
        /// character in the input stream</param>
        /// <returns>True if there were enough characters in the input stream</returns>
        public bool Take(IStringBuilder sb, int count, bool includeCurrent = true)
        {
            if (count == 0)
            {
                return(true);
            }

            if (includeCurrent)
            {
                sb.Append(_characterStream.Current);
                count--;
            }

            while (count-- > 0)
            {
                var c = TakeOne();
                if (!c.HasValue)
                {
                    return(false);
                }
                sb.Append(c.Value);
            }

            return(true);
        }
Example #4
0
        public static StandardizeApartIndexical newStandardizeApartIndexical(char preferredPrefix)
        {
            char ch = preferredPrefix;

            if (!(char.IsLetter(ch) && char.IsLower(ch)))
            {
                throw new IllegalArgumentException("Preferred prefix :"
                                                   + preferredPrefix + " must be a valid a lower case letter.");
            }

            IStringBuilder sb = TextFactory.CreateStringBuilder();
            int            currentPrefixCnt = 0;

            if (!_assignedIndexicals.ContainsKey(preferredPrefix))
            {
                currentPrefixCnt = 0;
            }
            else
            {
                currentPrefixCnt  = _assignedIndexicals.Get(preferredPrefix);
                currentPrefixCnt += 1;
            }
            _assignedIndexicals.Put(preferredPrefix, currentPrefixCnt);
            sb.Append(preferredPrefix);
            for (int i = 0; i < currentPrefixCnt; ++i)
            {
                sb.Append(preferredPrefix);
            }

            return(new StandardizeApartIndexicalImpl(sb.ToString()));
        }
Example #5
0
        public override string ToString()
        {
            if (null == stringRep)
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();
                sb.Append(functionName);
                sb.Append("(");

                bool first = true;
                foreach (Term t in terms)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        sb.Append(",");
                    }
                    sb.Append(t.ToString());
                }

                sb.Append(")");

                stringRep = sb.ToString();
            }
            return(stringRep);
        }
Example #6
0
        public override string ToString()
        {
            if (cachedStringRep == null)
            {
                IStringBuilder sb    = TextFactory.CreateStringBuilder();
                bool           first = true;
                sb.Append("{");
                foreach (Clause c in clauses)
                {
                    if (first)
                    {
                        first = false;
                    }
                    else
                    {
                        sb.Append(", ");
                    }
                    sb.Append(c);
                }
                sb.Append("}");
                cachedStringRep = sb.ToString();
            }

            return(cachedStringRep);
        }
Example #7
0
        /// <summary>
        /// Utility method for outputting proofs in a formatted textual
        /// representation.
        /// </summary>
        /// <param name="proof"></param>
        /// <returns></returns>
        public static string printProof(Proof proof)
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            sb.Append("Proof, Answer Bindings: ");
            sb.Append(proof.getAnswerBindings());
            sb.Append("\n");

            ICollection <ProofStep> steps = proof.getSteps();

            int maxStepWidth          = "Step".Length;
            int maxProofWidth         = "Proof".Length;
            int maxJustificationWidth = "Justification".Length;

            // Calculate the maximum width for each column in the proof
            foreach (ProofStep step in steps)
            {
                string sn = "" + step.getStepNumber();
                if (sn.Length > maxStepWidth)
                {
                    maxStepWidth = sn.Length;
                }
                if (step.getProof().Length > maxProofWidth)
                {
                    maxProofWidth = step.getProof().Length;
                }
                if (step.getJustification().Length > maxJustificationWidth)
                {
                    maxJustificationWidth = step.getJustification().Length;
                }
            }

            // Give a little extra padding
            maxStepWidth          += 1;
            maxProofWidth         += 1;
            maxJustificationWidth += 1;

            string f = "|{0}-" + maxStepWidth + "s| {1}-" + maxProofWidth + "s|{2}-" + maxJustificationWidth + "s|\n";

            int            barWidth = 5 + maxStepWidth + maxProofWidth + maxJustificationWidth;
            IStringBuilder bar      = TextFactory.CreateStringBuilder();

            for (int i = 0; i < barWidth; ++i)
            {
                bar.Append("-");
            }
            bar.Append("\n");

            sb.Append(bar);
            sb.Append(string.Format(f, "Step", "Proof", "Justification"));
            sb.Append(bar);
            foreach (ProofStep step in steps)
            {
                sb.Append(string.Format(f, "" + step.getStepNumber(), step.getProof(), step.getJustification()));
            }
            sb.Append(bar);

            return(sb.ToString());
        }
Example #8
0
 public override void ToStringBuilder(IStringBuilder writer)
 {
     if (!string.IsNullOrEmpty(Comment))
     {
         writer.Append("/* ");
         writer.Append(Comment);
         writer.AppendLine(" */");
     }
 }
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            sb.Append('[');
            sb.Append(name);
            sb.Append("]");
            return(sb.ToString());
        }
Example #10
0
            public override string ToString()
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();

                sb.Append("isComplete=" + complete);
                sb.Append("\n");
                sb.Append("result=" + proofs);
                return(sb.ToString());
            }
Example #11
0
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            foreach (Sentence s in originalSentences)
            {
                sb.Append(s.ToString());
                sb.Append("\n");
            }
            return(sb.ToString());
        }
        /**
         * Return string representation of this percept.
         *
         * @return a string representation of this percept.
         */
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            sb.Append("[");
            sb.Append(getAgentLocation());
            sb.Append(", ");
            sb.Append(getLocationState());
            sb.Append("]");
            return(sb.ToString());
        }
Example #13
0
        public override string ToString()
        {
            IStringBuilder buf = TextFactory.CreateStringBuilder();

            foreach (DecisionListTest test in tests)
            {
                buf.Append(test.ToString() + " => " + testOutcomes.Get(test) + " ELSE \n");
            }
            buf.Append("END");
            return(buf.ToString());
        }
Example #14
0
 public override string ToString()
 {
     if (null == stringRep)
     {
         IStringBuilder sb = TextFactory.CreateStringBuilder();
         sb.Append("NOT(");
         sb.Append(negated.ToString());
         sb.Append(")");
         stringRep = sb.ToString();
     }
     return(stringRep);
 }
 public override string ToString()
 {
     if (null == toString)
     {
         IStringBuilder sb = TextFactory.CreateStringBuilder();
         sb.Append(getDerivedName());
         sb.Append(" = ");
         sb.Append(sumsDomain.ToString());
         toString = sb.ToString();
     }
     return(toString);
 }
Example #16
0
 public override string ToString()
 {
     if (null == stringRep)
     {
         IStringBuilder sb = TextFactory.CreateStringBuilder();
         sb.Append(term1.ToString());
         sb.Append(" = ");
         sb.Append(term2.ToString());
         stringRep = sb.ToString();
     }
     return(stringRep);
 }
Example #17
0
        public override string ToString()
        {
            IStringBuilder buf = TextFactory.CreateStringBuilder();

            buf.Append("IF  ");
            foreach (string key in attrValues.GetKeys())
            {
                buf.Append(key + " = ");
                buf.Append(attrValues.Get(key) + " ");
            }
            buf.Append(" DECISION ");
            return(buf.ToString());
        }
Example #18
0
        public override string ToString()
        {
            if (null == toString)
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();
                sb.Append("(NOT ");
                sb.Append(proposition.ToString());
                sb.Append(")");

                toString = sb.ToString();
            }
            return(toString);
        }
Example #19
0
        public override string ToString()
        {
            if (null == toString)
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();
                sb.Append(getTermVariable().getName());
                sb.Append(" = ");
                sb.Append(value);

                toString = sb.ToString();
            }
            return(toString);
        }
Example #20
0
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            for (int i = 0; i < radices.Length; ++i)
            {
                sb.Append("[");
                sb.Append(this.GetCurrentNumeralValue(i));
                sb.Append("]");
            }

            return(sb.ToString());
        }
Example #21
0
        public override string ToString()
        {
            IStringBuilder buffer = TextFactory.CreateStringBuilder();

            for (int row = 0; row < 3; row++)
            {
                for (int col = 0; col < 3; col++)
                {
                    buffer.Append(getValue(col, row)).Append(" ");
                }
                buffer.Append("\n");
            }
            return(buffer.ToString());
        }
        public override string ToString()
        {
            IStringBuilder sb    = TextFactory.CreateStringBuilder();
            bool           first = true;

            sb.Append('[');
            foreach (var item in this)
            {
                if (first)
                {
                    first = false;
                }
                else
                {
                    sb.Append(", ");
                }
                sb.Append('[');
                sb.Append(item.GetKey().ToString());
                sb.Append(", ");
                sb.Append(item.GetValue().ToString());
                sb.Append(']');
            }

            sb.Append(']');
            return(sb.ToString());
        }
Example #23
0
        public override string ToString()
        {
            IStringBuilder result = TextFactory.CreateStringBuilder();

            foreach (Pair <VAR, Domain <VAL> > pair in savedDomains)
            {
                result.Append(pair.GetFirst()).Append("=").Append(pair.getSecond()).Append(" ");
            }
            if (emptyDomainObserved)
            {
                result.Append("!");
            }
            return(result.ToString());
        }
Example #24
0
        public override string ToString()
        {
            if (null == strRep)
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();
                if (isNegativeLiteral())
                {
                    sb.Append("~");
                }
                sb.Append(getAtomicSentence().ToString());
                strRep = sb.ToString();
            }

            return(strRep);
        }
Example #25
0
        public override string ToString()
        {
            IStringBuilder sb = TextFactory.CreateStringBuilder();

            for (int i = 0; i < conjunctionOfClauses.Size(); ++i)
            {
                if (i > 0)
                {
                    sb.Append(",");
                }
                sb.Append(conjunctionOfClauses.Get(i).ToString());
            }

            return(sb.ToString());
        }
Example #26
0
        public override string ToString()
        {
            if (null == cachedStringRep)
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();
                if (isNegativeLiteral())
                {
                    sb.Append(Connective.NOT.ToString());
                }
                sb.Append(getAtomicSentence().ToString());
                cachedStringRep = sb.ToString();
            }

            return(cachedStringRep);
        }
Example #27
0
        public override string ToString()
        {
            IStringBuilder buf = TextFactory.CreateStringBuilder();

            foreach (RowHeaderType r in rowHeaders)
            {
                foreach (ColumnHeaderType c in columnHeaders)
                {
                    buf.Append(Get(r, c));
                    buf.Append(" ");
                }
                buf.Append("\n");
            }
            return(buf.ToString());
        }
 public override string ToString()
 {
     if (null == toString)
     {
         IStringBuilder sb = TextFactory.CreateStringBuilder();
         sb.Append(getDerivedName());
         foreach (IRandomVariable rv in getScope())
         {
             sb.Append(" = ");
             sb.Append(rv);
         }
         toString = sb.ToString();
     }
     return(toString);
 }
Example #29
0
        public override string ToString()
        {
            if (null == toString)
            {
                IStringBuilder sb = TextFactory.CreateStringBuilder();
                sb.Append("(");
                sb.Append(left.ToString());
                sb.Append(" OR ");
                sb.Append(right.ToString());
                sb.Append(")");

                toString = sb.ToString();
            }

            return(toString);
        }
Example #30
0
        public override void Concat(IStringBuilder builder, params Action <IStringBuilder>[] generators)
        {
            builder.Append("(");

            for (var i = 0; i < generators.Length; i++)
            {
                if (i > 0)
                {
                    builder.Append(" + ");
                }

                generators[i](builder);
            }

            builder.Append(")");
        }