コード例 #1
0
 public GroupingQueryResult(GroupingKNNResult GKR) : base(GKR.ReturnAccessVector())
 {
     this.aDGroupsRepresented = GKR.ADGroupsRepresented;
     this.groupingName        = GKR.GroupingName;
     this.groupingType        = GKR.GroupingType;
     this.groupMemberCount    = GKR.MemberCount;
     this.members             = GKR.Members;
     this.accessSummaryVector = GKR.ReturnAccessVector();
     this.rawCountVector      = GKR.ReturnRawCountVector();
     this.tF_IDFVector        = GKR.ReturnTF_IDFVector();
 }
コード例 #2
0
        private void nearestNeighboursButton_Click(object sender, EventArgs e)
        {
            nNDataGridView.AutoGenerateColumns = true;
            bool KSpecified = true;
            int  K;
            List <iKNNResult>          AllResults = new List <iKNNResult>();
            ConcurrentBag <iKNNResult> ResultBag  = new ConcurrentBag <iKNNResult>();

            try { K = Convert.ToInt32(kTextBox.Text); }
            catch
            {
                KSpecified    = false;
                kTextBox.Text = "All";
                Application.DoEvents();
                K = -1;
            }
            if (thisFormResultType == typeof(UserQueryResult))
            {
                UserQueryResult      UQR     = (UserQueryResult)thisFormResult;
                List <UserKNNResult> UKRList = new List <UserKNNResult>();
                Parallel.ForEach <UserQueryResult>(parentReference.UserQueryResults, CurrentUQR => {
                    if (CurrentUQR.AccountName != UQR.AccountName)
                    {
                        UserKNNResult UKR      = new UserKNNResult(CurrentUQR);
                        double CurrentDistance = HelperFunctions.GetEuclideanDistance(UQR.ReturnAccessVector(), CurrentUQR.ReturnAccessVector());
                        UKR.AssignKNNDistanceFromX(CurrentDistance);
                        ResultBag.Add(UKR);
                    }
                });
                UKRList         = ResultBag.Cast <UserKNNResult>().ToList <UserKNNResult>();
                AllResults      = UKRList.OrderBy(o => o.Distance).ToList().Cast <iKNNResult>().ToList();
                thisQueryReport = new UserKNNReport(AllResults.Cast <UserKNNResult>().ToList(), Ordering.Ascending);
            }
            else if (thisFormResultType == typeof(GroupingQueryResult))
            {
                GroupingQueryResult      GQR     = (GroupingQueryResult)thisFormResult;
                List <GroupingKNNResult> GKRList = new List <GroupingKNNResult>();
                Parallel.ForEach <GroupingQueryResult>(parentReference.GroupingQueryResults, CurrentGQR => {
                    if (CurrentGQR.GroupingName != GQR.GroupingName)
                    {
                        GroupingKNNResult GKR = new GroupingKNNResult(CurrentGQR);
                        double CurrentDistance;
                        if (parentReference.ClusterByRelativeCount)
                        {
                            CurrentDistance = HelperFunctions.GetEuclideanDistance(GQR.ReturnAccessVector(), CurrentGQR.ReturnAccessVector());
                        }
                        else
                        {
                            CurrentDistance = HelperFunctions.GetEuclideanDistance(GQR.ReturnTF_IDFVector(), CurrentGQR.ReturnTF_IDFVector());
                        }
                        GKR.AssignKNNDistanceFromX(CurrentDistance);
                        ResultBag.Add(GKR);
                    }
                });
                GKRList         = ResultBag.Cast <GroupingKNNResult>().ToList();
                AllResults      = GKRList.OrderBy(o => o.Distance).ToList().Cast <iKNNResult>().ToList();
                thisQueryReport = new GroupingKNNReport(AllResults.Cast <GroupingKNNResult>().ToList(), Ordering.Ascending);
            }
            else
            {
            }

            if (KSpecified && K <= AllResults.Count)
            {
                List <iKNNResult> Outlist = new List <iKNNResult>();
                for (int i = 0; i < K; i++)
                {
                    Outlist.Add(AllResults[i]);
                }
                //AllKNNResults = Outlist;
                if (thisFormResultType == typeof(UserQueryResult))
                {
                    thisQueryReport = new UserKNNReport(Outlist.Cast <UserKNNResult>().ToList(), Ordering.Ascending);
                }
                else if (thisFormResultType == typeof(GroupingQueryResult))
                {
                    thisQueryReport = new GroupingKNNReport(Outlist.Cast <GroupingKNNResult>().ToList(), Ordering.Ascending);
                }
                else
                {
                }
            }
            else
            {
                AllKNNResults = AllResults;
            }
            if (thisFormResultType == typeof(UserQueryResult))
            {
                UserKNNReport ReportPointer = (UserKNNReport)thisQueryReport;
                thisBindingSource.DataSource = ReportPointer.QRList;
                //thisBindingSource.DataSource = (UserKNNReport)thisQueryReport..Cast<UserKNNResult>().ToList();
                nNDataGridView.DataSource = thisBindingSource;
            }
            else if (thisFormResultType == typeof(GroupingQueryResult))
            {
                GroupingKNNReport ReportPointer = (GroupingKNNReport)thisQueryReport;
                thisBindingSource.DataSource = ReportPointer.QRList;

                nNDataGridView.DataSource = thisBindingSource;
            }
            else
            {
            }
        }