public Concept CompletePartials(Context context)
        {
            if (context.Contents.Count == 0)
            {
                return(null);
            }

            IParsedPhrase phrase = StarUtilities.ProducedPhrase(context, tagger, parser);

            if (phrase == null)
            {
                // cannot do!
                context.Map["$knowPartials"] = new List <Datum>();
                return(null);
            }
            Concept concept = memory.NewConcept(phrase);

            List <Datum> completes = context.LookupAndAdd <List <Datum> >("$knowCompletes", new List <Datum>());

            List <Datum> data = context.LookupDefaulted <List <Datum> >("$knowPartials", new List <Datum>());

            foreach (Datum datum in data)
            {
                completes.Add(memory.Know(concept, datum));
            }

            context.Map["$knowPartials"] = new List <Datum>();

            return(concept);
        }
        public bool ConstructSentence(Context context, IContinuation succ, IFailure fail, params object[] args)
        {
            // Need to produce all my contents!
            IParsedPhrase phrase = StarUtilities.ProducedPhrase(context, tagger, parser);

            if (phrase == null)
            {
                // oops, we failed to produce
                fail.Fail("Context could not be produced", succ);
                return(true);
            }

            if (!(phrase.Part == "=P"))
            {
                if (phrase.Part == "FRAG" || phrase.Part == "S" || phrase.Part == "SBARQ")
                {
                    if (final != null)
                    {
                        GroupPhrase   groupPhrase = new GroupPhrase(phrase);
                        IParsedPhrase last        = groupPhrase.GetBranch(groupPhrase.Count - 1);
                        if (!(last.Part == "." || last.Part == "!" || last.Part == "?"))
                        {
                            List <IParsedPhrase> branches = new List <IParsedPhrase>();
                            branches.AddRange(phrase.Branches);
                            branches.Add((IParsedPhrase)final.Clone());
                            phrase = new GroupPhrase(phrase.Part, branches);
                        }
                    }
                }
                else
                {
                    List <IParsedPhrase> branches = new List <IParsedPhrase>();
                    branches.Add(phrase);
                    if (final != null)
                    {
                        branches.Add((IParsedPhrase)final.Clone());
                    }
                    phrase = new GroupPhrase("FRAG", branches);
                }
            }

            List <IContent> contents = new List <IContent>();

            contents.Add(new Word(phrase.Text));
            Context child = new Context(context, contents);

            succ.Continue(child, fail);

            return(true);
        }
        public override bool Produce(Context context, IContinuation succ, IFailure fail)
        {
            IParsedPhrase phrase = StarUtilities.ProducedPhrase(context, tagger, parser);

            if (phrase == null)
            {
                succ.Continue(new Context(context, new List <IContent>()), fail);
                return(true); // cannot do!
            }

            KnowPhrase(phrase, context, memory);

            succ.Continue(new Context(context, new List <IContent>()), fail);
            return(true);
        }
        public override bool Produce(Context context, IContinuation succ, IFailure fail)
        {
            IParsedPhrase phrase = StarUtilities.ProducedPhrase(context, tagger, parser);

            if (phrase == null)
            {
                succ.Continue(new Context(context, new List <IContent>()), fail);
                return(true); // cannot do!
            }

            if (phrase.Part == "PP")
            {
                // the ring on my finger
                // the ring of gold
            }

            succ.Continue(new Context(context, new List <IContent>()), fail);
            return(true);
        }
        public override bool Produce(Context context, IContinuation succ, IFailure fail)
        {
            IParsedPhrase other = StarUtilities.ProducedPhrase(context, tagger, parser);

            if (other == null)
            {
                succ.Continue(new Context(context, new List <IContent>()), fail);
                return(true); // cannot do!
            }

            Concept concept = produceTranslator.GetConcept(other);

            Datum datum = new Datum(null, kind, concept, context.Weight);

            context.LookupAndAdd <List <Datum> >("$knowPartials", new List <Datum>()).Add(datum);

            succ.Continue(new Context(context, new List <IContent>()), fail);
            return(true);
        }