Exemplo n.º 1
0
        public static void CreateLocation()
        {
            List <string> lokasi = new List <string>();

            lokasi.Add(getEnvirontment());
            lokasi.Add(getKnowledgeBase());
            lokasi.Add(getDataBaru());
            lokasi.Add(getDataCache());
            lokasi.Add(getDataCacheKata());
            dbDataContext db = new dbDataContext();

            foreach (var item in db.tbDomains.ToList())
            {
                if (item.Id > 0)
                {
                    lokasi.Add(getDataCache() + item.Name + "/");
                    //System.Windows.Forms.MessageBox.Show(item.Name);
                }
            }

            FileInfo file;

            foreach (string loc in lokasi)
            {
                file = new FileInfo(loc);
                file.Directory.Create(); // If the directory already exists, this method does nothing.
            }
        }
Exemplo n.º 2
0
        private void manageDataToolStripMenuItem_Click(object sender, EventArgs e)
        {
            ManageDBForm managedb = new ManageDBForm(this.Text, db);

            this.Visible = false;
            if (managedb.ShowDialog() == DialogResult.OK)
            {
                for (int i = 0; i < managedb.LokasibaruData.Count; i++)
                {
                    foreach (var item in managedb.DataBaru)
                    {
                        if (!File.Exists(managedb.LokasibaruData[i]))
                        {
                            File.Copy(managedb.LokasilamaData[i], managedb.LokasibaruData[i]);
                        }
                        if (db.tbInformasis.Where(x => x.Judul.ToString() == item.Judul).FirstOrDefault() == null)
                        {
                            db.tbInformasis.InsertOnSubmit(item);
                        }
                    }
//                    db.tbInformasis.InsertAllOnSubmit(managedb.DataBaru.ToList());
                    db.SubmitChanges();
                }
            }
            else
            {
                db = new dbDataContext();
            }
            this.Visible = true;
        }
        public void HitungPembobotanKata()
        {
            List <Term> InvertedIndex = Lingkungan.LoadInvertedIndex();

            if (InvertedIndex == null)
            {
                InvertedIndex = new List <Term>();
            }
            if (db == null)
            {
                db = new dbDataContext();
            }
            List <tbDomain> Domain      = db.tbDomains.ToList(); // seluruh domain yang ada
            List <int>      DomainCount = new List <int>();      // Counter setiap domain

            for (int i = 0; i < Domain.Count; i++)               // inisialisasi counter domain
            {
                DomainCount.Add(0);
            }

            // Hitung jumlah kata dalam seluruh dokumen dan perdomain
            int TermCount = 0; //counter kata

            foreach (var item in InvertedIndex)
            {
                TermCount += item.Index.Count;
                for (int i = 0; i < Domain.Count; i++)
                {
                    DomainCount[i] += item.Index.Where(x => x.DomainID == Domain[i].Id).Count();
                }
            }

            for (int i = 1; i < DomainCount.Count; i++)
            {
                if (DomainCount[i] == 0)
                {
                    for (int j = 1; j < DomainCount.Count; j++)
                    {
                        DomainCount[i]++;
                    }
                    break;
                }
            }
            //pembobotan
            foreach (var item in InvertedIndex)
            {
                item.Bobot.Clear();
                for (int i = 0; i < Domain.Count; i++)
                {
                    int    count = item.Index.Where(x => x.DomainID == Domain[i].Id).Count();
                    double bobot = Math.Log10((Lingkungan.getLambda(0) * (count / TermCount)) +
                                              (Lingkungan.getLambda(1) * count / DomainCount[i]));
                    item.Bobot.Add(bobot);
                }
            }
            Lingkungan.SaveInvertedIndex(InvertedIndex);
        }
 public DialogueManager(dbDataContext database, tbUser bot)
 {
     Conversation  = new Stack <Dialogue>();
     db            = database;
     Bot           = bot;
     ListOfState   = db.tbStates.ToList();
     StateMovement = db.tbStatePrgs.ToList();
     bool selesai  = false;
     bool initiate = true;
 }
 public EngineMixtureLanguageModel(dbDataContext database)
 {
     if (database != null)
     {
         db = database;
     }
     else
     {
         db = new dbDataContext();
     }
 }
Exemplo n.º 6
0
 dbDataContext db;   // koneksi ke db dibuat
 public LoginForm(dbDataContext database)
 {
     /* Ctor Login Form
      * menginisialisasi seluruh komponen, menghilgkan label warning dan
      * Diable SignUp serta membuat koneksi ke db
      */
     InitializeComponent();
     db   = database;
     user = null;
     SignUpPanel.Enabled  = false;
     labelWarning.Visible = false;
     this.AcceptButton    = buttonLogin;
 }
Exemplo n.º 7
0
        public ChatbotForm()
        {
            //Inisialisasi Program
            InitializeComponent();
            Lingkungan.CreateLocation();
            db     = new dbDataContext();
            Engine = new EngineActuator("MLM", db);
            bot    = db.tbUsers.Where(x => x.Id == 0).FirstOrDefault();
            DM     = new DialogueManager(db, bot);

            //bot define
            bool testing = true;

            //Login
            if (!testing) //temporary code
            {
                currentUser = db.tbUsers.Where(x => x.Id == 1).FirstOrDefault();
                this.Text   = bot.Name + " Chatbot";
            }
            else
            {
                #region True Initiation
                this.Text = bot.Name + " Chatbot";
                try
                {
                    LoginlogoutToolStripMenuItem.PerformClick();
                    if (Login == DialogResult.Cancel)
                    {
                        throw new Exception();
                    }
                }
                catch (Exception)
                {
                    if (System.Windows.Forms.Application.MessageLoop)
                    {
                        System.Windows.Forms.Application.Exit(); // WinForms app
                    }
                    else
                    {
                        System.Environment.Exit(1); // Console app
                    }
                    this.Close();
                    this.Dispose();
                }
                #endregion
            }
//            DM.ManageDialogue(bot, "Welcome " + currentUser.Name + " to " + bot.Name + " Chatbot.",null);
            refreshListBoxChat();
            this.AcceptButton = this.buttonSend;
        }
Exemplo n.º 8
0
        public ManageDBForm(string args, dbDataContext database)
        {
            InitializeComponent();
            buttonDelete.Enabled = false;
            this.Text            = args;

            //Inisialisasi Variable
            LokasibaruData = new List <string>();
            LokasilamaData = new List <string>();
            DataBaru       = new List <tbInformasi>();
            db             = database;
            DataDomain     = db.tbDomains.ToList();

            //Inisialisasi Grid
            comboBoxDomain.DataSource    = DataDomain.Select(x => x.Name).ToList();
            comboBoxDomain.SelectedIndex = 1;
        }
Exemplo n.º 9
0
//        List<tbInformasi> tobeIndexed;
        public EngineActuator(string args, dbDataContext database)
        {
            db    = database;
            model = new EngineMixtureLanguageModel(db);
        }