Ejemplo n.º 1
0
        internal static InputPhraseEvent[] GetPrefixPhrases(InputPhraseEvent phrase, int prefixLength, BeamNode node)
        {
            var result      = new List <InputPhraseEvent>();
            var currentNode = node;

            //find node where prefix starts
            while (currentNode != null && currentNode.Evt != phrase)
            {
                currentNode = currentNode.ParentNode;
            }

            while (currentNode != null)
            {
                if (currentNode.Evt is TurnStartEvent)
                {
                    break;
                }

                if (currentNode.Evt is InputPhraseEvent prefixPhrase)
                {
                    result.Add(prefixPhrase);
                    if (result.Count >= prefixLength)
                    {
                        break;
                    }
                }

                currentNode = currentNode.ParentNode;
            }

            result.Reverse();
            return(result.ToArray());
        }
Ejemplo n.º 2
0
        internal virtual void Visit(InputPhraseEvent evt)
        {
            // input phrase can create a new instance or point to some old instance
            tryActivateNewInstances();
            tryActivateProperties();

            // input can be unrecognized
            PushSelf();
        }
Ejemplo n.º 3
0
        private bool isDelimiter(InputPhraseEvent inputPhrase)
        {
            var phrase = inputPhrase.Phrase;

            return(new[] { "a", "an", "is", "does", "much", "can", "will", "in", "from", "out", "of", "i", "am", "iam", "i'am", "where", "what", "mean" }.Contains(phrase));
        }
Ejemplo n.º 4
0
 internal static InputPhraseEvent[] GetSufixPhrases(InputPhraseEvent phrase, int ngramLimitCount, BeamNode node)
 {
     throw new NotImplementedException();
 }
Ejemplo n.º 5
0
 internal bool IsInputUsed(InputPhraseEvent input)
 {
     return(GetAllEvents <InstanceActivationRequestEvent>(getCurrentNode()).Where(r => r.ActivationPhrases.Contains(input)).Any());
 }