Exemplo n.º 1
0
        public int UpdateRow(DbTransaction pTran, GroupFunction GroupFunction, bool CreateTransaction)
        {
            int           intRow    = 0;
            DbTransaction objTran   = pTran;
            Exception     exception = null;

            try
            {
                if (pTran == null && CreateTransaction == true)
                {
                    objTran = GroupFunctionData.CreateTransaction();
                }
                intRow = GroupFunctionData.UpdateRow(objTran, GroupFunction);
                if (pTran == null && objTran != null && CreateTransaction == true)
                {
                    GroupFunctionData.CommitTransaction(objTran, true);
                    objTran = null;
                }
            }
            catch (Exception EX)
            {
                exception = EX;
                if (pTran == null && objTran != null && CreateTransaction == true)
                {
                    GroupFunctionData.RollbackTransaction(objTran, true);
                    objTran = null;
                }
            }
            finally
            {
            }
            return(intRow);
        }
Exemplo n.º 2
0
        public static bool MapGroupAsInput(GroupDTO groupDTO)
        {
            bool result = default(bool);

            _Group = new Group();
            _GroupFunctionListInput = new List <GroupFunction>();
            GroupFunction _GroupFunctionTemp = default(GroupFunction);

            if (groupDTO != null)
            {
                // Group Data Part
                _Group.Id     = groupDTO.Id;
                _Group.name   = groupDTO.name;
                _Group.status = groupDTO.status;

                // Functions Data Part
                if (groupDTO.GroupFunctions != null && groupDTO.GroupFunctions.Count > 0)
                {
                    foreach (FunctionDTO _FunctionDTO in groupDTO.GroupFunctions)
                    {
                        _GroupFunctionTemp         = new GroupFunction();
                        _GroupFunctionTemp.groupId = _FunctionDTO.Id;
                        _GroupFunctionListInput.Add(_GroupFunctionTemp);
                    }

                    result = true;
                }
            }

            return(result);
        }
Exemplo n.º 3
0
        public GroupFunctionList SelectRows(DbTransaction pTran, System.Int32?Id, System.Int32?functionId, System.Int32?groupId)
        {
            GroupFunctionList GroupFunctionList = new GroupFunctionList();
            Exception         exception         = null;

            DbParameter[] Parameters = new DbParameter[3];
            Parameters[0] = _getIdParameter(Id, ParameterDirection.Input);
            Parameters[1] = _getfunctionIdParameter(functionId, ParameterDirection.Input);
            Parameters[2] = _getgroupIdParameter(groupId, ParameterDirection.Input);

            DbDataReader Dr = ExecuteReader(pTran, "[Lookups].[SelectGroupFunction]", Parameters);

            try
            {
                if (Dr != null)
                {
                    while (Dr.Read())
                    {
                        GroupFunction GroupFunction = new GroupFunction();
                        if (Dr["Id"] != DBNull.Value)
                        {
                            GroupFunction.Id = (System.Int32)Dr["Id"];
                        }
                        if (Dr["functionId"] != DBNull.Value)
                        {
                            GroupFunction.functionId = (System.Int32?)Dr["functionId"];
                        }
                        if (Dr["groupId"] != DBNull.Value)
                        {
                            GroupFunction.groupId = (System.Int32?)Dr["groupId"];
                        }
                        if (Dr["status"] != DBNull.Value)
                        {
                            GroupFunction.status = (System.Boolean?)Dr["status"];
                        }
                        GroupFunctionList.FillRow(GroupFunction);
                        GroupFunction = null;
                    }
                }
            }
            catch (Exception Ex)
            {
                exception = Ex;
            }
            finally
            {
                if (Dr != null)
                {
                    if (Dr.IsClosed == false)
                    {
                        Dr.Close();
                    }
                    Dr = null;
                }
            }
            return(GroupFunctionList);
        }
Exemplo n.º 4
0
        public int DeleteRow(DbTransaction pTran, GroupFunction GroupFunction)
        {
            int intRows = 0;

            DbParameter[] Parameters = new DbParameter[1];
            Parameters[0] = _getIdParameter(GroupFunction.Id, ParameterDirection.Input);

            intRows = ExecuteNonQuery(pTran, "[Lookups].[DeleteGroupFunction]", Parameters);

            return(intRows);
        }
Exemplo n.º 5
0
        public int UpdateRow(DbTransaction pTran, GroupFunction GroupFunction)
        {
            int intRows = 0;

            DbParameter[] Parameters = new DbParameter[4];
            Parameters[0] = _getIdParameter(GroupFunction.Id, ParameterDirection.Input);
            Parameters[1] = _getfunctionIdParameter(GroupFunction.functionId, ParameterDirection.Input);
            Parameters[2] = _getgroupIdParameter(GroupFunction.groupId, ParameterDirection.Input);
            Parameters[3] = _getstatusParameter(GroupFunction.status, ParameterDirection.Input);

            intRows = ExecuteNonQuery(pTran, "[Lookups].[UpdateGroupFunction]", Parameters);

            return(intRows);
        }
Exemplo n.º 6
0
    protected void btApply_Click(object sender, EventArgs e)
    {
        int groupID               = AppUtils.Request("id");
        var _GroupFunction        = new GroupFunction();
        List <GroupFunction> list = _GroupFunction.GetList(groupID);

        for (int i = 0; i < rptList.Items.Count; i++)
        {
            CheckBox cbx        = (CheckBox)rptList.Items[i].FindControl("cbxRole");
            Label    lbl        = (Label)rptList.Items[i].FindControl("lblFunctionID");
            int      functionID = Convert.ToInt32(lbl.Text);

            _GroupFunction.Update(groupID, functionID, Convert.ToInt32(cbx.Checked));
        }
    }
Exemplo n.º 7
0
        public int InsertRow(DbTransaction pTran, GroupFunction GroupFunction)
        {
            int intRows = 0;

            DbParameter[] Parameters = new DbParameter[4];
            Parameters[0] = _getIdParameter(GroupFunction.Id, ParameterDirection.Output);
            Parameters[1] = _getfunctionIdParameter(GroupFunction.functionId, ParameterDirection.Input);
            Parameters[2] = _getgroupIdParameter(GroupFunction.groupId, ParameterDirection.Input);
            Parameters[3] = _getstatusParameter(GroupFunction.status, ParameterDirection.Input);

            intRows = ExecuteNonQuery(pTran, "[Lookups].[InsertGroupFunction]", Parameters);

            if (Parameters[0].Value != DBNull.Value)
            {
                GroupFunction.Id = (System.Int32)Parameters[0].Value;
            }

            return(intRows);
        }
Exemplo n.º 8
0
    private void init()
    {
        var _Group = new Groups();

        _Group = _Group.Get(AppUtils.Request("id"));
        if (_Group == null)
        {
            Response.Redirect(Constant.ADMIN_PATH + Resources.Url.GroupsList);
        }

        txtName.Text        = _Group.Name;
        txtOrder.Text       = _Group.Order.ToString();
        txtDescription.Text = _Group.Description;

        // Gán quyền
        var _Function = new Functions();

        rptList.DataSource = _Function.GetList();
        rptList.DataBind();

        var _GroupFunction        = new GroupFunction();
        List <GroupFunction> list = _GroupFunction.GetList(_Group.GroupID);

        for (int i = 0; i < rptList.Items.Count; i++)
        {
            CheckBox cbx        = (CheckBox)rptList.Items[i].FindControl("cbxRole");
            Label    lbl        = (Label)rptList.Items[i].FindControl("lblFunctionID");
            int      functionID = Convert.ToInt32(lbl.Text);
            for (int j = 0; j < list.Count; j++)
            {
                _GroupFunction = list[j];
                if (functionID == _GroupFunction.FunctionID)
                {
                    cbx.Checked = true;
                    break;
                }
            }
        }
    }
Exemplo n.º 9
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="propertyName">输出属性的名称</param>
 /// <param name="groupFunction"></param>
 public OutputExpression(string propertyName, GroupFunction groupFunction)
 {
     Property = new PropertyExpression(propertyName, groupFunction);
 }
Exemplo n.º 10
0
 /// <summary>构造函数</summary>
 /// <param name="propertyName">初始化搜索条件的字段全称</param>
 /// <param name="groupFunction"></param>
 /// <param name="conditionOperator">初始化搜索运算类型</param>
 /// <param name="conditionValue">初始化搜索的条件值</param>
 public ConditionExpression(string propertyName, GroupFunction groupFunction, ConditionOperator conditionOperator, object conditionValue)
 {
     Property          = new PropertyExpression(propertyName, groupFunction);
     ConditionOperator = conditionOperator;
     ConditionValue    = conditionValue;
 }
Exemplo n.º 11
0
        static private void Initialize(int group)
        {
            Label[] labelArray = GroupFunction.DescendLabelsByNumber(group);
            #region 初始化
            TDDSVariable.Sij = new Sij(1);
            //整体的信息,用于构造互信息参数,求树(所有句子一棵树)
            IDictionary <Label, double>     labelFloatDic  = new Dictionary <Label, double>();
            IDictionary <LabelPair, double> labelPairFloat = new Dictionary <LabelPair, double>();//前后无序,45个,用于初始化
            //Function.InitializeEmptyLabelDic(ref labelFloatDic, ref labelPairFloat, labelArray);
            IDictionary <Label, double>     numberOfLabelTrue              = new Dictionary <Label, double>(labelFloatDic);
            IDictionary <Label, double>     numberOfLabelFalse             = new Dictionary <Label, double>(labelFloatDic);
            IDictionary <LabelPair, double> numberOfLabel1TrueLabel2True   = new Dictionary <LabelPair, double>(labelPairFloat);
            IDictionary <LabelPair, double> numberOfLabel1TrueLabel2False  = new Dictionary <LabelPair, double>(labelPairFloat);
            IDictionary <LabelPair, double> numberOfLabel1FalseLabel2True  = new Dictionary <LabelPair, double>(labelPairFloat);
            IDictionary <LabelPair, double> numberOfLabel1FalseLabel2False = new Dictionary <LabelPair, double>(labelPairFloat);

            IDictionary <Sentence, IDictionary <Label, double> >     ProbabilityOfLabelTrue              = new Dictionary <Sentence, IDictionary <Label, double> >();
            IDictionary <Sentence, IDictionary <Label, double> >     ProbabilityOfLabelFalse             = new Dictionary <Sentence, IDictionary <Label, double> >();
            IDictionary <Sentence, IDictionary <LabelPair, double> > ProbabilityOfLabel1TrueLabel2True   = new Dictionary <Sentence, IDictionary <LabelPair, double> >();
            IDictionary <Sentence, IDictionary <LabelPair, double> > ProbabilityOfLabel1TrueLabel2False  = new Dictionary <Sentence, IDictionary <LabelPair, double> >();
            IDictionary <Sentence, IDictionary <LabelPair, double> > ProbabilityOfLabel1FalseLabel2True  = new Dictionary <Sentence, IDictionary <LabelPair, double> >();
            IDictionary <Sentence, IDictionary <LabelPair, double> > ProbabilityOfLabel1FalseLabel2False = new Dictionary <Sentence, IDictionary <LabelPair, double> >();

            //每句的信息,用于树的具体值(每个句子对应的树的值不同)
            foreach (Sentence sentence in Variable.Sentences)
            {
                ProbabilityOfLabelTrue.Add(sentence, new Dictionary <Label, double>(labelFloatDic));
                ProbabilityOfLabelFalse.Add(sentence, new Dictionary <Label, double>(labelFloatDic));
                ProbabilityOfLabel1TrueLabel2True.Add(sentence, new Dictionary <LabelPair, double>(labelPairFloat));
                ProbabilityOfLabel1TrueLabel2False.Add(sentence, new Dictionary <LabelPair, double>(labelPairFloat));
                ProbabilityOfLabel1FalseLabel2True.Add(sentence, new Dictionary <LabelPair, double>(labelPairFloat));
                ProbabilityOfLabel1FalseLabel2False.Add(sentence, new Dictionary <LabelPair, double>(labelPairFloat));
            }
            #endregion
            #region 求互信息的参数
            int N = 0;
            foreach (Sentence sentence in Variable.Sentences)
            {
                foreach (Annotation annotation in sentence.AnnotaitonGroups[group].AnnotatorAnnotationDic.Values)
                {
                    ++N;
                    IList <Label> traversedLabels = new List <Label>();
                    foreach (Label label1 in labelArray)
                    {
                        traversedLabels.Add(label1);
                        if (annotation.Labels[label1])
                        {
                            ++numberOfLabelTrue[label1];
                            ++ProbabilityOfLabelTrue[sentence][label1];
                            foreach (Label label2 in labelArray)
                            {
                                if (!traversedLabels.Contains(label2))
                                {
                                    if (annotation.Labels[label2])
                                    {
                                        ++numberOfLabel1TrueLabel2True[new LabelPair(label1, label2)];
                                        ++ProbabilityOfLabel1TrueLabel2True[sentence][new LabelPair(label1, label2)];
                                    }
                                    else
                                    {
                                        ++numberOfLabel1TrueLabel2False[new LabelPair(label1, label2)];
                                        ++ProbabilityOfLabel1TrueLabel2False[sentence][new LabelPair(label1, label2)];
                                    }
                                }
                            }
                        }
                        else
                        {
                            ++numberOfLabelFalse[label1];
                            ++ProbabilityOfLabelFalse[sentence][label1];
                            foreach (Label label2 in labelArray)
                            {
                                if (!traversedLabels.Contains(label2))
                                {
                                    if (annotation.Labels[label2])
                                    {
                                        ++numberOfLabel1FalseLabel2True[new LabelPair(label1, label2)];
                                        ++ProbabilityOfLabel1FalseLabel2True[sentence][new LabelPair(label1, label2)];
                                    }
                                    else
                                    {
                                        ++numberOfLabel1FalseLabel2False[new LabelPair(label1, label2)];
                                        ++ProbabilityOfLabel1FalseLabel2False[sentence][new LabelPair(label1, label2)];
                                    }
                                }
                            }
                        }
                    }
                }
            }
            #endregion
            #region 求树(全部一棵树)
            IList <KeyValuePair <LabelPair, double> > tree = TDDSFunction.GenerateIMTree(numberOfLabelTrue, numberOfLabelFalse,
                                                                                         numberOfLabel1TrueLabel2True, numberOfLabel1TrueLabel2False,
                                                                                         numberOfLabel1FalseLabel2True, numberOfLabel1FalseLabel2False, N, labelArray);//此处是导致多线程结果不同的原因:虽然换组时Variable.LabelArray不会变化,但原先sentence中用于CommonTree和DistinctTree计算的成员属性没有做区分。
            #endregion
            #region 初始化Sij
            if (TDDSVariable.SmoothTree == Smoothing.None)
            {
                foreach (Sentence sentence in Variable.Sentences)
                {
                    foreach (Label label in labelArray)
                    {
                        ProbabilityOfLabelTrue[sentence][label]  /= Variable.NumberOfAnnotationsPerSentenceAfterGrouping;
                        ProbabilityOfLabelFalse[sentence][label] /= Variable.NumberOfAnnotationsPerSentenceAfterGrouping;
                    }
                    foreach (LabelPair labelPair in labelPairFloat.Keys)
                    {
                        ProbabilityOfLabel1TrueLabel2True[sentence][labelPair]   /= Variable.NumberOfAnnotationsPerSentenceAfterGrouping;
                        ProbabilityOfLabel1TrueLabel2False[sentence][labelPair]  /= Variable.NumberOfAnnotationsPerSentenceAfterGrouping;
                        ProbabilityOfLabel1FalseLabel2True[sentence][labelPair]  /= Variable.NumberOfAnnotationsPerSentenceAfterGrouping;
                        ProbabilityOfLabel1FalseLabel2False[sentence][labelPair] /= Variable.NumberOfAnnotationsPerSentenceAfterGrouping;
                    }
                }
            }
            else
            {
                IDictionary <Smoothing, double[]> smoothingNumber = Function.SmoothingNumber(Variable.NumberOfAnnotationsPerSentenceAfterGrouping);
                foreach (Sentence sentence in Variable.Sentences)
                {
                    foreach (Label label in labelArray)
                    {
                        ProbabilityOfLabelTrue[sentence][label]  = (ProbabilityOfLabelTrue[sentence][label] + smoothingNumber[TDDSVariable.SmoothTree][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[TDDSVariable.SmoothTree][1]);
                        ProbabilityOfLabelFalse[sentence][label] = (ProbabilityOfLabelFalse[sentence][label] + smoothingNumber[TDDSVariable.SmoothTree][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[TDDSVariable.SmoothTree][1]);;
                    }
                    foreach (LabelPair labelPair in labelPairFloat.Keys)
                    {
                        ProbabilityOfLabel1TrueLabel2True[sentence][labelPair]   = (ProbabilityOfLabel1TrueLabel2True[sentence][labelPair] + smoothingNumber[TDDSVariable.SmoothTree][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[TDDSVariable.SmoothTree][1]);
                        ProbabilityOfLabel1TrueLabel2False[sentence][labelPair]  = (ProbabilityOfLabel1TrueLabel2False[sentence][labelPair] + smoothingNumber[TDDSVariable.SmoothTree][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[TDDSVariable.SmoothTree][1]);
                        ProbabilityOfLabel1FalseLabel2True[sentence][labelPair]  = (ProbabilityOfLabel1FalseLabel2True[sentence][labelPair] + smoothingNumber[TDDSVariable.SmoothTree][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[TDDSVariable.SmoothTree][1]);
                        ProbabilityOfLabel1FalseLabel2False[sentence][labelPair] = (ProbabilityOfLabel1FalseLabel2False[sentence][labelPair] + smoothingNumber[TDDSVariable.SmoothTree][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[TDDSVariable.SmoothTree][1]);
                    }
                }
            }
            foreach (Sentence sentence in Variable.Sentences)
            {
                for (int l = 0; l < Math.Pow(2, Variable.LabelArray.Length); ++l)
                {
                    Labelset Labelset = new Labelset(Variable.LabelArray, l);
                    TDDSVariable.Sij.Value[sentence].Add(Labelset, 1);
                    if (TDDSVariable.SmoothTree == Smoothing.None)
                    {
                        if (Labelset.Labels[tree[0].Key.First])
                        {
                            if (ProbabilityOfLabelTrue[sentence][tree[0].Key.First] != 0)
                            {
                                TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabelTrue[sentence][tree[0].Key.First];//应该除,除后准确率更高,原因未知
                            }
                        }
                        else
                        {
                            if (ProbabilityOfLabelFalse[sentence][tree[0].Key.First] != 0)
                            {
                                TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabelFalse[sentence][tree[0].Key.First];
                            }
                        }
                    }
                    else
                    {
                        if (Labelset.Labels[tree[0].Key.First])
                        {
                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabelTrue[sentence][tree[0].Key.First];
                        }
                        else
                        {
                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabelFalse[sentence][tree[0].Key.First];
                        }
                    }
                    foreach (KeyValuePair <LabelPair, double> labelPairAndValue in tree)
                    {
                        LabelPair labelPair = labelPairAndValue.Key;
                        if (TDDSVariable.SmoothTree == Smoothing.None)
                        {
                            if (Labelset.Labels[labelPair.First])
                            {
                                if (ProbabilityOfLabelTrue[sentence][labelPair.First] != 0)//考虑分母为0的情况
                                {
                                    if (Labelset.Labels[labelPair.Second])
                                    {
                                        if (ProbabilityOfLabel1TrueLabel2True[sentence].ContainsKey(labelPair))
                                        {
                                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1TrueLabel2True[sentence][labelPair] / ProbabilityOfLabelTrue[sentence][labelPair.First];
                                        }
                                        else
                                        {
                                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1TrueLabel2True[sentence][labelPair.Reverse] / ProbabilityOfLabelTrue[sentence][labelPair.First];
                                        }
                                    }
                                    else
                                    {
                                        if (ProbabilityOfLabel1TrueLabel2False[sentence].ContainsKey(labelPair))
                                        {
                                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1TrueLabel2False[sentence][labelPair] / ProbabilityOfLabelTrue[sentence][labelPair.First];
                                        }
                                        else
                                        {
                                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1FalseLabel2True[sentence][labelPair.Reverse] / ProbabilityOfLabelTrue[sentence][labelPair.First];
                                        }
                                    }
                                }
                                else
                                {
                                    TDDSVariable.Sij.Value[sentence][new Labelset(Variable.LabelArray, l)] *= 0;//此处应该是0,不是1
                                    break;
                                }
                            }
                            else
                            {
                                if (ProbabilityOfLabelFalse[sentence][labelPair.First] != 0)//考虑分母为0的情况
                                {
                                    if (Labelset.Labels[labelPair.Second])
                                    {
                                        if (ProbabilityOfLabel1FalseLabel2True[sentence].ContainsKey(labelPair))
                                        {
                                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1FalseLabel2True[sentence][labelPair] / ProbabilityOfLabelFalse[sentence][labelPair.First];
                                        }
                                        else
                                        {
                                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1TrueLabel2False[sentence][labelPair.Reverse] / ProbabilityOfLabelFalse[sentence][labelPair.First];
                                        }
                                    }
                                    else
                                    {
                                        if (ProbabilityOfLabel1FalseLabel2False[sentence].ContainsKey(labelPair))
                                        {
                                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1FalseLabel2False[sentence][labelPair] / ProbabilityOfLabelFalse[sentence][labelPair.First];
                                        }
                                        else
                                        {
                                            TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1FalseLabel2False[sentence][labelPair.Reverse] / ProbabilityOfLabelFalse[sentence][labelPair.First];
                                        }
                                    }
                                }
                                else
                                {
                                    TDDSVariable.Sij.Value[sentence][new Labelset(Variable.LabelArray, l)] *= 0;
                                    break;
                                }
                            }
                        }
                        else
                        {
                            if (Labelset.Labels[labelPair.First])
                            {
                                if (Labelset.Labels[labelPair.Second])
                                {
                                    if (ProbabilityOfLabel1TrueLabel2True[sentence].ContainsKey(labelPair))
                                    {
                                        TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1TrueLabel2True[sentence][labelPair] / ProbabilityOfLabelTrue[sentence][labelPair.First];
                                    }
                                    else
                                    {
                                        TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1TrueLabel2True[sentence][labelPair.Reverse] / ProbabilityOfLabelTrue[sentence][labelPair.First];
                                    }
                                }
                                else
                                {
                                    if (ProbabilityOfLabel1TrueLabel2False[sentence].ContainsKey(labelPair))
                                    {
                                        TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1TrueLabel2False[sentence][labelPair] / ProbabilityOfLabelTrue[sentence][labelPair.First];
                                    }
                                    else
                                    {
                                        TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1FalseLabel2True[sentence][labelPair.Reverse] / ProbabilityOfLabelTrue[sentence][labelPair.First];
                                    }
                                }
                            }
                            else
                            {
                                if (Labelset.Labels[labelPair.Second])
                                {
                                    if (ProbabilityOfLabel1FalseLabel2True[sentence].ContainsKey(labelPair))
                                    {
                                        TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1FalseLabel2True[sentence][labelPair] / ProbabilityOfLabelFalse[sentence][labelPair.First];
                                    }
                                    else
                                    {
                                        TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1TrueLabel2False[sentence][labelPair.Reverse] / ProbabilityOfLabelFalse[sentence][labelPair.First];
                                    }
                                }
                                else
                                {
                                    if (ProbabilityOfLabel1FalseLabel2False[sentence].ContainsKey(labelPair))
                                    {
                                        TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1FalseLabel2False[sentence][labelPair] / ProbabilityOfLabelFalse[sentence][labelPair.First];
                                    }
                                    else
                                    {
                                        TDDSVariable.Sij.Value[sentence][Labelset] *= ProbabilityOfLabel1FalseLabel2False[sentence][labelPair.Reverse] / ProbabilityOfLabelFalse[sentence][labelPair.First];
                                    }
                                }
                            }
                        }
                    }
                }
            }
            //for (int i = 0; i < Variable.Sentences.Count; ++i)
            //{
            //    double all = 0;
            //    for (int j = 0; j < DependentVariable.NumberOfIntlabel; ++j)
            //    {
            //        all += TDDSVariable.Sij.Value[sentence][new Labelset(bilabel.ToArray(), j)];
            //    }
            //    for (int j = 0; j < DependentVariable.NumberOfIntlabel; ++j)
            //    {
            //        TDDSVariable.Sij.Value[sentence][new Labelset(bilabel.ToArray(), j)] /= all;
            //    }
            //}
            #endregion
            //Variable.OutputFile.WriteLine(TDDSVariable.Sij.ToString(DependentVariable.NumberOfIntlabel));
            //Variable.OutputFile.Close();
            //double[] ii = new double[Variable.Sentences.Count];
            //foreach (Sentence Sentence in Variable.Sentences)
            //{
            //    for (int l = 0; l < DependentVariable.NumberOfIntlabel; ++l)
            //    {
            //        ii[Sentence.ID] += TDDSVariable.Sij.Value[Sentence.ID, l];
            //    }
            //}
        }
Exemplo n.º 12
0
 public override string ToString()
 {
     return(GroupFunction == GroupFunction.None ? PropertyName : (GroupFunction.ToString() + "(" + PropertyName + ")"));
 }
Exemplo n.º 13
0
 public int InsertRow(DbTransaction pTran, GroupFunction GroupFunction)
 {
     return(InsertRow(pTran, GroupFunction, false));
 }
Exemplo n.º 14
0
        static public void RunSPDS()
        {
            if (!SupervisedFunction.IsNumberOfTraningSentencesValid())
            {
                return;
            }
            double NumericIndependentEuclidean = 0;
            double BinaryIndependentDice       = 0;
            double BinaryDependentDice         = 0;
            double BinaryIndependentCompare    = 0;
            double BinaryDependentCompare      = 0;
            double BinaryDependentJaccard      = 0;
            double BinaryAndNumeric            = 0;

            for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
            {
                Label[] LabelArray = GroupFunction.DescendLabelsByNumber(groupIndex);
                foreach (Sentence sentence in Variable.Sentences)
                {
                    if (sentence.ID < SupervisedVariable.NumberOfTraningSentences)
                    {
                        continue;
                    }
                    sentence.AnnotaitonGroups[groupIndex].SPDSNumResult = new NumericResult();
                    sentence.AnnotaitonGroups[groupIndex].SPDSResult    = new Result();
                }
                IList <LabelPair> bilabels = PDSFunction.GenerateBilabels(groupIndex);
                foreach (LabelPair bilabel in bilabels)
                {
                    InitializeTrainingSijAndPj(bilabel);
                    CalculatePij(bilabel, groupIndex);
                    CalculatePj(bilabel);
                    CalculatePAkjl(bilabel, groupIndex);
                    CalculateSij(bilabel, groupIndex);
                    ObtainLabelResult(bilabel, groupIndex);
                }
                Function.WriteBinaryResultFile("SPDS", groupIndex);//只输出,计算在前面
                double groupNumericIndependentEuclidean = 0;
                double groupBinaryIndependentDice       = 0;
                double groupBinaryDependentDice         = 0;
                double groupBinaryIndependentCompare    = 0;
                double groupBinaryDependentCompare      = 0;
                double groupBinaryDependentJaccard      = 0;
                double groupBinaryAndNumeric            = 0;
                foreach (Sentence sentence in Variable.Sentences)
                {
                    if (sentence.ID < SupervisedVariable.NumberOfTraningSentences)
                    {
                        continue;
                    }
                    groupNumericIndependentEuclidean += SimilarityMeasure.Euclidean(sentence.AnnotaitonGroups[groupIndex].SPDSNumResult, sentence.NumericGold);
                    groupBinaryIndependentDice       += SimilarityMeasure.DicePlusANumber(sentence.AnnotaitonGroups[groupIndex].SPDSNumResult.ToBinaryResult(), sentence.NumericGold.ToBinaryResult());
                    groupBinaryIndependentCompare    += SimilarityMeasure.Compare(sentence.AnnotaitonGroups[groupIndex].SPDSNumResult.ToBinaryResult(), sentence.NumericGold.ToBinaryResult());
                    groupBinaryDependentCompare      += SimilarityMeasure.Compare(sentence.AnnotaitonGroups[groupIndex].SPDSResult, sentence.BinaryGold);
                    groupBinaryDependentDice         += SimilarityMeasure.DicePlusANumber(sentence.AnnotaitonGroups[groupIndex].SPDSResult, sentence.BinaryGold);
                    groupBinaryDependentJaccard      += SimilarityMeasure.JaccardPlusANumber(sentence.AnnotaitonGroups[groupIndex].SPDSResult, sentence.BinaryGold);
                    groupBinaryAndNumeric            += SimilarityMeasure.BinaryAndNumeric(sentence.AnnotaitonGroups[groupIndex].SPDSResult, sentence.NumericGold);
                }
                NumericIndependentEuclidean += groupNumericIndependentEuclidean / (Variable.Sentences.Count - SupervisedVariable.NumberOfTraningSentences);
                BinaryIndependentDice       += groupBinaryIndependentDice / (Variable.Sentences.Count - SupervisedVariable.NumberOfTraningSentences);
                BinaryDependentDice         += groupBinaryDependentDice / (Variable.Sentences.Count - SupervisedVariable.NumberOfTraningSentences);
                BinaryIndependentCompare    += groupBinaryIndependentCompare / (Variable.Sentences.Count - SupervisedVariable.NumberOfTraningSentences);
                BinaryDependentCompare      += groupBinaryDependentCompare / (Variable.Sentences.Count - SupervisedVariable.NumberOfTraningSentences);
                BinaryDependentJaccard      += groupBinaryDependentJaccard / (Variable.Sentences.Count - SupervisedVariable.NumberOfTraningSentences);
                BinaryAndNumeric            += groupBinaryAndNumeric / (Variable.Sentences.Count - SupervisedVariable.NumberOfTraningSentences);
            }
            NumericIndependentEuclidean /= GroupVariable.AnnotatorGroups.Length;
            BinaryIndependentDice       /= GroupVariable.AnnotatorGroups.Length;
            BinaryDependentDice         /= GroupVariable.AnnotatorGroups.Length;
            BinaryIndependentCompare    /= GroupVariable.AnnotatorGroups.Length;
            BinaryDependentCompare      /= GroupVariable.AnnotatorGroups.Length;
            BinaryDependentJaccard      /= GroupVariable.AnnotatorGroups.Length;
            BinaryAndNumeric            /= GroupVariable.AnnotatorGroups.Length;
        }
Exemplo n.º 15
0
        public int DeleteRow(GroupFunction GroupFunction)
        {
            DbTransaction Tran = null;

            return(DeleteRow(Tran, GroupFunction));
        }
Exemplo n.º 16
0
        public int UpdateRow(GroupFunction GroupFunction)
        {
            DbTransaction Tran = null;

            return(UpdateRow(Tran, GroupFunction));
        }
Exemplo n.º 17
0
        public int InsertRow(GroupFunction GroupFunction)
        {
            DbTransaction Tran = null;

            return(InsertRow(Tran, GroupFunction));
        }
Exemplo n.º 18
0
 public int DeleteRow(DbTransaction pTran, GroupFunction GroupFunction)
 {
     return(DeleteRow(pTran, GroupFunction, false));
 }
Exemplo n.º 19
0
 static public Sij Initialize(int groupIndex, double threshold, IndependenceEstimation independentEstimation)
 {
     #region 初始化
     Sij sij = new Sij(1);
     #endregion
     Label[] labelArray = GroupFunction.DescendLabelsByNumber(groupIndex);
     Graph   BN         = NDDSFunction.BuildBN(groupIndex, labelArray, independentEstimation, threshold);
     #region 从BN中求每个情感(事件)的父节点(条件)
     IDictionary <Label, IList <Label> > LabelsAndPas = new Dictionary <Label, IList <Label> >();
     foreach (Label label in labelArray)
     {
         LabelsAndPas.Add(label, new List <Label>());
     }
     foreach (KeyValuePair <LabelPair, bool> hasRelationship in BN.AdjMatrix)
     {
         if (hasRelationship.Value)
         {
             LabelsAndPas[hasRelationship.Key.Second].Add(hasRelationship.Key.First);
         }
     }
     #endregion
     #region 求计算联合概率的参数
     IDictionary <Sentence, IDictionary <LabelAndWitness, double> > Probability = new Dictionary <Sentence, IDictionary <LabelAndWitness, double> >();
     foreach (Sentence sentence in Variable.Sentences)
     {
         Probability.Add(sentence, new Dictionary <LabelAndWitness, double>());
     }
     IDictionary <Smoothing, double[]> smoothingNumber = Function.SmoothingNumber(2);
     foreach (KeyValuePair <Label, IList <Label> > labelAndPas in LabelsAndPas)
     {
         if (labelAndPas.Value.Count == 0)
         {
             foreach (Sentence sentence in Variable.Sentences)
             {
                 double numberOfLabelTrue  = 0;
                 double numberOfLabelFalse = 0;
                 foreach (Annotation annotation in sentence.AnnotaitonGroups[groupIndex].AnnotatorAnnotationDic.Values)
                 {
                     if (annotation.Labels[labelAndPas.Key])
                     {
                         ++numberOfLabelTrue;
                     }
                     else
                     {
                         ++numberOfLabelFalse;
                     }
                 }
                 if (NDDSVariable.SmoothBN != Smoothing.None)
                 {
                     Probability[sentence].Add(new LabelAndWitness(new Labelset(labelAndPas.Key, false), new Labelset()), (numberOfLabelFalse + smoothingNumber[NDDSVariable.SmoothBN][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[NDDSVariable.SmoothBN][1]));
                     Probability[sentence].Add(new LabelAndWitness(new Labelset(labelAndPas.Key, true), new Labelset()), (numberOfLabelTrue + (numberOfLabelTrue + smoothingNumber[NDDSVariable.SmoothBN][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[NDDSVariable.SmoothBN][1])));
                 }
                 else
                 {
                     Probability[sentence].Add(new LabelAndWitness(new Labelset(labelAndPas.Key, false), new Labelset()), numberOfLabelFalse / Variable.NumberOfAnnotationsPerSentenceAfterGrouping);
                     Probability[sentence].Add(new LabelAndWitness(new Labelset(labelAndPas.Key, true), new Labelset()), numberOfLabelTrue / Variable.NumberOfAnnotationsPerSentenceAfterGrouping);
                 }
             }
         }
         else
         {
             for (int i = 0; i < Math.Pow(2, labelAndPas.Value.Count); ++i)
             {
                 Labelset Labelset = new Labelset(labelAndPas.Value, i);
                 foreach (Sentence sentence in Variable.Sentences)
                 {
                     double numberOfLabelTrue  = 0;
                     double numberOfLabelFalse = 0;
                     foreach (Annotation annotation in sentence.AnnotaitonGroups[groupIndex].AnnotatorAnnotationDic.Values)
                     {
                         if (annotation.IsAccordingToLabelset(Labelset))
                         {
                             if (annotation.Labels[labelAndPas.Key])
                             {
                                 ++numberOfLabelTrue;
                             }
                             else
                             {
                                 ++numberOfLabelFalse;
                             }
                         }
                     }
                     if (NDDSVariable.SmoothBN != Smoothing.None)
                     {
                         Probability[sentence].Add(new LabelAndWitness(new Labelset(labelAndPas.Key, false), Labelset), (numberOfLabelFalse + smoothingNumber[NDDSVariable.SmoothBN][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[NDDSVariable.SmoothBN][1]));
                         Probability[sentence].Add(new LabelAndWitness(new Labelset(labelAndPas.Key, true), Labelset), (numberOfLabelTrue + smoothingNumber[NDDSVariable.SmoothBN][0]) / (Variable.NumberOfAnnotationsPerSentenceAfterGrouping + smoothingNumber[NDDSVariable.SmoothBN][1]));
                     }
                     else
                     {
                         Probability[sentence].Add(new LabelAndWitness(new Labelset(labelAndPas.Key, false), Labelset), numberOfLabelFalse / Variable.NumberOfAnnotationsPerSentenceAfterGrouping);
                         Probability[sentence].Add(new LabelAndWitness(new Labelset(labelAndPas.Key, true), Labelset), numberOfLabelTrue / Variable.NumberOfAnnotationsPerSentenceAfterGrouping);
                     }
                 }
             }
         }
     }
     #endregion
     #region 计算Sij
     IDictionary <Sentence, double> denominator = new Dictionary <Sentence, double>();//归一化参数
     foreach (Sentence sentence in Variable.Sentences)
     {
         sij.Value.Add(sentence, new Dictionary <Labelset, double>());
         denominator.Add(sentence, 0);
         for (int l = 0; l < Math.Pow(2, Variable.LabelArray.Length); ++l)
         {
             Labelset Labelset = new Labelset(Variable.LabelArray, l);
             double   value    = 1;
             foreach (Label label in labelArray)
             {
                 Labelset singleLabelAnnotation = new Labelset(label, Labelset.Labels[label]);
                 Labelset subLabelset           = new Labelset(LabelsAndPas[label], Labelset);
                 value *= Probability[sentence][new LabelAndWitness(singleLabelAnnotation, subLabelset)];
             }
             if (value != 0)
             {
                 sij.Value[sentence].Add(Labelset, value);
                 denominator[sentence] += value;
             }
         }
     }
     #endregion
     #region 归一化
     foreach (Sentence sentence in Variable.Sentences.ToArray())
     {
         foreach (Labelset labelset in sij.Value[sentence].Keys.ToArray())
         {
             sij.Value[sentence][labelset] /= denominator[sentence];
         }
     }
     #endregion
     return(sij);
 }
Exemplo n.º 20
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="propertyName">输出属性的名称</param>
 /// <param name="groupFunction"></param>
 /// <param name="alias"></param>
 public OutputExpression(string propertyName, GroupFunction groupFunction, string alias)
 {
     Property = new PropertyExpression(propertyName, groupFunction);
     Alias    = alias;
 }
Exemplo n.º 21
0
        public ActionResult Edit(int id)
        {
            WrapperViewEditProject wp = new WrapperViewEditProject();

            using (DatabaseContext db = new DatabaseContext())
            {
                //  ArrayList dayslist = new ArrayList();
                List <GroupFunction> dayslist = new List <GroupFunction>();
                try
                {
                    List <DbViewClass> gridClassList = db.gridClasses.AsNoTracking().Where(n => n.id == id).OrderBy(n => n.ProjFuncId).
                                                       ToList();

                    int           tempFuncId    = 0;
                    string        str           = "";
                    string        flag          = "X";
                    int           printflag     = 0;
                    int           idfunc        = 0;
                    int           idrel         = 0;
                    int           idapp         = 0;
                    int           estimateRecId = 0;
                    string        namefunc      = "";
                    int           totalDays     = 0;
                    int           projfuncid    = 0;
                    GroupFunction gf            = null;
                    foreach (var aa in gridClassList)
                    {
                        if (aa.FuncId != tempFuncId)
                        {
                            if (printflag == 1)
                            {
                                gf            = new GroupFunction();
                                gf.appid      = idapp;
                                gf.releaseId  = idrel;
                                gf.FuncId     = idfunc;
                                gf.FuncName   = namefunc;
                                gf.daysString = str;
                                gf.totalDays  = totalDays;
                                gf.ProjFuncId = projfuncid;
                                dayslist.Add(gf);
                                totalDays = 0;
                                str       = "";
                            }
                            printflag = 1;
                        }
                        if (str.Length == 0)
                        {
                            str = aa.estId.ToString() + "," + aa.phaseCode.ToString() + "," + aa.roleId.ToString() + "," + aa.estDays.ToString() + "," + flag;
                        }
                        else
                        {
                            str = str + "-" + aa.estId.ToString() + "," + aa.phaseCode.ToString() + "," + aa.roleId.ToString() + "," + aa.estDays.ToString() + "," + flag;
                        }

                        idfunc        = aa.FuncId;
                        idrel         = aa.RelId;
                        idapp         = aa.AppId;
                        namefunc      = aa.FuncName;
                        estimateRecId = aa.estId;
                        projfuncid    = aa.ProjFuncId;

                        totalDays  = totalDays + aa.estDays;
                        tempFuncId = aa.FuncId;
                    }
                    gf            = new GroupFunction();
                    gf.appid      = idapp;
                    gf.releaseId  = idrel;
                    gf.FuncId     = idfunc;
                    gf.FuncName   = namefunc;
                    gf.daysString = str;
                    gf.totalDays  = totalDays;
                    gf.ProjFuncId = projfuncid;
                    dayslist.Add(gf);
                    //foreach (GroupFunction i in dayslist)
                    //{
                    //    System.Diagnostics.Debug.WriteLine(i.FuncId);
                    //    System.Diagnostics.Debug.WriteLine(i.FuncName);
                    //    System.Diagnostics.Debug.WriteLine(i.appid);
                    //    System.Diagnostics.Debug.WriteLine(i.RelId);
                    //    System.Diagnostics.Debug.WriteLine(i.daysString);

                    //}

                    //List<GroupFunction> result = gridClassList.GroupBy(x => new { x.FuncId, x.FuncName, x.AppId, x.RelId })
                    //    .Select(o => o.First()).ToList().Select(o => new GroupFunction
                    //    {
                    //        FuncId = o.FuncId, FuncName = o.FuncName, appid = o.AppId, RelId = o.RelId
                    //    }).ToList();



                    //foreach (GroupFunction item in result)
                    //{
                    //    System.Diagnostics.Debug.WriteLine(item.appid);
                    //}



                    List <Phase>         phaseList    = db.Phases.ToList();
                    List <Role>          roleList     = db.Roles.ToList();
                    List <Application>   appList      = db.Applications.ToList();
                    List <Release>       releaseList  = db.Releases.ToList();
                    List <Functionality> functionList = db.Functionalities.ToList();
                    List <ProjectStatus> statusList   = db.ProjectStatuses.ToList();
                    List <Gate>          gateList     = db.Gates.ToList();


                    //

                    wp.groupFunction        = dayslist;
                    wp.project.impactType   = gridClassList[0].impactType;
                    wp.project.statusId     = gridClassList[0].statusId;
                    wp.gateversion.gvGateId = gridClassList[0].gvGateId;
                    wp.gateversion.gvStatus = gridClassList[0].gvStatus;
                    // wp.FuncId = gridClassList[0].FuncId;

                    wp.dbview       = gridClassList;
                    wp.appList      = appList;
                    wp.relList      = releaseList;
                    wp.roleList     = roleList;
                    wp.phaselist    = phaseList;
                    wp.functionList = functionList;
                    wp.statusList   = statusList;
                    wp.gateList     = gateList;
                }
                catch (Exception ex)
                {
                    // string msg = "";
                    if (ex.InnerException is null)
                    {
                        msg = ex.Message;
                    }
                    else
                    {
                        msg = ex.InnerException.Message;
                    }
                    return(RedirectToAction("IndexError", "Project", new { msg = msg }));
                }
            }

            return(View(wp));
        }
Exemplo n.º 22
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="propertyName">输出属性的名称</param>
 /// <param name="groupFunction"></param>
 /// <param name="orderType">排序类型</param>
 public OrderExpression(string propertyName, GroupFunction groupFunction, OrderType orderType)
 {
     Property  = new PropertyExpression(propertyName, groupFunction);
     OrderType = orderType;
 }
Exemplo n.º 23
0
 public void Add(string propertyName, GroupFunction groupFunction, ConditionOperator conditionOperator, object conditionValue)
 {
     Add(new ConditionExpression(propertyName, groupFunction, conditionOperator, conditionValue));
 }
Exemplo n.º 24
0
 static public LabelPair[] GenerateBilabels(int group)
 {
     Label[] labelArray = GroupFunction.DescendLabelsByNumber(group);
     #region 初始化,用于构造互信息参数
     IDictionary <Label, double> labelFloatDic = new Dictionary <Label, double>();
     IList <LabelPair>           labelPairList = new List <LabelPair>();//前后无序,45个,用于初始化
     Function.InitializeEmptyLabelDic(ref labelFloatDic, ref labelPairList, labelArray);
     IDictionary <Label, double> numberOfLabelTrue  = new Dictionary <Label, double>(labelFloatDic);
     IDictionary <Label, double> numberOfLabelFalse = new Dictionary <Label, double>(labelFloatDic);
     #endregion
     #region 求互信息的参数
     IList <Label> traversedLabels = new List <Label>();
     int           N = 0;
     foreach (Sentence sentence in Variable.Sentences)
     {
         foreach (Annotation annotation in sentence.AnnotaitonGroups[group].AnnotatorAnnotationDic.Values)
         {
             ++N;
             traversedLabels.Clear();
             foreach (Label label1 in labelArray)
             {
                 traversedLabels.Add(label1);
                 if (annotation.Labels[label1])
                 {
                     ++numberOfLabelTrue[label1];
                     foreach (Label label2 in labelArray)
                     {
                         if (!traversedLabels.Contains(label2))
                         {
                             LabelPair labelPair = labelPairList.First(lp => lp.First == label1 && lp.Second == label2);
                             if (annotation.Labels[label2])
                             {
                                 if (labelPair.Label1TrueLabel2TrueSentenceAndFreq.ContainsKey(sentence))
                                 {
                                     ++labelPair.Label1TrueLabel2TrueSentenceAndFreq[sentence];
                                 }
                                 else
                                 {
                                     labelPair.Label1TrueLabel2TrueSentenceAndFreq.Add(sentence, 1);
                                 }
                             }
                             else
                             {
                                 if (labelPair.Label1TrueLabel2FalseSentenceAndFreq.ContainsKey(sentence))
                                 {
                                     ++labelPair.Label1TrueLabel2FalseSentenceAndFreq[sentence];
                                 }
                                 else
                                 {
                                     labelPair.Label1TrueLabel2FalseSentenceAndFreq.Add(sentence, 1);
                                 }
                             }
                         }
                     }
                 }
                 else
                 {
                     ++numberOfLabelFalse[label1];
                     foreach (Label label2 in labelArray)
                     {
                         if (!traversedLabels.Contains(label2))
                         {
                             LabelPair labelPair = labelPairList.First(lp => lp.First == label1 && lp.Second == label2);
                             if (annotation.Labels[label2])
                             {
                                 if (labelPair.Label1FalseLabel2TrueSentenceAndFreq.ContainsKey(sentence))
                                 {
                                     ++labelPair.Label1FalseLabel2TrueSentenceAndFreq[sentence];
                                 }
                                 else
                                 {
                                     labelPair.Label1FalseLabel2TrueSentenceAndFreq.Add(sentence, 1);
                                 }
                             }
                             else
                             {
                                 if (labelPair.Label1FalseLabel2FalseSentenceAndFreq.ContainsKey(sentence))
                                 {
                                     ++labelPair.Label1FalseLabel2FalseSentenceAndFreq[sentence];
                                 }
                                 else
                                 {
                                     labelPair.Label1FalseLabel2FalseSentenceAndFreq.Add(sentence, 1);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     #endregion
     #region 情感对排序,论文用
     //List<LabelPair> sortednumberOfLabel1TrueLabel2True = new List<LabelPair>(labelPairList);//变量名为MI,其实值为joint entropy
     //sortednumberOfLabel1TrueLabel2True.Sort(delegate(LabelPair s1, LabelPair s2)
     //{
     //    return s2.Label1TrueLabel2TrueFrequency.CompareTo(s1.Label1TrueLabel2TrueFrequency);
     //});
     //List<LabelPair> sortednumberOfLabel1TrueLabel2False = new List<LabelPair>(labelPairList);//变量名为MI,其实值为joint entropy
     //sortednumberOfLabel1TrueLabel2False.Sort(delegate(LabelPair s1, LabelPair s2)
     //{
     //    return s2.Label1TrueLabel2FalseFrequency.CompareTo(s1.Label1TrueLabel2FalseFrequency);
     //});
     //List<LabelPair> sortednumberOfLabel1FalseLabel2True = new List<LabelPair>(labelPairList);//变量名为MI,其实值为joint entropy
     //sortednumberOfLabel1FalseLabel2True.Sort(delegate(LabelPair s1, LabelPair s2)
     //{
     //    return s2.Label1FalseLabel2TrueFrequency.CompareTo(s1.Label1FalseLabel2TrueFrequency);
     //});
     //List<LabelPair> sortednumberOfLabel1FalseLabel2False = new List<LabelPair>(labelPairList);//变量名为MI,其实值为joint entropy
     //sortednumberOfLabel1FalseLabel2False.Sort(delegate(LabelPair s1, LabelPair s2)
     //{
     //    return s2.Label1FalseLabel2FalseFrequency.CompareTo(s1.Label1FalseLabel2FalseFrequency);
     //});
     #endregion
     #region 求联合熵
     for (int i = 0; i < labelPairList.Count; ++i)
     {
         if (labelPairList[i].Label1TrueLabel2TrueFrequency != 0)
         {
             labelPairList[i].Weight += -(labelPairList[i].Label1TrueLabel2TrueFrequency / N) * Math.Log((labelPairList[i].Label1TrueLabel2TrueFrequency / N), 2);
         }
         if (labelPairList[i].Label1TrueLabel2FalseFrequency != 0)
         {
             labelPairList[i].Weight += -(labelPairList[i].Label1TrueLabel2FalseFrequency / N) * Math.Log((labelPairList[i].Label1TrueLabel2FalseFrequency / N), 2);
         }
         if (labelPairList[i].Label1FalseLabel2TrueFrequency != 0)
         {
             labelPairList[i].Weight += -(labelPairList[i].Label1FalseLabel2TrueFrequency / N) * Math.Log((labelPairList[i].Label1FalseLabel2TrueFrequency / N), 2);
         }
         if (labelPairList[i].Label1FalseLabel2FalseFrequency != 0)
         {
             labelPairList[i].Weight += -(labelPairList[i].Label1FalseLabel2FalseFrequency / N) * Math.Log((labelPairList[i].Label1FalseLabel2FalseFrequency / N), 2);
         }
     }
     List <LabelPair> sortedMutualInformation = new List <LabelPair>(labelPairList);//变量名为MI,其实值为joint entropy;排序仅为观察用
     sortedMutualInformation.Sort(delegate(LabelPair s1, LabelPair s2)
     {
         return(s1.Weight.CompareTo(s2.Weight));
     });
     #endregion
     return(MinimumWeightedPerfectMatching(labelPairList, true));
 }
Exemplo n.º 25
0
 /// <summary>
 /// 构造函数
 /// </summary>
 /// <param name="propertyName">输出属性的名称</param>
 /// <param name="groupFunction"></param>
 public PropertyExpression(string propertyName, GroupFunction groupFunction)
 {
     PropertyName  = propertyName;
     GroupFunction = groupFunction;
 }
Exemplo n.º 26
0
 public int UpdateRow(DbTransaction pTran, GroupFunction GroupFunction)
 {
     return(UpdateRow(pTran, GroupFunction, false));
 }