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; }
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; }
static public void RunSIDS() { if (!SupervisedFunction.IsNumberOfTraningSentencesValid()) { return; } for (int g = 0; g < GroupVariable.AnnotatorGroups.Length; ++g) { foreach (Sentence sentence in Variable.Sentences) { if (sentence.ID < SupervisedVariable.NumberOfTraningSentences) { continue; } sentence.AnnotaitonGroups[g].SIDSNumResult = new NumericResult(); } } foreach (Label label in Variable.LabelArray) { InitializeTrainingSijAndPj(label); for (int groupIndex = 0; groupIndex < GroupVariable.AnnotatorGroups.Length; ++groupIndex) { //Function.ConsoleWriteLine("SIDS, " + g); CalculatePij(label, groupIndex); CalculatePj(label); CalculatePajl(label, groupIndex); CalculateSij(label, groupIndex); ObtainLabelResult(label, 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) { Function.WriteNumericResultFile("SIDS", groupIndex); Function.WriteBinaryResultFile("SIDS", 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].SIDSNumResult, sentence.NumericGold); groupBinaryIndependentDice += SimilarityMeasure.DicePlusANumber(sentence.AnnotaitonGroups[groupIndex].SIDSNumResult.ToBinaryResult(), sentence.NumericGold.ToBinaryResult()); groupBinaryIndependentCompare += SimilarityMeasure.Compare(sentence.AnnotaitonGroups[groupIndex].SIDSNumResult.ToBinaryResult(), sentence.NumericGold.ToBinaryResult()); groupBinaryDependentCompare += SimilarityMeasure.Compare(sentence.AnnotaitonGroups[groupIndex].SIDSResult, sentence.BinaryGold); groupBinaryDependentDice += SimilarityMeasure.DicePlusANumber(sentence.AnnotaitonGroups[groupIndex].SIDSResult, sentence.BinaryGold); groupBinaryDependentJaccard += SimilarityMeasure.JaccardPlusANumber(sentence.AnnotaitonGroups[groupIndex].SIDSResult, sentence.BinaryGold); groupBinaryAndNumeric += SimilarityMeasure.BinaryAndNumeric(sentence.AnnotaitonGroups[groupIndex].SIDSResult, 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; }