Example #1
0
        public training(int lang_id, int category_id, string langauge, string stemming, bool addtur, int n, bool punctuation, int nov)
        {
            _cr = new classifier(langauge, stemming, addtur, n, punctuation, nov);//classifier hazır
            _category_sentence_count = new Dictionary <int, int>();
            all_sentence_count       = 0;

            word_dic _wd = new word_dic();
            comment  _c  = new comment();

            DataTable _dt = _c.select_comment(lang_id.ToString(), category_id.ToString());

            int id      = 1;
            int yuzde50 = _dt.Rows.Count / 2;

            foreach (DataRow row in _dt.Rows) // Loop over the rows.
            {
                var    type      = row[0];
                string _sentence = row[1].ToString().ToLower();
                int    _type     = Convert.ToInt32(type);

                _cr.AddSentenceforTraining(_sentence, _type);
                AddASentence(_type);//kategorideki cümle sayısı
                all_sentence_count++;
                id++;
                if (id == yuzde50)
                {
                    break;
                }
            }
        }
Example #2
0
        public arff_converter2(int lang_id, int category_id, string langauge, string stemming, bool addtur, int n, bool punctuation, int nov)
        {
            word_dic  _wd = new word_dic();
            comment   _c  = new comment();
            DataTable _dt = _c.select_comment(lang_id.ToString(), category_id.ToString());

            int olumsuz = 0;
            int olumlu  = 0;
            int notr    = 0;
            int soru    = 0;

            int id = 1;

            foreach (DataRow row in _dt.Rows) // Loop over the rows.
            {
                var    type      = row[0];
                string _sentence = row[1].ToString().ToLower();
                int    _type     = Convert.ToInt32(type);

                if (_type == -1)
                {
                    olumsuz++;
                    if (olumsuz < 3300000)
                    {
                        _wd.update_hashtables(_sentence, _type, langauge, stemming, addtur, n, punctuation, nov);
                    }
                }
                if (_type == 0)
                {
                    notr++;
                    if (notr < 1700000)
                    {
                        _wd.update_hashtables(_sentence, _type, langauge, stemming, addtur, n, punctuation, nov);
                    }
                }
                if (_type == 1)
                {
                    olumlu++;
                    if (olumlu < 550000000)
                    {
                        _wd.update_hashtables(_sentence, _type, langauge, stemming, addtur, n, punctuation, nov);
                    }
                }
                if (_type == 2)
                {
                    soru++;
                    if (soru < 100000)
                    {
                        _wd.update_hashtables(_sentence, _type, langauge, stemming, addtur, n, punctuation, nov);
                    }
                }

                id++;
            }

            _sentence_data = _wd._sentence_data;
        }
Example #3
0
        public int[,] ConfusionMatrix(int lang_id, int category_id)
        {
            int[,] _cm = new int[_cat_dic.Count, _cat_dic.Count];
            for (int x = 0; x < _cat_dic.Count; x++)
            {
                for (int y = 0; y < _cat_dic.Count; y++)
                {
                    _cm[x, y] = 0;
                }
            }

            Hashtable _categoriler = new Hashtable();
            int       i            = 0;

            foreach (var _cat in _cat_dic)
            {
                _categoriler.Add((int)_cat.Key, i);
                i++;
            }

            word_dic  _wd = new word_dic();
            comment   _c  = new comment();
            DataTable _dt = _c.select_comment(lang_id.ToString(), category_id.ToString());

            int id = 1;

            foreach (DataRow row in _dt.Rows) // Loop over the rows.
            {
                var    type      = row[0];
                string _sentence = row[1].ToString().ToLower();
                int    _type     = Convert.ToInt32(type);
                int    x         = (int)_categoriler[_type];
                int    y         = (int)_categoriler[Estimate_Category(_sentence)];
                _cm[x, y]++;
                id++;
            }

            return(_cm);
        }
Example #4
0
        public Hashtable _words_in_sentence;//bir cümle içindeki kelimeler için

        public arff_converter(int lang_id, int category_id, string langauge, string stemming, bool addtur, int n, bool punctuation, int nov)
        {
            word_dic _wd = new word_dic();
            comment  _c  = new comment();

            DataTable _dt = _c.select_comment(lang_id.ToString(), category_id.ToString());
            int       id  = 1;

            foreach (DataRow row in _dt.Rows) // Loop over the rows.
            {
                var    type      = row[0];
                string _sentence = row[1].ToString().ToLower();
                int    _type     = Convert.ToInt32(type);

                _wd.update_hashtables(_sentence, _type, langauge, stemming, addtur, n, punctuation, nov);
                id++;
            }

            _word_dic      = _wd._word_dic;
            _sentence_word = _wd._sentence_word;
            _sentence_type = _wd._sentence_type;
        }