TraceLab Component Library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
VSM.cs
Go to the documentation of this file.
1 // TraceLab Component Library
2 // Copyright © 2012-2013 SEMERU
3 //
4 // This program is free software: you can redistribute it and/or modify
5 // it under the terms of the GNU General Public License as published by
6 // the Free Software Foundation, either version 3 of the License, or
7 // (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful,
10 // but WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 // GNU General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program. If not, see <http://www.gnu.org/licenses/>.
16 
17 using TraceLab.Components.DevelopmentKit.Utils.TermDocumentMatrixUtils;
18 using TraceLabSDK.Types;
19 using System;
20 
21 namespace TraceLab.Components.DevelopmentKit.Tracers.InformationRetrieval
22 {
26  public static class VSM
27  {
35  public static TLSimilarityMatrix Compute(TLArtifactsCollection source, TLArtifactsCollection target, VSMWeightEnum weight)
36  {
37  switch (weight)
38  {
39  case VSMWeightEnum.TFIDF:
40  return SimilarityUtil.ComputeCosine(WeightUtil.ComputeTFIDF(new TermDocumentMatrix(source, target)), source.Keys, target.Keys);
41  case VSMWeightEnum.BooleanQueriesAndTFIDFCorpus:
43  case VSMWeightEnum.NoWeight:
44  return SimilarityUtil.ComputeCosine(new TermDocumentMatrix(source, target), source.Keys, target.Keys);
45  default:
46  throw new NotImplementedException("Unknown weighting scheme \"" + weight + "\"");
47  }
48  }
49  }
50 
54  public enum VSMWeightEnum
55  {
59  TFIDF,
60 
65 
69  NoWeight,
70  }
71 }