public static ValidateEntity CreateInstance(LexiconEntity entity)
        {
            ValidateEntity instance = CreateInstance <ValidateEntity>();

            instance.entity = entity;
            return(instance);
        }
        public void Process()
        {
            //Debug.Log("Process, generateAssetsQueues count: " + generateAssetsQueues.Count);
            //Debug.Log("Process, watsonSpeechToTextSyncQueues count: " + watsonSpeechToTextSyncQueues.Count);
            //Debug.Log("Process, watsonConversationSyncQueues count: " + watsonConversationSyncQueues.Count);

            CleanUp();

            if (entityToSave)
            {
                //Debug.Log("have a stored entity to save...");
                SaveEntity(entityToSave);
                entityToSave = null;
            }

            foreach (SyncQueue queue in generateAssetsQueues)
            {
                queue.Process();
            }

            foreach (WatsonSyncQueue queue in watsonSpeechToTextSyncQueues)
            {
                queue.Process();
            }

            foreach (WatsonSyncQueue queue in watsonConversationSyncQueues)
            {
                queue.Process();
            }
        }
        public void SaveEntity(LexiconEntity entity)
        {
            //Debug.Log("SaveEntity");

            if (assemblyReload)
            {
                //Debug.Log("Trying to save entity on assembly reload, this is not safe!");
                entityToSave = entity;
            }
            else
            {
                SyncQueue assetsQueue = ScriptableObject.CreateInstance <SyncQueue>();

                assetsQueue.Enqueue(ValidateEntity.CreateInstance(entity));

                List <LexiconIntent> intents = GetAllIntents();

                foreach (LexiconIntent intent in intents)
                {
                    if (intent.UsesEntity(entity))
                    {
                        //Debug.Log("  Generate strings for " + intent.intentName);
                        assetsQueue.Enqueue(GenerateIntentStrings.CreateInstance(intent));
                    }
                }

                assetsQueue.Process();

                generateAssetsQueues.Add(assetsQueue);
            }
        }
예제 #4
0
        public bool UsesEntity(LexiconEntity entity)
        {
            foreach (LexiconIntent intent in intents)
            {
                if (intent.UsesEntity(entity))
                {
                    return(true);
                }
            }

            return(false);
        }
        /// <summary>
        /// Returns an entity value matching the given name and value, with returnEntity containing the matched entity.
        /// </summary>
        public LexiconEntityValue FindEntityValue(string entityName, string valueName, out LexiconEntity returnEntity)
        {
            foreach (LexiconEntity entity in requiredEntities)
            {
                if (entity == null)
                {
                    continue;
                }

                if (entityName.Equals(entity.EntityName, System.StringComparison.OrdinalIgnoreCase))
                {
                    LexiconEntityValue entityValue = entity.FindValueByName(valueName);
                    if (entityValue != null)
                    {
                        returnEntity = entity;
                        return(entityValue);
                    }
                }
            }

            foreach (LexiconEntity entity in optionalEntities)
            {
                if (entity == null)
                {
                    continue;
                }

                if (entityName.Equals(entity.EntityName, System.StringComparison.OrdinalIgnoreCase))
                {
                    LexiconEntityValue entityValue = entity.FindValueByName(valueName);
                    if (entityValue != null)
                    {
                        returnEntity = entity;
                        return(entityValue);
                    }
                }
            }

            returnEntity = null;
            return(null);
        }
 /// <summary>
 /// Returns true if the given entity is used by this intent.
 /// </summary>
 public bool UsesEntity(LexiconEntity entity)
 {
     return(requiredEntities.Contains(entity) || optionalEntities.Contains(entity));
 }