Ejemplo n.º 1
0
        public List <LexiconEntityMatch> GetEntitiesAfter(string entityName, LexiconEntityMatch targetMatch)
        {
            List <LexiconEntityMatch> matches = new List <LexiconEntityMatch>();

            if (!string.IsNullOrEmpty(entityName))
            {
                for (int i = EntityMatches.IndexOf(targetMatch) + 1; i < EntityMatches.Count; i++)
                {
                    LexiconEntityMatch entityMatch = EntityMatches[i];

                    if (string.Equals(entityMatch.Entity.EntityName, targetMatch.Entity.EntityName, StringComparison.OrdinalIgnoreCase))
                    {
                        // Break if we run into another entity of the same type.
                        // E.g. for "Create a cube with a sphere on top" location should be null after cube.
                        break;
                    }

                    if (string.Equals(entityMatch.Entity.EntityName, entityName, StringComparison.OrdinalIgnoreCase))
                    {
                        matches.Add(entityMatch);
                    }
                }
            }

            return(matches);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Returns the entity with the given entity name that appears after the target match.
        /// </summary>
        public LexiconEntityMatch GetEntityAfter(string entityName, LexiconEntityMatch targetMatch)
        {
            LexiconEntityMatch match = null;

            // TODO: I don't like this null check, or the return

            if (!string.IsNullOrEmpty(entityName))
            {
                for (int i = EntityMatches.IndexOf(targetMatch) + 1; i < EntityMatches.Count; i++)
                {
                    LexiconEntityMatch entityMatch = EntityMatches[i];

                    if (string.Equals(entityMatch.Entity.EntityName, targetMatch.Entity.EntityName, StringComparison.OrdinalIgnoreCase))
                    {
                        // Break if we run into another entity of the same type.
                        // E.g. for "Create a cube with a sphere on top" location should be null after cube.
                        break;
                    }

                    if (string.Equals(entityMatch.Entity.EntityName, entityName, StringComparison.OrdinalIgnoreCase))
                    {
                        match = entityMatch;
                        break;
                    }
                }
            }

            return(match);
        }