예제 #1
0
 /// <summary>Decompose a string according to the given key.</summary>
 /// <remarks>
 /// Decompose a string according to the given key. Try each decomposition
 /// rule in order. If it matches, assemble a reply and return it. If assembly
 /// fails, try another decomposition rule. If assembly is a goto rule, return
 /// null and give the key. If assembly succeeds, return the reply;
 /// </remarks>
 private string Decompose(Key key, string s, Key gotoKey)
 {
     string[] reply = new string[10];
     for (int i = 0; i < key.Decomp().Count; i++)
     {
         Decomp d   = key.Decomp()[i];
         string pat = d.Pattern();
         if (syns.MatchDecomp(s, pat, reply))
         {
             string rep = Assemble(d, reply, gotoKey);
             if (rep != null)
             {
                 return(rep);
             }
             if (gotoKey.GetKey() != null)
             {
                 return(null);
             }
         }
     }
     return(null);
 }
예제 #2
0
파일: Key.cs 프로젝트: mjdavy/Eliza
 public virtual void Copy(Eliza.Key k)
 {
     key    = k.GetKey();
     rank   = k.Rank();
     decomp = k.Decomp();
 }
예제 #3
0
 /// <summary>Decompose a string according to the given key.</summary>
 /// <remarks>
 /// Decompose a string according to the given key. Try each decomposition
 /// rule in order. If it matches, assemble a reply and return it. If assembly
 /// fails, try another decomposition rule. If assembly is a goto rule, return
 /// null and give the key. If assembly succeeds, return the reply;
 /// </remarks>
 private string Decompose(Key key, string s, Key gotoKey)
 {
     string[] reply = new string[10];
     for (int i = 0; i < key.Decomp().Count; i++)
     {
         Decomp d = (Decomp)key.Decomp()[i];
         string pat = d.Pattern();
         if (syns.MatchDecomp(s, pat, reply))
         {
             string rep = Assemble(d, reply, gotoKey);
             if (rep != null)
             {
                 return rep;
             }
             if (gotoKey.GetKey() != null)
             {
                 return null;
             }
         }
     }
     return null;
 }