Ejemplo n.º 1
0
        public Corpus.Dialogue symbolToText(SymbolDialogue symbols)
        {
            Corpus.Dialogue dialogue = new Corpus.Dialogue();
            dialogue.entrances = new string[symbols.sentences.Length];

            for (int i = 0; i < dialogue.entrances.Length; i++)
            {
                dialogue.entrances[i] = symbolToText(symbols.sentences[i].symbols);
            }

            return(dialogue);
        }
Ejemplo n.º 2
0
        public SymbolDialogue textToSymbol(Corpus.Dialogue text)
        {
            SymbolDialogue symbols = new SymbolDialogue();

            symbols.sentences = new SymbolSentence[text.entrances.Length];
            for (int i = 0; i < symbols.sentences.Length; i++)
            {
                symbols.sentences[i]         = new SymbolSentence();
                symbols.sentences[i].symbols = textToSymbol(text.entrances[i]);
            }

            return(symbols);
        }
        public byte[] response(SymbolDialogue dialogue)
        {
            //Reset state
            state = 0;

            //Process all current sentences
            SymbolSentence inputSentence;

            for (int j = 0; j < dialogue.sentences.Length; j++)
            {
                inputSentence = dialogue.sentences[j];

                //predict corpus
                process(inputSentence.symbols);
            }

            //Return cascade from last state
            return(cascade(state, 128));
        }
Ejemplo n.º 4
0
        public byte[] response(Corpus.Dialogue corpusDialogue)
        {
            SymbolDialogue dialogue = translator.textToSymbol(corpusDialogue);
            SymbolSentence sentence;
            byte           feed = 0;

            //Reset states
            if (deepLayers != null)
            {
                for (int k = 0; k < deepLayers.Length; k++)
                {
                    deepLayers[k].state = 0;
                }
            }

            outputLayer.state = 0;

            for (int j = 0; j < dialogue.sentences.Length; j++)
            {
                sentence = dialogue.sentences[j];

                //Predict first symbol
                feed = 0;
                if (deepLayers != null)
                {
                    for (int k = 0; k < deepLayers.Length; k++)
                    {
                        feed = deepLayers[k].process(feed);
                    }
                }

                outputLayer.process(feed);

                //Predict remaining symbols
                for (int l = 0; l < sentence.symbols.Length - 1; l++)
                {
                    feed = sentence.symbols[l];
                    if (deepLayers != null)
                    {
                        for (int k = 0; k < deepLayers.Length; k++)
                        {
                            feed = deepLayers[k].process(feed);
                        }
                    }

                    outputLayer.process(feed);
                }
            }

            //Cascade
            List <byte> output    = new List <byte>();
            int         maxLength = 128;

            feed = 0;
            for (int i = 0; i < maxLength; i++)
            {
                if (deepLayers != null)
                {
                    for (int k = 0; k < deepLayers.Length; k++)
                    {
                        feed = deepLayers[k].process(feed);
                    }
                }

                feed = outputLayer.process(feed);

                output.Add(feed);

                if (feed == 0)
                {
                    break;
                }
            }

            return(output.ToArray());
        }