Exemple #1
0
void run_lda()
{
	cout << "Start LDA Module..." << endl;
	ReadDocument();
	cout<<"Reading Document Done."<<endl;
	
	env_inst.AllocHeap();
	cout<<env_inst<<endl;
	
	BuildLdaGraph("./graph/graph_lda/graph_lda");
        cout << "Generating Graph Data Done. " << endl;
    	
	graph_type lda_graph;
	lda_graph.load_format("./graph/graph_lda/graph_lda");
	cout <<"Loading Graph Done."<<endl;
	
	
	cout<<"LDA Start..."<<endl;	
	saedb::IEngine<lda_init> *engine_init = new saedb::EngineDelegate<lda_init>(lda_graph);	
	engine_init->signalAll();
	engine_init->start();
	delete engine_init;
	cout<<"Init done"<<endl;
	
	
	for(int i=0;i<env_inst.NROUNDS;i++)
	{
		cout<<"ROUNDS "<<i+1<<" is running!"<<endl;
		saedb::IEngine<lda_gibbs> *engine_gibbs = new saedb::EngineDelegate<lda_gibbs>(lda_graph);
		engine_gibbs->signalAll();			
		engine_gibbs->start();
		delete engine_gibbs;
		if ((i > env_inst.BURN_IN) && (env_inst.SAMPLE_LAG > 0) && (i % env_inst.SAMPLE_LAG == 0)) {
			saedb::IEngine<lda_update> *engine_update = new saedb::EngineDelegate<lda_update>(lda_graph);
			engine_update->signalAll();			
			engine_update->start();
			delete engine_update;
			env_inst.numstats++;
        	}
	}
	
	GetDistribution();
	cout<<"LDA Finished."<<endl;

	OutputLda();
	cout<<"Output Distribution Done."<<endl;
	
	//release resources
	for (auto i = 0; i < lda_graph.num_local_vertices(); i ++) {
	    	vertex_data v= lda_graph.vertex(i).parse<vertex_data>();
            	v.ReleaseHeap();
	}
	env_inst.ReleaseHeap();
        cout << "End LDA Module." << endl;
}
void DocumentList::RunFerret (int first_document)
{
  ResetReading ();
	// phase 1 -- read each file in turn, finding trigrams
	for (int i = first_document; i < _documents.size (); ++i)
	{
		ReadDocument (i);
	}

	// phase 2 -- compute the similarities
	ComputeSimilarities ();
}
Exemple #3
0
BOOL DocRoot::OpenDocument(const char* pszPathName)
  {
  if (gs_Exec.Busy())
    {
    LogError("SysCAD", 0, "Must not be running");
    return False;
    }

  SetModifiedFlag(FALSE);
  gs_pPrj->bDocChanged=0;
  
  char Fn[512];
  if (strpbrk(pszPathName, ":\\")==NULL)
    {
    strcpy(Fn, PrjFiles());
    strcat(Fn, pszPathName);
    }
  else
    strcpy(Fn, pszPathName);
  CString Ext;
  VERIFY(GetDocTemplate()->GetDocString(Ext, CDocTemplate::filterExt));
  //GetDocTemplate()->GetDocString(Ext, CDocTemplate::filterExt);
  pchar ext=Ext.GetBuffer(0);
  const int l=strlen(Fn);
  const int el=strlen(ext);
  if (l<=el || (_stricmp(&Fn[l-el], ext)!=0 && Fn[l-el]!='.'))
    strcat(Fn, ext);

  FILE* pFile= fopen(Fn, "rt");
  flag b=(pFile!=NULL);
   
  if (b && !feof(pFile))
    b=ReadDocument(Fn, pFile);

  if (pFile) 
    fclose(pFile);
  if (b)
    {
    SetPathName(Fn);
    //LogNote("Document", 0, "Loaded : %s", Fn); Who really wants to know?
    }
  else
    {
    LogError("Document", 0, "NOT Loaded : %s", Fn);
    }
  return b;
  }