예제 #1
0
 static public void RunTDDS()
 {
     for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
     {
         Initialize(groupIndex);
         IList <double> Pdatas = new List <double>();
         for (int time = 1; time <= Variable.ConvergeTimeThreshold; ++time)
         {
             //计算Pk
             //计算Pk,mcj(consistent:角色c有j标签的概率)
             ChoiceFunction.PriorPj(ref TDDSVariable.Pj, ref TDDSVariable.Mcj, TDDSVariable.Sij, time);
             //计算π
             TDDSVariable.PAkjl = CoreFunction.CalculatePAkjl(Variable.LabelArray, TDDSVariable.Sij, time, groupIndex);
             //计算Sij
             //if (CoreFunction.CalculatePdataAndSij(Variable.LabelArray, ref TDDSVariable.Sij, TDDSVariable.Pj, TDDSVariable.Pajl, TDDSVariable.Mcj, ref TDDSVariable.Pdata, groupIndex, Pdatas,
             //    TDDSVariable.ConditionalPj, TDDSVariable.ConditionalMcj))
             //break;
         }
         DDSFunction.ObtainBinaryResult(TDDSVariable.Sij, "TDDS", groupIndex);
         DDSFunction.ObtainNumericResult(TDDSVariable.Sij, "TDDS", groupIndex);
         Function.WriteBinaryResultFile("TDDS", groupIndex);
     }
 }
예제 #2
0
        static public void RunSDDS()
        {
            if (!SupervisedFunction.IsNumberOfTraningSentencesValid())
            {
                return;
            }
            InitializeTrainingSijAndTrainingPj();
            for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex)
            {
                CalculatePij(groupIndex);
                CalculatePj();
                CalculatePAkjl(groupIndex);
                CalculateSij(groupIndex);
                DDSFunction.ObtainNumericResult(SDDSVariable.Sij, "SDDS", groupIndex);
                DDSFunction.ObtainBinaryResult(SDDSVariable.Sij, "SDDS", groupIndex);
                Function.WriteNumericResultFile("SDDS", groupIndex);
                Function.WriteBinaryResultFile("SDDS", groupIndex);//连计算再输出
            }
            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)
            {
                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].SDDSNumResult, sentence.NumericGold);
                    groupBinaryIndependentDice       += SimilarityMeasure.DicePlusANumber(sentence.AnnotaitonGroups[groupIndex].SDDSNumResult.ToBinaryResult(), sentence.NumericGold.ToBinaryResult());
                    groupBinaryIndependentCompare    += SimilarityMeasure.Compare(sentence.AnnotaitonGroups[groupIndex].SDDSNumResult.ToBinaryResult(), sentence.NumericGold.ToBinaryResult());
                    groupBinaryDependentCompare      += SimilarityMeasure.Compare(sentence.AnnotaitonGroups[groupIndex].SDDSResult, sentence.BinaryGold);
                    groupBinaryDependentDice         += SimilarityMeasure.DicePlusANumber(sentence.AnnotaitonGroups[groupIndex].SDDSResult, sentence.BinaryGold);
                    groupBinaryDependentJaccard      += SimilarityMeasure.JaccardPlusANumber(sentence.AnnotaitonGroups[groupIndex].SDDSResult, sentence.BinaryGold);
                    groupBinaryAndNumeric            += SimilarityMeasure.BinaryAndNumeric(sentence.AnnotaitonGroups[groupIndex].SDDSResult, 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;
        }