/// <summary> /// Saves corpus to cache. /// Overwrites existing files with the same name. /// </summary> /// <returns>Corpus base path + name</returns> public LDACorpusInfo Save() { LDACorpusInfo info = new LDACorpusInfo(); info.Name = Name; // write matrix FileStream cFS = RUtil.CreateCacheFile(Name + ".corpus"); info.Corpus = cFS.Name; TextWriter corpus = new StreamWriter(cFS); corpus.Write(Matrix); corpus.Flush(); corpus.Close(); // write vocab FileStream vFS = RUtil.CreateCacheFile(Name + ".vocab"); info.Vocab = vFS.Name; TextWriter vocab = new StreamWriter(vFS); vocab.Write(Vocab); vocab.Flush(); vocab.Close(); // write edges FileStream eFS = RUtil.CreateCacheFile(Name + ".tableWriter"); info.Edges = eFS.Name; TextWriter edges = new StreamWriter(eFS); edges.Write(Edges); edges.Flush(); edges.Close(); // write links FileStream lFS = RUtil.CreateCacheFile(Name + ".links"); info.Links = lFS.Name; TextWriter links = new StreamWriter(lFS); links.Write(Links); links.Flush(); links.Close(); // return info return(info); }
/// <summary> /// Precompute method /// </summary> public override void PreCompute() { RUtil.RegisterScript(Assembly.GetExecutingAssembly(), _baseScript); LDACorpus corpus = new LDACorpus("LDA", _source, _target); LDACorpusInfo info = corpus.Save(); _outputFile = RUtil.ReserveCacheFile("LDA.out"); _arguments = new List <object>(); _arguments.Add(info.Corpus); _arguments.Add(info.Vocab); _arguments.Add(info.Edges); _arguments.Add(_outputFile); _arguments.Add(_config.NumTopics); _arguments.Add(_config.NumIterations); _arguments.Add(_config.Alpha); _arguments.Add(_config.Eta); _arguments.Add(_config.PredictionBeta); _arguments.Add(_config.Seed); }
/// <summary> /// Precompute method /// </summary> public override void PreCompute() { RUtil.RegisterScript(Assembly.GetExecutingAssembly(), _baseScript); _info = _corpus.Save(); _outputFile = RUtil.ReserveCacheFile("RTM.out"); _arguments = new List <object>(); _arguments.Add(_info.Corpus); _arguments.Add(_info.Vocab); _arguments.Add(_info.Edges); _arguments.Add(_info.Links); _arguments.Add(_outputFile); _arguments.Add(_config.NumTopics); _arguments.Add(_config.NumIterations); _arguments.Add(_config.Alpha); _arguments.Add(_config.Eta); _arguments.Add(_config.RTMBeta); _arguments.Add(_config.PredictionBeta); _arguments.Add(_config.Seed); }
/// <summary> /// Precompute method /// </summary> public override void PreCompute() { RUtil.RegisterScript(Assembly.GetExecutingAssembly(), _baseScript); _info = _corpus.Save(); _outputFile = RUtil.ReserveCacheFile("RTM.out"); _arguments = new List<object>(); _arguments.Add(_info.Corpus); _arguments.Add(_info.Vocab); _arguments.Add(_info.Edges); _arguments.Add(_info.Links); _arguments.Add(_outputFile); _arguments.Add(_config.NumTopics); _arguments.Add(_config.NumIterations); _arguments.Add(_config.Alpha); _arguments.Add(_config.Eta); _arguments.Add(_config.RTMBeta); _arguments.Add(_config.PredictionBeta); _arguments.Add(_config.Seed); }
/// <summary> /// Saves corpus to cache. /// Overwrites existing files with the same name. /// </summary> /// <returns>Corpus base path + name</returns> public LDACorpusInfo Save() { LDACorpusInfo info = new LDACorpusInfo(); info.Name = Name; // write matrix FileStream cFS = RUtil.CreateCacheFile(Name + ".corpus"); info.Corpus = cFS.Name; TextWriter corpus = new StreamWriter(cFS); corpus.Write(Matrix); corpus.Flush(); corpus.Close(); // write vocab FileStream vFS = RUtil.CreateCacheFile(Name + ".vocab"); info.Vocab = vFS.Name; TextWriter vocab = new StreamWriter(vFS); vocab.Write(Vocab); vocab.Flush(); vocab.Close(); // write edges FileStream eFS = RUtil.CreateCacheFile(Name + ".tableWriter"); info.Edges = eFS.Name; TextWriter edges = new StreamWriter(eFS); edges.Write(Edges); edges.Flush(); edges.Close(); // write links FileStream lFS = RUtil.CreateCacheFile(Name + ".links"); info.Links = lFS.Name; TextWriter links = new StreamWriter(lFS); links.Write(Links); links.Flush(); links.Close(); // return info return info; }