Exemple #1
0
        public void StoreLDADocToDB(LDABoWModel doc)
        {
            if(ldaColl == null)
                ldaColl = db.GetCollection<BsonDocument>(LDACollectionName);

            if (ldaColl.Name != LDACollectionName)
                ldaColl = db.GetCollection<BsonDocument>(LDACollectionName);

            LDAModel ldaModel = doc.GetLDAModel();
            ldaColl.Insert(ldaModel.StoreToDB());
        }
Exemple #2
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 #3
0
 public override DocModel LoadFromDB(BsonDocument bsonDoc)
 {
     LDABoWModel docModel = new LDABoWModel(this);
     return docModel.LoadFromDB(bsonDoc, wordDict);
 }