Beispiel #1
0
        public CompressedPosting(TokenPosting posting)
        {
            RawData = new List <List <int> >();
            Token   = posting.Token;

            var docIds = posting.AllOccurrencesByDocumentId.Keys.OrderBy(x => x).ToList();

            RawData.Add(docIds);

            foreach (var docOccurrence in posting.AllOccurrencesByDocumentId.OrderBy(x => x.Key).Select(x => x.Value))
            {
                RawData.Add(docOccurrence.Positions.ToList());
            }
        }
Beispiel #2
0
        public TokenPosting Decompress(List <List <int> > decompressedData)
        {
            var result = new TokenPosting(Token);

            var docIds = decompressedData.First();

            var i = 1;

            foreach (var docId in docIds)
            {
                result.GetOrCreateDocumentOccurrence(docId).Positions.AddRange(decompressedData[i]);
                i++;
            }

            return(result);
        }
Beispiel #3
0
        public void AddPosting(string token, TokenPosting posting)
        {
            var cp = new CompressedPosting(posting);

            PostingsByToken.Add(token, cp);
        }