예제 #1
0
        public static Dictionary<int, double> retrive(Query query)
        {
            searchSetTableAdapters.Document_TermTableAdapter documentTermTableAdapter = new searchSetTableAdapters.Document_TermTableAdapter();
            searchSet.Document_TermDataTable documentTermDataTable = new searchSet.Document_TermDataTable();

            Dictionary<int, double> list_document = new Dictionary<int, double>();

            foreach (KeyValuePair<string, double> entry in query.terms)
            {

                documentTermDataTable = documentTermTableAdapter.GetDataByTerm(entry.Key);

                foreach (searchSet.Document_TermRow row in documentTermDataTable)
                {
                    double SC = entry.Value * row.Weight;

                    if (list_document.ContainsKey(row.Document_ID))
                    {
                        list_document[row.Document_ID] += SC;
                    }
                    else
                    {
                        list_document.Add(row.Document_ID, SC);
                    }
                }
            }
            return list_document;
        }
예제 #2
0
        public Parser(Config config, BackgroundWorker reporter)
        {
            this.config = config;
            termOccurenceInCollection = new Dictionary<string, int>();

            documentDataTable = new searchSet.DocumentsDataTable();
            documentTermDataTable = new searchSet.Document_TermDataTable();
            termsDataTable = new searchSet.TermsDataTable();

            progressReporter = reporter;
        }
        public void applyAlgorithm(Query query)
        {
            double pembagi_relevan, pembagi_irelevan;

            if (MainForm.feedback_config.algorithm == 0)
            {
                pembagi_irelevan = irelevant_doc.Count;
                pembagi_relevan = relevant_doc.Count;
            }
            else
            {
                pembagi_irelevan = 1;
                pembagi_relevan = 1;
            }

            foreach (int rel in relevant_doc)
            {
                searchSetTableAdapters.Document_TermTableAdapter documentTermTableAdapter = new searchSetTableAdapters.Document_TermTableAdapter();
                searchSet.Document_TermDataTable documentTermDataTable = new searchSet.Document_TermDataTable();

                documentTermDataTable = documentTermTableAdapter.GetDataByDocID(rel);
                foreach (searchSet.Document_TermRow row in documentTermDataTable)
                {
                    if (MainForm.feedback_config.useexpand == 0)
                    {
                        if (query.terms.ContainsKey(row.Term))
                            query.terms[row.Term] += row.Weight / pembagi_relevan;
                    }
                    else
                    {
                        if (query.terms.ContainsKey(row.Term))
                            query.terms[row.Term] += row.Weight / pembagi_relevan;
                        else
                            query.terms.Add(row.Term, row.Weight / pembagi_relevan);
                    }
                }
            }

            foreach (int rel in irelevant_doc)
            {
                searchSetTableAdapters.Document_TermTableAdapter documentTermTableAdapter = new searchSetTableAdapters.Document_TermTableAdapter();
                searchSet.Document_TermDataTable documentTermDataTable = new searchSet.Document_TermDataTable();

                documentTermDataTable = documentTermTableAdapter.GetDataByDocID(rel);
                foreach (searchSet.Document_TermRow row in documentTermDataTable)
                {
                    if (query.terms.ContainsKey(row.Term))
                    {
                        query.terms[row.Term] -= row.Weight / pembagi_irelevan;

                        if (query.terms[row.Term] <= 0)
                            query.terms.Remove(row.Term);
                    }

                }

                if (MainForm.feedback_config.algorithm == 2) break;
            }

            foreach (KeyValuePair<string, double> entry in query.terms)
            {
                Console.WriteLine(entry.Key + " --> " + entry.Value);
            }
        }