示例#1
0
        public void AddKeyword(string entityName, WitEntityKeyword keyword)
        {
            var entity = entities.Find(e => entityName == e.entity);

            if (null == entity)
            {
                entity = new WitDynamicEntity(entityName);
                entities.Add(entity);
            }
            entity.keywords.Add(keyword);
        }
示例#2
0
        public void RemoveKeyword(string entityName, WitEntityKeyword keyword)
        {
            int index = entities.FindIndex(e => e.entity == entityName);

            if (index >= 0)
            {
                entities[index].keywords.Remove(keyword);
                if (entities[index].keywords.Count == 0)
                {
                    entities.RemoveAt(index);
                }
            }
        }
示例#3
0
        public override void UpdateData(WitResponseNode entityWitResponse)
        {
            id      = entityWitResponse[Fields.ID].Value;
            name    = entityWitResponse[Fields.NAME].Value;
            lookups = entityWitResponse[Fields.LOOKUPS].AsStringArray;
            var roleArray = entityWitResponse[Fields.ROLES].AsArray;

            roles = new WitEntityRole[roleArray.Count];
            for (int i = 0; i < roleArray.Count; i++)
            {
                roles[i] = WitEntityRole.FromJson(roleArray[i]);
            }
            var keywordArray = entityWitResponse[Fields.KEYWORDS].AsArray;

            keywords = new WitEntityKeyword[keywordArray.Count];
            for (int i = 0; i < keywordArray.Count; i++)
            {
                keywords[i] = WitEntityKeyword.FromJson(keywordArray[i]);
            }
        }
 public void UnregisterDynamicEntity(string entity, WitEntityKeyword keyword)
 {
     entities.RemoveKeyword(entity, keyword);
 }
 public void RegisterDynamicEntity(string entity, WitEntityKeyword keyword)
 {
     entities.AddKeyword(entity, keyword);
 }
示例#6
0
 public WitDynamicEntity(string entity, WitEntityKeyword keyword)
 {
     this.entity = entity;
     this.keywords.Add(keyword);
 }