Ejemplo n.º 1
0
        static public string ToEnglish(string sentenceIn, ISettingsDictionary OutputSubstitutions)
        {
            var writeToLog = (OutputDelegate)null;

            if (sentenceIn == null)
            {
                return(null);
            }
            sentenceIn = sentenceIn.Trim();
            if (sentenceIn == "")
            {
                return("");
            }
            var    sentence      = "";
            string xmlsentenceIn = ToEnglishT(sentenceIn);

            if (xmlsentenceIn == "")
            {
                return("");
            }
            sentence = ApplySubstitutions.Substitute(OutputSubstitutions, xmlsentenceIn);
            if (sentenceIn != sentence)
            {
                if (writeToLog != null)
                {
                    writeToLog("SUBTS: " + sentenceIn + " -> " + sentence);
                }
            }
            sentence = AltBot.CleanupCyc(sentence);
            sentence = ApplySubstitutions.Substitute(OutputSubstitutions, sentence);
            return(sentence.Trim());
        }
Ejemplo n.º 2
0
        protected override Unifiable ProcessChangeU()
        {
            if (FinalResultValid)
            {
                return(FinalResult);
            }
            TemplateInfo queryTemplate = query.CurrentTemplate;

            if (queryTemplate != null)
            {
                if (queryTemplate.IsDisabledOutput)
                {
                    return(Unifiable.INCOMPLETE);
                }
                Succeed();
                request.MarkTemplate(queryTemplate);
            }
            Unifiable templateResult = RecurseReal(templateNode, false);
            Unifiable test           = templateResult;

            if (Unifiable.IsEMPTY(test))
            {
                if (QueryHasFailed)
                {
                    return(FAIL);
                }
                if (IsSilentTag(templateNode))
                {
                    return(templateResult);
                }
                ResetValues(true);
                templateResult = RecurseReal(templateNode, false);
            }
            if (templateResult == null)
            {
                return(null);
            }
            return(AltBot.ReTrimAndspace(AltBot.CleanupCyc(templateResult)));
        }
Ejemplo n.º 3
0
 protected Unifiable ProcessChangeSraiPre(Unifiable templateNodeInnerValue)
 {
     throw bot.RaiseError("wrong SRAI!");
     {
         try
         {
             { if (false && IsNull(templateNodeInnerValue))
               {
                   templateNodeInnerValue = Recurse();
               }
               TemplateInfo queryTemplate = query.CurrentTemplate;
               if (queryTemplate != null)
               {
                   if (!result.CanResultUseTemplate(queryTemplate))
                   {
                       writeToLogWarn("!result.CanResultUseTemplate " + queryTemplate);
                       return(Unifiable.INCOMPLETE);
                   }
                   if (!request.CanUseRequestTemplate(queryTemplate))
                   {
                       writeToLogWarn("!request.CanUseRequestTemplate " + queryTemplate);
                       return(Unifiable.INCOMPLETE);
                   }
               }
               templateNodeInnerValue = AltBot.CleanupCyc(templateNodeInnerValue);
               var vv = ProcessChangeSrai(templateNodeInnerValue);
               if (!Unifiable.IsNullOrEmpty(vv))
               {
                   return(vv);
               }
               if (Unifiable.IsNull(vv))
               {
                   writeToLogWarn("NULL SRAI!?!");
               }
               else
               {
                   if (IsSilentTag(templateNode.ChildNodes))
                   {
                       return(Unifiable.Empty);
                   }
                   return(vv); // Empty
               }
               if (ProcessChange12)
               {
                   writeToLogWarn("ProcessChange12 cant get result");
                   return(null);
               }
               if (Unifiable.IsNull(vv))
               {
                   vv = GetTemplateNodeInnerText();
                   return(FAIL);
               }
               return(vv); }
         }
         catch (ChatSignal ex)
         {
             throw;
         }
         catch (Exception e)
         {
             writeToLog("ERROR: " + e);
             throw;
         }
     }
 }