public void IndexOf() { //Arrange SortedSet <string> words = new SortedSet <string>(); words.Add("a"); words.Add("b"); words.Add("c"); //Act WordCooccurrenceMatrix matrix = new WordCooccurrenceMatrix(words); //Assert Assert.AreEqual(0, matrix.IndexOf("a")); Assert.AreEqual(1, matrix.IndexOf("b")); Assert.AreEqual(2, matrix.IndexOf("c")); }
public void CompileOccurrences() { //Arrange KeywordExtractor extractor = new KeywordExtractor(); string[] tokens = extractor.Tokenize(this.Sample1); string[] phrases = extractor.ToPhrases(tokens); WordCooccurrenceMatrix matrix = new WordCooccurrenceMatrix(extractor.UniqueWordIndex); //Act matrix.CompileOccurrences(phrases); //Assert Assert.AreEqual(2, matrix[matrix.IndexOf("algorithms"), matrix.IndexOf("algorithms")], "'algorithms' diagonal count"); Assert.AreEqual(1, matrix[matrix.IndexOf("bounds"), matrix.IndexOf("bounds")], "'bounds' diagonal count"); Assert.AreEqual(1, matrix[matrix.IndexOf("corresponding"), matrix.IndexOf("algorithms")], "'corresponding'->'algorithms' count"); Assert.AreEqual(2, matrix[matrix.IndexOf("minimal"), matrix.IndexOf("set")], "'minimal'->'set' count"); Assert.AreEqual(2, matrix[matrix.IndexOf("set"), matrix.IndexOf("minimal")], "'set'->'minimal' count"); }