TraceLab Component Library
 All Classes Namespaces Files Functions Variables Enumerations Enumerator Properties
GibbsLDA-GAComponent.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 RPlugin.Core;
18 using System;
19 using System.Collections.Generic;
20 using System.Linq;
21 using System.Text;
22 using TraceLab.Components.DevelopmentKit.Tracers.InformationRetrieval;
23 using TraceLab.Components.Types.Tracers.InformationRetrieval;
24 using TraceLabSDK;
25 using TraceLabSDK.Types;
26 
27 namespace TraceLab.Components.Library.Tracers.InformationRetrieval
28 {
29  [Component(Name = "Gibbs LDA - Genetic Algorithm",
30  Description = "Computes an 'ideal' Gibbs LDA configuration using a genetic algorithm. Uses package 'topicmodels'",
31  Author = "SEMERU; Evan Moritz",
32  Version = "1.0.0.0",
33  ConfigurationType = typeof(GibbsLDA_GAConfig))]
34  [IOSpec(IOSpecType.Input, "SourceArtifacts", typeof(TLArtifactsCollection))]
35  [IOSpec(IOSpecType.Input, "TargetArtifacts", typeof(TLArtifactsCollection))]
36  [IOSpec(IOSpecType.Output, "GibbsLDAConfig", typeof(GibbsLDAConfig))]
37  [Tag("RPlugin.Tracers.InformationRetrieval")]
38  [Tag("Tracers.InformationRetrieval")]
39  public class GibbsLDA_GAComponent : BaseComponent
40  {
41  private GibbsLDA_GAConfig _config;
42 
43  public GibbsLDA_GAComponent(ComponentLogger log)
44  : base(log)
45  {
46  _config = new GibbsLDA_GAConfig();
47  Configuration = _config;
48  }
49 
50  public override void Compute()
51  {
52  TLArtifactsCollection source = (TLArtifactsCollection)Workspace.Load("SourceArtifacts");
53  TLArtifactsCollection target = (TLArtifactsCollection)Workspace.Load("TargetArtifacts");
54  REngine engine = new REngine(_config.RScriptPath);
55  GibbsLDAConfig config = (GibbsLDAConfig)engine.Execute(new GibbsLDA_GAScript(source, target, _config));
56  Workspace.Store("GibbsLDAConfig", config);
57  }
58  }
59 }