Exemple #1
0
 internal static void CompareResults(TLSimilarityMatrix oracle, TLSimilarityMatrix results, IEnumerable <string> rawMethods)
 {
     Console.WriteLine("Comparing results...");
     Assert.AreEqual(oracle.Count, results.Count);
     foreach (string oracleMethod in oracle.GetSetOfTargetArtifactIdsAboveThresholdForSourceArtifact("trace"))
     {
         string rawMethod = rawMethods.ElementAt(Convert.ToInt32(oracleMethod) - 1);
         string method    = rawMethod.Substring(0, rawMethod.IndexOf('('));
         //Console.WriteLine(oracleMethod + ": " + method);
         Assert.IsTrue(results.IsLinkAboveThreshold("trace", method));
         Assert.AreEqual(oracle.GetScoreForLink("trace", oracleMethod), results.GetScoreForLink("trace", method), Settings.Default.DoublePrecision);
     }
 }
Exemple #2
0
        /// <summary>
        /// Performs an affine transformation on two similarity matrices.
        /// </summary>
        /// <param name="large">Large expert</param>
        /// <param name="small">Small expert</param>
        /// <param name="lambda">Weight given to large expert</param>
        /// <returns>Transformed similarities</returns>
        public static TLSimilarityMatrix Transform(TLSimilarityMatrix large, TLSimilarityMatrix small, double lambda)
        {
            TLSimilarityMatrix largeNormal = Normalize(large);
            TLSimilarityMatrix smallNormal = Normalize(small);
            TLSimilarityMatrix combined    = new TLSimilarityMatrix();

            foreach (TLSingleLink largeLink in largeNormal.AllLinks)
            {
                double smallLink = smallNormal.GetScoreForLink(largeLink.SourceArtifactId, largeLink.TargetArtifactId);
                combined.AddLink(largeLink.SourceArtifactId, largeLink.TargetArtifactId, Combine(largeLink.Score, smallLink, lambda));
            }

            return(combined);
        }
Exemple #3
0
        public void ComputeLSA()
        {
            TLArtifactsCollection source = TermDocumentMatrix.Load(@"../../Data/LSA/source.txt").ToTLArtifactsCollection();
            TLArtifactsCollection target = TermDocumentMatrix.Load(@"../../Data/LSA/target.txt").ToTLArtifactsCollection();
            REngine            engine    = new REngine(Settings.Default.RScriptEXE);
            TLSimilarityMatrix matrix    = (TLSimilarityMatrix)engine.Execute(new LSAScript(source, target, new LSAConfig {
                Dimensions = 3
            }));
            TLSimilarityMatrix correct = Similarities.Import(@"../../Data/LSA/correct.txt");

            foreach (TLSingleLink link in matrix.AllLinks)
            {
                Assert.AreEqual(correct.GetScoreForLink(link.SourceArtifactId, link.TargetArtifactId),
                                link.Score,
                                Settings.Default.DoublePrecision
                                );
            }
        }