Exemplo n.º 1
0
        public int LoadBaiViet()
        {
            List<BAIVIET_getall_newResult> lt = new List<BAIVIET_getall_newResult>();
            BUSBaiViet BUSBaiViet = new BUSBaiViet();
            lt = BUSBaiViet.SelectBAIVIETsAll_new();

            LOAIBAIVIET ltLoaiBaiViet = new LOAIBAIVIET();
            BUSLoaiBaiViet BUSLoaiBaiViet = new BUSLoaiBaiViet();
            if (lt.Count > 0)
            {
                lt.Sort(SortByDate);
                this.GridViewBaiViet.DataSource = lt;
                GridViewBaiViet.DataBind();
                PanelDanhSach.Visible = true;
                PanelMessage.Visible = false;

                //                 for (int i = 0; i < lt.Count; i++)
                //                 {
                //                     GridViewBaiViet.Rows[i].Cells[4].Text = BUSLoaiBaiViet.TimKiem((int)lt[i].MaLoaiBaiViet).TenLoaiBaiViet;
                //                 }
                return lt.Count;
            }
            else
            {
                PanelDanhSach.Visible = false;
                PanelMessage.Visible = true;
                return 0;
            }
        }
Exemplo n.º 2
0
        private void bt_clustering_Click(object sender, EventArgs e)
        {
            List<string> initialContent = ReadData("C:\\Users\\LENOVO\\Desktop\\回复提取3.0.txt");
            List<string> content = new List<string>();
            for (int i = 0; i < initialContent.Count; i++)
            {
                List<string> matchs=GetMatchs(@"(?<=\b.+?\b\s\b\w{4}\d\b\s).*", initialContent[i]);
                if (matchs.Count != 0)
                    content.Add(matchs[0]);

            }
            List<string> segmentWords = GetSegmentWords(content);
            string[] stopWords = File.ReadAllLines(@"中文停用词表(专用).txt", System.Text.Encoding.Default);
            List<theWord> theWords = new List<theWord>();
            foreach (string s in segmentWords.Distinct().ToList())
            {
                int i = 0;
                foreach (string word in stopWords)
                {
                    if (word == s)
                    {
                        i = 1;
                        break;
                    }
                }
                if (!Regex.IsMatch(s, @"[\u4e00-\u9fbb]+$"))//去除非汉字
                    i = 1;
                if (i == 1)
                    continue;
                int times = 0;
                foreach (string word in segmentWords)
                {
                    if (s == word)
                        times++;
                }
                theWord theword;
                theword.text = s;
                theword.times = times;
                theWords.Add(theword);
            }
            theWords.Sort((left, right) =>
            {
                if (left.times > right.times)
                    return -1;
                else if (left.times == right.times)
                    return 0;
                else
                    return 1;
            });
            for (int i = 0; i < theWords.Count; i++)
            {
                tb_content.Text += theWords[i].text + "(" + theWords[i].times + ")" + "\r\n";
            }

            StreamWriter sw = new StreamWriter("C:\\Users\\LENOVO\\Desktop\\流行词排行3.0.txt");
            sw.Write(tb_content.Text);
            sw.Close();
        }