Example #1
0
        public static ITerm AddAnnotToList(ITerm l, DefaultTerm source)
        {
            if (l.IsList())
            {
                IListTerm result = new ListTermImpl();
                foreach (ITerm lTerm in (IListTerm)l)
                {
                    ITerm t = AddAnnotToList(lTerm, source);
                    if (t != null)
                    {
                        result.Add(t);
                    }
                }
                return(result);
            }
            else if (l.IsLiteral())
            {
                Literal result = ((Literal)l).ForceFullLiteralImpl().Copy();

                //Create the source annots
                Literal ts = Pred.CreateSource(source).AddAnnots(result.GetAnnots("source"));

                result.DelSources();
                result.AddAnnots(ts);
                return(result);
            }
            else
            {
                return(l);
            }
        }
Example #2
0
        // Removes a literal from the belief base
        public bool Remove(Literal l)
        {
            Literal bl = Contains(l);

            if (bl != null)
            {
                if (l.HasSubsetAnnot(bl))
                {
                    if (l.HasAnnot(TPercept))
                    {
                        percepts.Remove(bl);
                    }
                    bool result = bl.DelAnnots((List <ITerm>)l.GetAnnots());
                    return(RemoveFromEntry(bl) || result);
                }
            }
            return(false);
        }