public void ComputeTest() { string data = @"../../Data/SimpleCorpus."; TLArtifactsCollection source = Artifacts.Import(data + "input.source.txt"); TLArtifactsCollection target = Artifacts.Import(data + "input.target.txt"); TLSimilarityMatrix testsims = VSM.Compute(source, target); TLSimilarityMatrix realsims = Similarities.Import(data + "output.VSM.txt"); Assert.AreEqual(testsims.Count, realsims.Count); TLLinksList testlinks = testsims.AllLinks; TLLinksList reallinks = realsims.AllLinks; testlinks.Sort(); reallinks.Sort(); for (int i = 0; i < reallinks.Count; i++) { Assert.AreEqual(testlinks[i].SourceArtifactId, reallinks[i].SourceArtifactId); Assert.AreEqual(testlinks[i].TargetArtifactId, reallinks[i].TargetArtifactId); Assert.AreEqual(testlinks[i].Score, reallinks[i].Score, 0.000000001); } }
public void ConstructorTest_Artifacts() { string data = @"../../Data/SimpleCorpus."; TermDocumentMatrix matrix = new TermDocumentMatrix(Artifacts.Import(data + "input.target.txt")); TermDocumentMatrix answer = TermDocumentMatrix.Load(data + "output.target.matrix.txt"); // counts Assert.AreEqual(matrix.NumDocs, answer.NumDocs); Assert.AreEqual(matrix.NumTerms, answer.NumTerms); // matrix for (int i = 0; i < answer.NumDocs; i++) { Assert.AreEqual(matrix.GetDocumentName(i), answer.GetDocumentName(i)); Assert.AreEqual(matrix.GetDocument(i).Length, answer.NumTerms); for (int j = 0; j < answer.NumTerms; j++) { Assert.AreEqual(matrix.GetTermName(j), answer.GetTermName(j)); Assert.AreEqual(matrix[i, j], answer[i, j], 0.0); } } }
public override void Compute() { Workspace.Store("Artifacts", Artifacts.Import(_config.Artifacts.Absolute)); }