예제 #1
0
        public List<WordOccurrenceNode> GetWordOccurrencies(Word word)
        {
            invertedfileName = GetFileName(word.WordID);
            List<WordOccurrenceNode> result = new List<WordOccurrenceNode>();

            try
            {
                //open the file
                br = new BinaryReader(new FileStream(invertedfileName, FileMode.Open));

                //reading the file
                for (int i = 0; (i < conf.MaxResultList) && (br.BaseStream.Position < br.BaseStream.Length); i++)
                {
                    int tempDocumentHashOne = br.ReadInt32();
                    int hitsCount = br.ReadInt32();

                    WordOccurrenceNode node = new WordOccurrenceNode();

                    node.Hits = new List<WordHit>();

                    for (int y = 0; y < hitsCount; y++)
                    {
                        WordHit hit = new WordHit();
                        hit.Position = br.ReadInt32();
                        node.Hits.Add(hit);
                    }

                    node.Word = word;
                    node.QuantityHits = hitsCount;
                    node.Doc = this.docIndex.Search(tempDocumentHashOne);
                    result.Add(node);
                }

                return result;
            }
            catch (IOException e)
            {
                throw e;
            }
            finally
            {
                br.Close();
            }
        }
예제 #2
0
 public void AddNewWord(Word word)
 {
     this.ht.Add(word.WordID, word);
 }