Exemple #1
0
        static void InitAP()
        {
            wordDict = new WordDictionary();
            docModelDB = new LDABoWModelDB(10, wordDict);

            string line;
            StreamReader reader = new StreamReader(new FileStream("ap.dat", FileMode.Open));
            while ((line = reader.ReadLine()) != null)
            {
                string[] ss = line.Split(' ');
                LDABoWModel doc = new LDABoWModel(docModelDB);
                for (int i = 1; i < ss.Length; i++)
                {
                    string[] sss = ss[i].Split(':');
                    doc.AddWord(int.Parse(sss[0]), int.Parse(sss[1]));
                    wordDict.AddValue(sss[0], int.Parse(sss[0]));
                }
                doc.InitIndex();
                docModelDB.AddDocModel(doc);
            }
            reader.Close();
            docModelDB.Init();
        }
Exemple #2
0
 static void Stats()
 {
     InitDict();
     docModelDB = new LDABoWModelDB(1, wordDict);
     docModelDB.LoadFromDB();
     // print class labels
     docModelDB.Stats(classLabelDict);
 }
Exemple #3
0
 static void LDAEstimateDataSet(string dataSetName, int numOfTopics)
 {
     InitTFIDFDict();
     docModelDB = new LDABoWModelDB(numOfTopics, tfidfDict);
     docModelDB.LDACollectionName = "ldadocs_" + numOfTopics;
     docModelDB.LoadFromDBByDataSet(dataSetName);
     docModelDB.Init();
     docModelDB.RunEM(true);
     docModelDB.SaveLDAModel();
     docModelDB = null;
 }
Exemple #4
0
 static void LDAInferenceDataSet(string dataSetName, int numOfTopics)
 {
     InitTFIDFDict();
     docModelDB = new LDABoWModelDB(numOfTopics, tfidfDict);
     docModelDB.LDACollectionName = "ldadocs_" + numOfTopics+ "_all";
     docModelDB.LoadFromDBByDataSet(dataSetName);
     docModelDB.Init();
     docModelDB.LoadLDAModel();
     docModelDB.E_Step(true);
     docModelDB = null;
 }
Exemple #5
0
 public LDABoWModel(LDABoWModelDB db)
 {
     modelDB = db;
     Init();
 }