Exemplo n.º 1
0
        private void Swap(FileInfoClass curFic, FileInfoClass preFic)
        {
            int tempIndex = curFic.FileIndex;
            double tempValue = curFic.DFITFValue;

            curFic.FileIndex = preFic.FileIndex;
            curFic.DFITFValue = preFic.DFITFValue;

            preFic.FileIndex = tempIndex;
            preFic.DFITFValue = tempValue;
        }
Exemplo n.º 2
0
        private List<FileInfoClass> RetriveSubDocs(List<string> ANDTerms)
        {
            List<FileInfoClass> subDocs = new List<FileInfoClass>();

            List<List<InvertedTableItem>> allItemLists = new List<List<InvertedTableItem>>();
            //foreach (string term in ANDTerms)
            for (int index = 0; index < ANDTerms.Count; ++index )
            {
                string term = ANDTerms[index];
                int tokenId = GetTokenId(term);
                if (tokenId != -1)
                {
                    List<InvertedTableItem> itemList = this.invertedTable[tokenId];
                    allItemLists.Add(itemList);
                }
            }

            List<InvertedTableItem> subItemLists = allItemLists[0];
            //计算交集
            for (int index = 1; index < allItemLists.Count; ++index)
            {
                List<InvertedTableItem> tempList = new List<InvertedTableItem>();
                foreach (InvertedTableItem item in allItemLists[index])
                {
                    foreach (InvertedTableItem item2 in subItemLists)
                    {
                        if (item2.FileIndex == item.FileIndex)
                        {
                            tempList.Add(item);
                            break;
                        }
                    }
                }

                subItemLists.Clear();
                foreach (InvertedTableItem item in tempList)
                {
                    subItemLists.Add(item);
                }
            }

            foreach (InvertedTableItem item in subItemLists)
            {
                //计算df-itf
                double df = item.OccurCounts;
                double itf = Math.Log10(((double)this.docCounts / (double)subItemLists.Count()));
                FileInfoClass fic = new FileInfoClass(item.FileIndex, df * itf);

                bool flag = false;
                foreach (FileInfoClass doc in subDocs)
                {
                    if (doc.FileIndex == fic.FileIndex)
                    {
                        flag = true;
                        doc.DFITFValue += fic.DFITFValue;
                    }
                }

                if (false == flag)
                {
                    subDocs.Add(fic);
                }
            }

            return subDocs;
        }
Exemplo n.º 3
0
 private void RemoveFileFromRelativedDocs(FileInfoClass fic)
 {
     foreach (FileInfoClass doc in this.relativedDocs)
     {
         if (doc.FileIndex == fic.FileIndex)
         {
             this.relativedDocs.Remove(doc);
             break;
         }
     }
 }
Exemplo n.º 4
0
        private void GetRelativeDoc()
        {
            foreach (string term in this.queryTerms)
            {
                int tokenId = GetTokenId(term);
                if (tokenId != -1)
                {
                    List<InvertedTableItem> itemList = this.invertedTable[tokenId];

                    foreach (InvertedTableItem item in itemList)
                    {
                        //计算df-itf
                        double df = item.OccurCounts;
                        double itf = Math.Log10(((double)this.docCounts / (double)itemList.Count()));
                        FileInfoClass fic = new FileInfoClass(item.FileIndex, df*itf);

                        AddIntoRelativedDocs(fic);
                    }
                }
            }
        }
Exemplo n.º 5
0
        private Boolean CheckIsContainedInRankedDocs(FileInfoClass newFic)
        {
            foreach (FileInfoClass item in this.rankedDocsIndex)
            {
                if (item.FileIndex == newFic.FileIndex)
                {
                    return true;
                }
            }

            return false;
        }
Exemplo n.º 6
0
        private void AddIntoRelativedDocs(FileInfoClass fic)
        {
            bool flag = false;
            foreach (FileInfoClass doc in this.relativedDocs)
            {
                if (doc.FileIndex == fic.FileIndex)
                {
                    flag = true;
                    doc.DFITFValue += fic.DFITFValue;
                }
            }

            if (false == flag)
            {
                this.relativedDocs.Add(fic);
            }
        }