public MemorySearchItem() { inputQueryTagList = new List <string>(); searchTagList = new List <string>(); tagSearchMode = TagSearchMode.Or; // labelIdentificationMode = LabelIdentificationMode.Exact; memoryIdentifier = AgentConstants.LONG_TERM_MEMORY_NAME; // Search long-term memory per default. }
public MemorySearchItem(string id, string memoryIdentifier, List <string> inputQueryTagList, List <string> searchTagList, TagSearchMode tagSearchMode, string identificationLabel, string searchLabel, string outputQueryTag, string successTargetContext, string successTargetID, string failureTargetContext, string failureTargetID) { this.id = id; this.memoryIdentifier = memoryIdentifier; this.inputQueryTagList = inputQueryTagList; this.searchTagList = searchTagList; this.tagSearchMode = tagSearchMode; this.identificationLabel = identificationLabel; this.searchLabel = searchLabel; this.outputQueryTag = outputQueryTag; this.successTargetContext = successTargetContext; this.successTargetID = successTargetID; this.failureTargetContext = failureTargetContext; this.failureTargetID = failureTargetID; }
public List <MemoryItem> GetAllItemsByTagList(List <string> tagList, TagSearchMode tagSearchMode) { Monitor.Enter(lockObject); List <MemoryItem> matchingItemList = new List <MemoryItem>(); foreach (MemoryItem memoryItem in itemList) { if (tagSearchMode == TagSearchMode.Or) { foreach (string tag in tagList) { if (memoryItem.TagList.Contains(tag)) { matchingItemList.Add(memoryItem.Copy()); break; } } } else if (tagSearchMode == TagSearchMode.And) { Boolean allTagsMatch = true; foreach (string tag in tagList) { if (!memoryItem.TagList.Contains(tag)) { allTagsMatch = false; break; } } if (allTagsMatch) { matchingItemList.Add(memoryItem.Copy()); } } } if (matchingItemList.Count == 0) { matchingItemList = null; } // Return null if nothing is found. Monitor.Exit(lockObject); return(matchingItemList); }