示例#1
0
 private void AddKeyToMap(string keyword, string docId)
 {
     if (InvertedMap.ContainsKey(keyword))
     {
         InvertedMap[keyword].Add(docId);
     }
     else
     {
         InvertedMap.Add(keyword, new HashSet <string>()
         {
             docId
         });
     }
 }
示例#2
0
 public string RemoveDoc(string docID)
 {
     if (Docs.ContainsKey(docID))
     {
         string docContext = Docs[docID];
         Docs.Remove(docID);
         foreach (var keyword in InvertedMap.Keys)
         {
             InvertedMap[keyword].Remove(docID);
             if (InvertedMap[keyword].Count == 0)
             {
                 InvertedMap.Remove(keyword);
             }
         }
         return(docContext);
     }
     return("");
 }