Example #1
0
        public MailReader()
        {
            m_FieldParser = new FieldParser();
            m_FieldParser.CompilePattern();

            m_UnfoldPattern = PatternFactory.GetInstance().Get(typeof (Pattern.UnfoldPattern));
        }
Example #2
0
 public OffsetBenchmarks()
 {
     offsetPatternParser = new OffsetPatternParser();
     var parseResult = offsetPatternParser.ParsePattern("HH:mm", InvariantFormatInfo);
     offsetPattern = parseResult.GetResultOrThrow();
     longPattern = OffsetPattern.CreateWithInvariantInfo("HH:mm:ss.fff");
 }
 public ContentTransferEncodingFieldParser(ContentTypeFieldParser original)
     : base(original)
 {
     Original = original;
     m_MechanismPattern = PatternFactory.GetInstance().Get(typeof (Pattern.MechanismPattern));
     m_ContentTransferPattern = PatternFactory.GetInstance().Get(typeof (Pattern.ContentTransferEncodingPattern));
 }
 /// <summary>
 /// Construct a definition pattern with a desired name and also 
 /// a main pattern.
 /// <para></para>
 /// </summary>
 /// <param name="name">The name.</param>
 /// <param name="pattern">The main pattern.</param>
 public Definition(string name, IPattern pattern)
 {
     Initialize();
     DefinitionName = "Definition" + (Counter++);
     DefinitionName = name;
     MainPattern = pattern;
 }
 /// <summary>
 /// Creates a match object.
 /// </summary>
 /// <param name="pattern">The referenced matching pattern</param>
 /// <param name="sequence">Sequence the match was found on.</param>
 /// <param name="start">Start position of the match.</param>
 /// <param name="length">Length of the match.</param>
 /// <param name="strand">Strand the match belongs to. +1 = forward strand, 
 /// -1 = backward strand, 0 = n.a. or unknown.</param>
 /// <param name="similarity"></param>
 public Match
     (IPattern pattern, Sequence sequence, int start, int length, int strand, double similarity)
     : base()
 {
     this.MatchPattern = pattern;
     Set(sequence, start, length, strand, similarity);
 }
 /// <summary>
 /// Adds a pattern to the pattern series.
 /// </summary>
 /// <param name="pat">Pattern to add.</param>
 /// <returns>Returns the added pattern.</returns>
 public IPattern Add(IPattern pat)
 {
     Patterns.Add(pat);
     //patternList.Add(pat);
     Matched.Add(pat.Matched);
     return pat;
 }
 /// <summary>
 /// Adds a pattern to the pattern series at the given index position.
 /// </summary>
 /// <param name="index">Index of insertion position.</param>
 /// <param name="pat">Pattern to add.</param>
 /// <returns>Returns the added pattern.</returns>
 public IPattern Add(int index, IPattern pat)
 {
     Patterns.Add(index, pat);
     //patternList.Insert(index, pat);
     Matched.Add(index, pat.Matched);
     return pat;
 }
        private static void RunPattern(IYateDataContext dataContext, object model, CQ domObjects, IPattern pattern)
        {
            //try/finally leaves the data context in the same state as when we started with it hopefully.
            try
            {
                dataContext.PushValue(model);

                foreach (var domObject in domObjects)
                {
                    var htmlFragment = CQ.CreateFragment(pattern.HtmlFragment);

                    foreach (var atRule in pattern.AtRules)
                    {
                        atRule.Render(htmlFragment, dataContext);
                    }

                    foreach (var ruleSet in pattern.RuleSets)
                    {
                        ruleSet.Render(htmlFragment, dataContext);
                    }

                    //append those mama jammas
                    foreach(var frag in htmlFragment)
                    {
                        domObject.AppendChild(frag);
                    }
                }
            }
            finally
            {
                dataContext.PopValue();
            }
        }
 /// <summary>
 /// Constructs an iteration pattern.
 /// </summary>
 /// <param name="name">Name of the pattern.</param>
 /// <param name="pattern">The pattern to iterate over.</param>
 /// <param name="minimum">Minimum number of iterations.</param>
 /// <param name="maximum">Maximum number of iterations.</param>
 /// <param name="threshold">Similarity threshold</param>
 public Iteration
     (String name, IPattern pattern, int minimum, int maximum, double threshold)
     : base(name)
 {
     Threshold = threshold;
     Set(pattern, minimum, maximum);
 }
 public IPatternFormatter GetFormatter(IPattern pattern)
 {
     if (pattern == null) throw new ArgumentNullException("pattern");
     IPatternFormatter formatter = null;
     formatters.TryGetValue(pattern.ID, out formatter);
     return formatter;
 }
 /// <summary>
 ///  Constructs a repeat pattern.
 /// </summary>
 /// <param name="name">Name of the repeat.</param>
 /// <param name="pattern">The Pattern to repeat.</param>
 /// <param name="mode">DIRECT, INVERTED</param>
 /// <param name="threshold">Similarity threshold</param>
 public Repeat
     (string name, IPattern pattern, string mode, double threshold)
     : base(name)
 {
     Threshold = threshold;
     Set(pattern, mode);
     weights = null;
 }
        public string[] GetTags(IPattern pattern)
        {
            if (pattern == null) throw new ArgumentNullException("pattern");

            var findedTags = new List<string>(SearchTags(pattern.Body));
            Array.ForEach(SearchTags(pattern.Subject), tag => { if (!findedTags.Contains(tag)) findedTags.Add(tag); });
            return findedTags.ToArray();
        }
Example #13
0
 public FieldParser()
 {
     m_UnfoldPattern = PatternFactory.GetInstance().Get(typeof (UnfoldPattern));
     m_FieldPattern = PatternFactory.GetInstance().Get(typeof (FieldPattern));
     m_HeaderNamePattern = PatternFactory.GetInstance().Get(typeof (FieldNamePattern));
     m_HeaderBodyPattern = PatternFactory.GetInstance().Get(typeof (FieldBodyPattern));
     m_DataReader = new DataReader();
 }
        /// <summary>
        /// Sets the alignment parameters
        /// </summary>
        /// <param name="pattern"> Pattern the cursor position is relative to.  </param>
        /// <param name="position"> Symboloc position e.g. START, END, CENTER. </param>
        /// <param name="offset"> Offset to the specified alignment. Can be positive or negative</param>
        private void Set(IPattern pattern, string position, int offset)
        {
            if (pattern == null)
                throw new ArgumentNullException("No reference pattern specified!");

            Pattern  = pattern;
            Position = position;
            Offset = offset;
        }
Example #15
0
 public SubTypePattern()
 {
     m_MultipartSubTypePattern = PatternFactory.GetInstance().Get(typeof (MultipartSubTypePattern));
     m_TextSubTypePattern = PatternFactory.GetInstance().Get(typeof (TextSubTypePattern));
     m_ImageSubTypePattern = PatternFactory.GetInstance().Get(typeof (ImageSubTypePattern));
     ApplicationSubTypePattern = PatternFactory.GetInstance().Get(typeof (ApplicationSubTypePatern));
     m_MessageSubTypePattern = PatternFactory.GetInstance().Get(typeof (MessageSubTypePattern));
     m_AudioSubTypePattern = PatternFactory.GetInstance().Get(typeof (AudioSubTypePattern));
     Compile();
 }
Example #16
0
 public NoticeMessage(IDirectRecipient recipient, INotifyAction action, string objectID, IPattern pattern)
 {
     if (recipient == null) throw new ArgumentNullException("recipient");
     if (pattern == null) throw new ArgumentNullException("pattern");
     Recipient = recipient;
     Action = action;
     Pattern = pattern;
     ObjectID = objectID;
     ContentType = pattern.ContentType;
 }
 public ContentTypeFieldParser(FieldParser original)
     : base(original)
 {
     m_TokenPattern = PatternFactory.GetInstance().Get(typeof(RFC822.Pattern.TokenPattern));
     m_ContentPattern = PatternFactory.GetInstance().Get(typeof (Pattern.ContentTypePattern));
     m_TypePattern = PatternFactory.GetInstance().Get(typeof (Pattern.TypePattern));
     SubTypePattern = PatternFactory.GetInstance().Get(typeof (Pattern.SubTypePattern));
     m_ParameterPattern = PatternFactory.GetInstance().Get(typeof (Pattern.ParameterPattern));
     m_ValuePattern = PatternFactory.GetInstance().Get(typeof (Pattern.ValuePattern));
 }
        public ContentDispositionFieldParser(ExtendedFieldParser original)
            : base(original)
        {
            Original = original;
            m_DispositionTypes = new List<string>();

            m_DispositionPattern = PatternFactory.GetInstance().Get(typeof (Pattern.DispositionParmPattern));
            m_TokenPattern = PatternFactory.GetInstance().Get(typeof (RFC822.Pattern.TokenPattern));
            m_DispositionTypePattern = PatternFactory.GetInstance().Get(typeof (Pattern.DispositionTypePattern));
            m_ValuePattern = PatternFactory.GetInstance().Get(typeof (RFC2045.Pattern.ValuePattern));
        }
Example #19
0
        public ExtendedFieldParser(ContentTransferEncodingFieldParser original)
            : base(original)
        {
            Original = original;
            m_CharsetPattern = PatternFactory.GetInstance().Get(typeof (Pattern.CharsetPattern));
            m_EncodingPattern = PatternFactory.GetInstance().Get(typeof (Pattern.EncodingPattern));
            m_EncodedTextPattern = PatternFactory.GetInstance().Get(typeof (Pattern.EncodedTextPattern));
            m_EncodedWordPattern = PatternFactory.GetInstance().Get(typeof (Pattern.EncodedWordPattern));

            m_TargetEncoding = Encoding.UTF8;
            m_QPDecoder = new MIMER.RFC2045.QuotedPrintableDecoder();
            m_B64decoder = new MIMER.RFC2045.Base64Decoder();
        }
        /// <summary>
        /// Setter for iteration parameters.
        /// </summary>
        /// <param name="pattern">The pattern to iterate over.</param>
        /// <param name="minimum">Minimum number of iterations. </param>
        /// <param name="maximum">Maximum number of iterations.</param>
        private void Set(IPattern pattern, int minimum, int maximum)
        {
            if (maximum < minimum)
                throw new ArgumentException
                    ("Maximum smaller than minimum in iteration pattern!");

            if (minimum < 1)
                throw new ArgumentException
                    ("Minimum smaller than one in iteration pattern!");

            Pattern = pattern;
            Minimum = minimum;
            Maximum = maximum;
        }
Example #21
0
        /// <summary>
        /// Creates a MIME competent MailReader, with QuotedPrintable &
        /// Base64 decoders.
        /// </summary>
        public MailReader()
        {
            m_Decoders = new List<RFC2045.IDecoder>();
            m_Decoders.Add(new QuotedPrintableDecoder());
            m_Decoders.Add(new Base64Decoder());
            m_FieldParser =
                new RFC2633.SMIMEFieldParser(
                    new ContentDispositionFieldParser(
                        new ExtendedFieldParser(
                            new ContentTransferEncodingFieldParser(new ContentTypeFieldParser(new FieldParser())))));

            m_FieldParser.CompilePattern();

            m_UnfoldPattern = PatternFactory.GetInstance().Get(typeof (UnfoldPattern));
            m_DiscretePattern = PatternFactory.GetInstance().Get(typeof (Pattern.DiscreteTypePattern));
            m_CompositePattern = PatternFactory.GetInstance().Get(typeof (Pattern.CompositeTypePattern));
            m_MimeVersionPattern = PatternFactory.GetInstance().Get(typeof (Pattern.MIMEVersionPattern));
        }
        /// <summary>
        /// Sets the attributes of repeat
        /// </summary>
        /// <param name="pattern">The pattern to repeat.</param>
        /// <param name="mode">Repeat mode: DIRECT, INVERTED</param>
        /// <exception cref="System.ArgumentException">thrown when reference pattern is null</exception>
        private void Set(IPattern pattern, string mode)
        {
            if (pattern == null)
                throw new ArgumentException
                    ("No referece pattern specified!");


            RefPattern = pattern;
            Mode = mode;

            if (Mode.Equals("DIRECT"))
                matcher = new MatcherDirect(this);

            else
                if (mode.Equals("INVERTED"))
                    matcher = new MatcherInverted(this);

                else
                    throw new ArgumentException
                        ("Invalid repeat mode: " + mode);

        }
Example #23
0
 private DurationPattern(string patternText, IPattern <Duration> pattern)
 {
     this.PatternText = patternText;
     this.pattern     = pattern;
 }
Example #24
0
 public Optional(IPattern pattern)
 {
     this.pattern = pattern;
 }
Example #25
0
 public void ChangePattern(PatternOption pattern)
 {
     _pattern = PatternSelector.SelectPattern(pattern);
     IsRandom = false;
 }
Example #26
0
 public OneOrMore(IPattern pattern)
 {
     this.pattern = new Sequence(pattern, new Many(pattern));
 }
Example #27
0
 public SqliteTypeMapping(IPattern <T> pattern) : this(CreateParameters(pattern))
 {
 }
Example #28
0
 public ZonedDateTimeDestructuringPolicy(IDateTimeZoneProvider provider) : base(CreateIsoValidator(x => x.Calendar))
 {
     Pattern = ZonedDateTimePattern.CreateWithInvariantCulture("uuuu'-'MM'-'dd'T'HH':'mm':'ss;FFFFFFFFFo<G> z", provider);
 }
Example #29
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OutlineControl"/> class that uses the specified pattern to define its configuration.
 /// </summary>
 /// <param name="original">When apply changes are clicked, the map will be updated when these changes are copied over.</param>
 /// <param name="display">The pattern that will be modified during changes.</param>
 public OutlineControl(IPattern original, IPattern display)
 {
     _original = original;
     _pattern  = display;
 }
Example #30
0
 public void Add(IPattern patternToAdd)
 {
     Array.Resize(ref patterns, patterns.Length + 1);
     patterns[patterns.Length - 1] = patternToAdd;
 }
 public abstract IPattern UpdatePattern(Chart chart, IPattern pattern);
 public abstract IPattern BuildPattern(Chart chart, IPattern pattern);
 /// <summary>
 /// Creates a new instance with a pattern and an optional validator. The validator will be called before each
 /// value is written, and may throw an exception to indicate that the value cannot be serialized.
 /// </summary>
 /// <param name="pattern">The pattern to use for parsing and formatting.</param>
 /// <param name="validator">The validator to call before writing values. May be null, indicating that no validation is required.</param>
 /// <exception cref="ArgumentNullException"><paramref name="pattern"/> is null.</exception>
 public NodaPatternConverter(IPattern <T> pattern, Action <T> validator)
 {
     Preconditions.CheckNotNull(pattern, nameof(pattern));
     this.pattern   = pattern;
     this.validator = validator;
 }
 /// <summary>
 /// Creates a new instance with a pattern and no validator.
 /// </summary>
 /// <param name="pattern">The pattern to use for parsing and formatting.</param>
 /// <exception cref="ArgumentNullException"><paramref name="pattern"/> is null.</exception>
 public NodaPatternConverter(IPattern <T> pattern) : this(pattern, null)
 {
 }
Example #35
0
 public List(IPattern pattern, IPattern separator)
 {
     this.character = pattern;
     this.separator = separator;
 }
Example #36
0
 public TokenPattern()
 {
     m_Pattern = PatternFactory.GetInstance().Get(typeof (TSpecialsPattern));
     m_TextPattern = "[^" + m_Pattern.TextPattern + "\x00-\x20]+";
     m_Regex = new Regex(m_TextPattern);
 }
Example #37
0
 /// <summary>
 /// Creates an outline control that uses the specified pattern to define its configuration.
 /// </summary>
 /// <param name="pattern">The pattern that will be modified during changes.</param>
 public OutlineControl(IPattern pattern)
 {
     _pattern = pattern;
 }
Example #38
0
 public void WaitVanish(IPattern Image, int?Timeout = null) => AutomataApi.WaitVanish(this, Image, Timeout);
Example #39
0
        /// <summary>
        /// Attempts to parse the given <paramref name="text" /> according to the rules of any of the <paramref name="patterns" />.
        /// </summary>
        /// <typeparam name="T">The type of the value to parse.</typeparam>
        /// <param name="patterns">The pattern to attempt to parse with.</param>
        /// <param name="text">The text to parse.</param>
        /// <param name="value">The parsed value if successful, otherwise <see langword="default{T}" />.</param>
        /// <param name="matched">The matched pattern.</param>
        /// <returns><c>true</c> if parsed, <c>false</c> otherwise.</returns>
        /// <exception cref="ArgumentNullException"><paramref name="patterns" /> or one of its elements was <see langword="null" />.</exception>
        public static bool TryParseAny <T>([NotNull] this IEnumerable <IPattern <T> > patterns, string text, out T value, out IPattern <T> matched)
        {
            if (patterns == null)
            {
                throw new ArgumentNullException(nameof(patterns));
            }

            foreach (IPattern <T> pattern in patterns)
            {
                if (pattern == null)
                {
                    throw new ArgumentNullException(nameof(pattern));
                }

                ParseResult <T> result = pattern.Parse(text);
                Debug.Assert(result != null);
                if (result.Success)
                {
                    value   = result.Value;
                    matched = pattern;
                    return(true);
                }
            }

            value   = default(T);
            matched = null;
            return(false);
        }
 public NegatedPattern(IPattern pattern)
 {
     _original = pattern;
 }
Example #41
0
 private static RelationalTypeMappingParameters CreateParameters(IPattern <T> pattern)
 => new(new CoreTypeMappingParameters(typeof(T), pattern.AsValueConverter()), "TEXT");
 internal LocalDateTimePatternAdapter(IPattern <LocalDateTime> pattern)
 {
     this.pattern = pattern;
 }
        public IPattern SetNextPattern(IPattern pattern)
        {
            this.pattern = pattern;

            return(this.pattern);
        }
        /// <summary>
        /// Adds a pattern preceeded by a gap of variable length to the profile. This
        /// pattern can't be the first pattern of the profile because the gap is
        /// defined between the given pattern and a preceding pattern!
        /// </summary>
        /// <param name="alignment">Alignment the gap is based on, e.g. END, START of the
        /// the preceding profile element or NONE if there is no preceding profile element 
        /// or no gap.
        /// </param>
        /// <param name="minGap">Minimum gap length.</param>
        /// <param name="maxGap">Maximum gap length. Must be greater than or equal to the 
        /// minimum gap length.</param>
        /// <param name="pattern">Any object which implements the pattern interface.</param>
        /// <returns>Returns a reference to the added { ProfileElement}.</returns>
        public ProfileElement Add
            (int alignment, int minGap, int maxGap, IPattern pattern)
        {
            if (Count == 0)
                throw new ArgumentException
                    ("First pattern of a profile must not have a gap!");

            return
                (Add(this[Count - 1], alignment, minGap, maxGap, pattern));
        }
Example #45
0
 private PeriodPattern([NotNull] IPattern <Period> pattern)
 {
     this.pattern = Preconditions.CheckNotNull(pattern, nameof(pattern));
 }
        /// <summary>
        /// 
        /// Adds a pattern preceeded by a gap of variable length to the profile.
        /// </summary>
        /// <param name="refElement">
        /// refElement Reference to the preceding profile element. Null if there
        /// is none. If there is gap then there must be a preceding profile element 
        /// defined!
        /// </param>
        /// <param name="alignment">Alignment the gap is based on, e.g. END, START of the 
        /// the preceding profile element or NONE if there is no preceding profile 
        /// element or no gap.</param>
        /// <param name="minGap">Minimum gap length.</param>
        /// <param name="maxGap">Maximum gap length. Must be greater than or equal to the 
        /// minimum gap length.</param>
        /// <param name="pattern">Any object which implements the pattern interface.</param>
        /// <returns></returns>
        public ProfileElement Add
            (ProfileElement refElement, int alignment, int minGap, int maxGap, IPattern pattern)
        {
            ProfileElement element = new ProfileElement
                                            (refElement, alignment, minGap, maxGap, pattern);

            patternList.Add(element);
            Matched.Add(pattern.Matched);
            return (element);
        }
Example #47
0
 private InstantPattern(string patternText, NodaFormatInfo formatInfo, IPattern <Instant> pattern)
 {
     this.PatternText = patternText;
     this.FormatInfo  = formatInfo;
     this.pattern     = pattern;
 }
        /// <summary>
        /// Getter for the index of the given pattern.
        /// </summary>
        /// <param name="pattern">Pattern reference.</param>
        /// <returns>
        /// Index of the given pattern within the profile or -1 if the
        /// pattern is not part of the profile.
        /// </returns>
        public int IndexOf(IPattern pattern)
        {
            for (int i = 0; i < Count; i++)
                if (this[i].Pattern == pattern)
                    return (i);

            return -1; //not found
        }
Example #49
0
    public void ReceiveExpression(Expression utterer, Expression utterance)
    {
        // Debug.Log(this.name + " is seeing '" + utterance + "'");
        if (this.model == null)
        {
            // Debug.Log("No associated model.");
            this.controller.placeExpression.Play();
            StartCoroutine(ShowSpeechBubble("questionMark"));
            return;
        }

        if (utterance.type.Equals(SemanticType.CONFORMITY_VALUE))
        {
            // if (name.Equals(new Phrase(Expression.THE,  new Phrase(Expression.POSSESS, new Phrase(Expression.THE, Expression.LOG), 1)))) {
            //     if (!model.Proves(new Phrase(Expression.KING, utterer))) {
            //         StartCoroutine(ShowSpeechBubble(Expression.REFUSE));
            //         return;
            //     }
            // }

            // TODO figure out conditions of refusal, etc.
            if (utterance.GetHead().Equals(Expression.CONTRACT))
            {
                if (!this.model.Proves(new Phrase(Expression.NOT, new Phrase(Expression.TRUSTWORTHY, utterer))))
                {
                    // TODO: check if utilities work out, and if you can uphold your end of the deal.
                    // For now, just accept by default
                    // uphold your end of the bargain
                    model.Add(new Phrase(Expression.BETTER, utterance.GetArg(1), Expression.NEUTRAL));
                    // model.AddUtility(utterance.GetArg(1), 10f);

                    // hold the other person to account
                    model.UpdateBelief(new Phrase(Expression.BOUND, utterer, utterance.GetArg(0)));

                    // // hold yourself to account??
                    // model.UpdateBelief(new Phrase(Expression.BOUND, utterer, utterance.GetArg(1)));

                    this.controller.combineSuccess.Play();
                    StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ACCEPT)));

                    return;
                }

                this.controller.lowClick.Play();
                StartCoroutine(ShowSpeechBubble(Expression.REFUSE));

                return;
            }

            if (utterance.GetHead().Equals(Expression.WOULD))
            {
                if (this.model.Proves(new Phrase(Expression.NOT, new Phrase(Expression.TRUSTWORTHY, utterer))))
                {
                    this.controller.lowClick.Play();
                    StartCoroutine(ShowSpeechBubble(new Phrase(Expression.REFUSE)));

                    return;
                }

                this.controller.combineSuccess.Play();
                StartCoroutine(ShowSpeechBubble(Expression.ACCEPT));

                model.Add(new Phrase(Expression.BETTER, utterance.GetArg(0), Expression.NEUTRAL));
                model.decisionLock = false;
                // model.AddUtility(utterance.GetArg(0), 10f);

                return;
            }
        }

        if (utterance.type.Equals(SemanticType.ASSERTION))
        {
            Expression content = utterance.GetArg(0);
            // if (this.model.UpdateBelief(new Phrase(Expression.BELIEVE, utterer, content))) {
            if (this.model.UpdateBelief(content))
            {
                this.controller.combineSuccess.Play();
                StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, Expression.AFFIRM)));
            }
            else
            {
                this.controller.failure.Play();
                StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, Expression.DENY)));
            }
            return;
        }

        if (utterance.type.Equals(SemanticType.TRUTH_VALUE))
        {
            if (this.model.Proves(utterance))
            {
                this.controller.combineSuccess.Play();
                StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, Expression.AFFIRM)));
            }
            else if (this.model.Proves(new Phrase(Expression.NOT, utterance)))
            {
                this.controller.failure.Play();
                StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, Expression.DENY)));
            }
            else
            {
                this.controller.lowClick.Play();
                StartCoroutine(ShowSpeechBubble(new Phrase(Expression.ASSERT, new Phrase(Expression.OR, Expression.AFFIRM, Expression.DENY))));
            }
            return;
        }

        if (utterance.type.Equals(SemanticType.INDIVIDUAL))
        {
            // I imagine this will be an invitation to attend to the individual named
            // but I'll leave this as a kind of puzzlement for now.
            this.controller.placeExpression.Play();
            StartCoroutine(ShowSpeechBubble("query"));
            return;
        }

        SemanticType outputType = utterance.type.GetOutputType();

        if (outputType != null && outputType.Equals(SemanticType.TRUTH_VALUE))
        {
            IPattern[] args = new IPattern[utterance.GetNumArgs()];
            Dictionary <SemanticType, int> places = new Dictionary <SemanticType, int>();
            int counter = 0;
            for (int i = 0; i < utterance.GetNumArgs(); i++)
            {
                if (utterance.GetArg(i) == null)
                {
                    SemanticType argType = utterance.type.GetInputType(counter);

                    int place = 0;

                    if (places.ContainsKey(argType))
                    {
                        place = places[argType];
                    }
                    places[argType] = place + 1;

                    args[i] = new MetaVariable(argType, place);

                    counter++;
                }
                else
                {
                    args[i] = utterance.GetArg(i);
                }
            }
            // let's see if this doesn't break things.
            // might have to cycle through the utterance's open args.
            IPattern question = new ExpressionPattern(utterance.GetHead(), args);

            List <Dictionary <MetaVariable, Expression> > found = model.Find(false, new List <Expression>(), question);
            if (found != null)
            {
                List <IPattern> bound   = question.Bind(found);
                Expression[]    answers = new Expression[bound.Count];
                counter = 0;
                foreach (IPattern p in bound)
                {
                    Expression answer = new Phrase(Expression.ASSERT, p.ToExpression());
                    answers[counter] = answer;
                    counter++;
                }
                StartCoroutine(ShowSpeechBubbles(answers));
                return;
            }
        }

        // this leaves functions with e as output. Not sure what this would amount to.
        this.controller.placeExpression.Play();
        StartCoroutine(ShowSpeechBubble("query"));
    }
Example #50
0
 public bool Exists(IPattern Image, int?Timeout = null, double?Similarity = null) => AutomataApi.Exists(this, Image, Timeout, Similarity);
 /// <summary>
 /// Adds a pattern preceeded by a gap of variable length to the profile. This
 /// pattern can't be the first pattern of the profile because the gap is
 /// defined between the given pattern and a preceding pattern! The gap
 /// is assumed to start at the end of the preceding pattern.
 /// Use #add(IPattern) to add the first ungapped pattern to the profile.
 /// </summary>
 /// <param name="minGap">Minimum gap length.</param>
 /// <param name="maxGap">Maximum gap length. Must be greater than or equal to the 
 /// inimum gap length.</param>
 /// <param name="pattern">Any object which implements the pattern interface.</param>
 /// <returns>a reference to the added {@link ProfileElement}.</returns>
 public ProfileElement Add(int minGap, int maxGap, IPattern pattern)
 {
     return (Add(this[Count - 1], ProfileElement.END, minGap, maxGap, pattern));
 }
 public static void SetFillPattern(this ICanvas target, IPattern pattern)
 {
     SetFillPattern(target, pattern, Colors.Black);
 }
        /// <summary>
        ///  Adds a pattern preceeded by a gap of variable length to the profile.
        /// </summary>
        /// <param name="elementIndex">
        /// Index to a preceding profile element. If the index
        /// smaller than zero it is assumed that there is no preceding profile element.
        /// In this case minGap and maxGap must be zero!
        /// Please note that the same pattern can not be added twice except it it
        /// a copy (with its own internal match object).
        /// </param>
        /// <param name="alignment">
        /// Alignment the gap is based on, e.g. END, START of the 
        /// the preceding profile element or NONE if there is no preceding profile element 
        /// or no gap.
        /// </param>
        /// <param name="minGap"> The min length</param>
        /// <param name="maxGap">
        /// Maximum gap length. Must be greater than or equal to the 
        /// minimum gap length.
        /// </param>
        /// <param name="pattern">Any object which implements the pattern interface.</param>
        /// <returns>Returns a reference to the added {ProfileElement}.</returns>
        public ProfileElement Add
            (int elementIndex, int alignment, int minGap, int maxGap, IPattern pattern)
        {
            if (IndexOf(pattern) >= 0)
                throw new ArgumentException
                    ("The same pattern can not be added twice to a profile!");

            ProfileElement element = new ProfileElement
                                            (this[elementIndex], alignment, minGap, maxGap, pattern);

            patternList.Add(element);
            Matched.Add(pattern.Matched);
            return (element);
        }
Example #54
0
 internal void Add(IPattern pattern)
 {
     Array.Resize(ref patterns, patterns.Length + 1);
     patterns[patterns.Length - 1] = pattern;
 }
Example #55
0
 public string[] GetTags(IPattern pattern)
 {
     throw new NotImplementedException();
 }
Example #56
0
 /// <summary>
 /// Constructs a <see cref="TypeConverter"/> for <typeparamref name="T"/> based on the provided <see cref="IPattern{T}"/>.
 /// </summary>
 /// <param name="pattern">The pattern used to parse and serialize <typeparamref name="T"/>.</param>
 /// <exception cref="ArgumentNullException"><paramref name="pattern"/></exception>
 protected TypeConverterBase(IPattern <T> pattern) => this.pattern = Preconditions.CheckNotNull(pattern, nameof(pattern));
Example #57
0
 public List(IPattern element, IPattern separator)
 {
     this.pattern = new Many(new Sequence(element, new Many(new Sequence(separator, element))));
 }
Example #58
0
 /// <summary>
 /// Initializes a new instance of the <see cref="OutlineControl"/> class that uses the specified pattern to define its configuration.
 /// </summary>
 /// <param name="pattern">The pattern that will be modified during changes.</param>
 public OutlineControl(IPattern pattern)
 {
     _pattern = pattern;
 }
Example #59
0
 /// <summary>
 /// Creates an outline control that uses the specified pattern to define its configuration.
 /// </summary>
 /// <param name="original">When apply changes are clicked, the map will be updated when these changes are copied over.</param>
 /// <param name="display">The pattern that will be modified during changes.</param>
 public OutlineControl(IPattern original, IPattern display)
 {
     _original = original;
     _pattern = display;
 }
Example #60
0
 public IPattern GetPatterCompleted(IPattern pattern)
 {
     return(pattern);
 }