Exemple #1
0
 protected override Unifiable ProcessChangeU()
 {
     if (!finalResult.IsValid)
     {
         var v = Recurse();
         var r = Proc.SystemExecute(v, GetAttribValue("lang", "bot"), request);
         if (Unifiable.IsFalse(r))
         {
             //finalResult = r;
             return(Unifiable.Empty);
         }
         else if (Unifiable.IsTrue(r))
         {
             finalResult.Value = r;
             //templateNodeInnerText = isValueSetStart + v;
         }
         return(r);
     }
     return(FinalResult);
 }
Exemple #2
0
        private bool lookup0(Unifiable textIn, Unifiable filter, out Unifiable term, SubQuery subquery)
        {
            string text = textIn.ToValue(subquery);

            if (text.Length < 2)
            {
                term = text;
                return(false);
            }
            string textStr = text.StartsWith("\"") ? text : String.Format("\"{0}\"", text);

            if (!CycEnabled)
            {
                term = textStr;
                return(true);
            }
            filter = Cyclify(filter);
            bool nospaces = !text.Contains(" ");

            string nqtext = textStr.Trim("\"".ToCharArray());
            string ptext  = nqtext.Substring(0, 1).ToUpper() + nqtext.Substring(2);

            if (nospaces)
            {
                if (Unifiable.IsFalse(EvalSubL(String.Format("(car (fi-complete \"{0}-TheWord\"))", ptext), null)))
                {
                    //no word used
                    nospaces = false;
                }
            }
            if (false ||
                lookupCycTerm("(#$nameString ?CYCOBJECT \"%s\")", text, filter, out term) ||
                (nospaces && (lookupCycTerm("(#$denotation #$%s-TheWord ?TEXT ?TYPE ?CYCOBJECT)", ptext, filter, out term) ||
                              lookupCycTerm("(#$denotationRelatedTo #$%s-TheWord ?TEXT ?TYPE ?CYCOBJECT)", ptext, filter, out term))) ||
                lookupCycTerm("(#$initialismString ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$abbreviationString-PN ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$preferredNameString ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$countryName-LongForm ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$countryName-ShortForm ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$acronymString ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$scientificName ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$termStrings-GuessedFromName ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$prettyString ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$preferredTermStrings ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$and (#$isa ?P #$ProperNamePredicate-Strict)(?P ?CYCOBJECT \"%s\"))", text, filter, out term) ||
                lookupCycTerm("(#$and (#$isa ?P #$ProperNamePredicate-General)(?P ?CYCOBJECT \"%s\"))", text, filter, out term) ||
                (nospaces && lookupCycTerm("(#$preferredGenUnit ?CYCOBJECT ?POS #$%s-TheWord )", ptext, filter, out term)) ||
                lookupCycTerm("(#$termStrings ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$nicknames ?CYCOBJECT \"%s\")", text, filter, out term) ||
                lookupCycTerm("(#$and (#$wordStrings ?WORD \"%s\") (#$or (#$denotation ?WORD ?TEXT ?TYPE ?CYCOBJECT) (#$denotationRelatedTo ?WORD ?TEXT ?TYPE ?CYCOBJECT) ))", text, filter, out term))
            {
                return(true);
            }

            term = EvalSubL(String.Format("(car (fi-complete \"{0}\"))", nqtext), null);
            // Followed by asking Cyc to guess at the word using (fi-complete \”%s\”)
            if (Unifiable.IsTrue(term))
            {
                if (IsaFilter(term, filter))
                {
                    return(true);
                }
            }
            term = EvalSubL(String.Format("(cdr (car (denotation-mapper \"{0}\")))", nqtext), null);
            if (Unifiable.IsTrue(term))
            {
                if (IsaFilter(term, filter))
                {
                    return(true);
                }
            }
            term = EvalSubL(String.Format("(car (denots-of-string \"{0}\"))", nqtext), null);
            if (Unifiable.IsTrue(term))
            {
                if (IsaFilter(term, filter))
                {
                    return(true);
                }
            }
            // and if that fails returns a Unifiable of using #$\”%s\”
            term = string.Format("#${0}", text);
            return(false);
        }