Ejemplo n.º 1
0
        private void ConcertToData(List <Concert> list)
        {
            List <BasicAttr> listbasic = new List <BasicAttr>();

            foreach (var item in list)
            {
                BasicAttr basic = new BasicAttr();
                basic.AttrName     = item.AttrName;
                basic.End_Time     = item.End_Time;
                basic.Holding_City = item.Holding_City;
                basic.Start_Time   = item.Start_Time;

                basic.Is_Concert      = false;
                basic.Is_Exhibition   = false;
                basic.Is_Meeting      = false;
                basic.Is_Localholiday = false;
                basic.Is_Sportevent   = false;

                switch (item.Categoryname)
                {
                case "演唱会":
                    basic.Is_Concert = true;
                    break;

                case "体育比赛":
                    basic.Is_Sportevent = true;
                    break;

                case "展会":
                    basic.Is_Exhibition = true;
                    break;

                case "会议":
                    basic.Is_Meeting = true;
                    break;

                default:
                    basic.Is_Localholiday = true;
                    break;
                }

                basic.Is_Influence_Adult         = true;
                basic.Is_Influence_City          = true;
                basic.Is_Influence_Generalpublic = true;
                basic.Event_Fever   = 3;
                basic.Event_History = 1;
                basic.Freq          = 2;

                basic.Is_c_Government = false;

                basic.Is_Homecivil_Association      = false;
                basic.Is_Hometrade_Association      = false;
                basic.Is_Influence_Business         = false;
                basic.Is_Influence_Children         = false;
                basic.Is_Influence_Intercontinental = false;
                basic.Is_Influence_Old          = false;
                basic.Is_Influence_Province     = false;
                basic.Is_Influence_Wholecountry = false;
                basic.Is_Influence_Worldwide    = false;
                basic.Is_Influence_Young        = false;
                basic.Is_Intercivil_Association = false;
                basic.Is_International          = false;
                basic.Is_Intertrade_Association = false;

                basic.Is_l_Government = false;

                basic.Is_p_Government = false;

                basic.Participant_Population = false;

                listbasic.Add(basic);
            }
            db.BasicAttr.AddRange(listbasic);
            db.SaveChanges();
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 属性分析
        /// </summary>
        /// <param name="txthtml">txthtml为需要分析的文章</param>
        /// <returns></returns>
        public BasicAttr Analysis(string txthtml, string serverpath)
        {
            BasicAttr basic = new BasicAttr();

            string txturl9  = serverpath + @"Content\ThesaurusURL\gjzz.txt"; //国际组织
            string txturl10 = serverpath + @"Content\ThesaurusURL\gjzf.txt"; //国家政府
            string txturl11 = serverpath + @"Content\ThesaurusURL\szf.txt";  //省政府
            string txturl12 = serverpath + @"Content\ThesaurusURL\dfzf.txt"; //地方政府

            a = TypeSun(txthtml, txturl9);
            b = TypeSun(txthtml, txturl10);
            c = TypeSun(txthtml, txturl11);
            d = TypeSun(txthtml, txturl12);

            max = max = PutMax(a, b, c, d);
            if (a > 0 || b > 0 || c > 0 || d > 0)
            {
                if (max == a)
                {
                    //lblshuxing.Text = //lblshuxing.Text + ",国际组织";
                    basic.Is_International = true;
                }
                else if (max == b)
                {
                    //lblshuxing.Text = //lblshuxing.Text + ",国家政府";
                    basic.Is_c_Government = true;
                }
                else if (max == c)
                {
                    //lblshuxing.Text = //lblshuxing.Text + ",省政府";
                    basic.Is_p_Government = true;
                }
                else if (max == d)
                {
                    //lblshuxing.Text = //lblshuxing.Text + ",地方政府";
                    basic.Is_l_Government = true;
                }
            }

            a = b = c = d = e = 0;

            string hyxh = serverpath + @"Content\ThesaurusURL\hyxh.txt"; //行业协会
            string mjxh = serverpath + @"Content\ThesaurusURL\mjxh.txt"; //民间协会
            string gjhy = serverpath + @"Content\ThesaurusURL\gjhy.txt"; //国际行业
            string gjmj = serverpath + @"Content\ThesaurusURL\gjmj.txt"; //国际民间

            a   = TypeSun(txthtml, hyxh);
            b   = TypeSun(txthtml, mjxh);
            c   = TypeSun(txthtml, gjhy);
            d   = TypeSun(txthtml, gjmj);
            max = PutMax(a, b, c, d);
            if (a > 0 || b > 0 || c > 0 || d > 0)
            {
                if (max == a)
                {
                    // ",国内行业协会";
                    basic.Is_Hometrade_Association = true;
                }
                else if (max == b)
                {
                    // ",国内民间协会";
                    basic.Is_Homecivil_Association = true;
                }
                else if (max == c)
                {
                    // ",国际行业协会";
                    basic.Is_Intertrade_Association = true;
                }
                else if (max == d)
                {
                    // ",国际民间协会";
                    basic.Is_Intercivil_Association = true;
                }
            }

            a = b = c = d = e = 0;
            string txturl6 = serverpath + @"Content\ThesaurusURL\et.txt"; //儿童
            string txturl7 = serverpath + @"Content\ThesaurusURL\qn.txt"; //青年
            string txturl8 = serverpath + @"Content\ThesaurusURL\lr.txt"; //老人

            a = TypeSun(txthtml, txturl6);
            b = TypeSun(txthtml, txturl7);
            c = TypeSun(txthtml, txturl8);

            max = PutMax(a, b, c);
            if (a > 0 || b > 0 || c > 0)
            {
                if (max == a)
                {
                    // ",儿童";
                    basic.Is_Influence_Children = true;
                }
                else if (max == b)
                {
                    // ",青年";
                    basic.Is_Influence_Young = true;
                }
                else if (max == c)
                {
                    // ",老人";
                    basic.Is_Influence_Old = true;
                }
            }
            else
            {
                // ",成年";
                basic.Is_Influence_Adult = true;
            }
            a = b = c = d = e = 0;
            string tyss = serverpath + @"Content\ThesaurusURL\tyss.txt";//体育赛事
            int    sw   = TypeSun(txthtml, tyss);

            if (sw > 3)
            {
                // ",固定人群";
                basic.Participant_Population = true;
            }
            a = b = c = d = e = 0;
            string txturl5 = serverpath + @"Content\ThesaurusURL\jj.txt";//经济人群

            sw = TypeSun(txthtml, txturl5);
            if (sw > 3)
            {
                // ",影响商务人群";
                basic.Is_Influence_Business = true;
            }
            else
            {
                // ",影响社会大众";
                basic.Is_Influence_Generalpublic = true;
            }
            a = b = c = d = e = 0;
            string txturl1 = serverpath + @"Content\ThesaurusURL\qq.txt"; //全球
            string txturl2 = serverpath + @"Content\ThesaurusURL\zj.txt"; //洲际
            string txturl3 = serverpath + @"Content\ThesaurusURL\qg.txt"; //全国
            string txturl4 = serverpath + @"Content\ThesaurusURL\qs.txt"; //全省

            a   = TypeSun(txthtml, txturl1);
            b   = TypeSun(txthtml, txturl2);
            c   = TypeSun(txthtml, txturl3);
            d   = TypeSun(txthtml, txturl4);
            max = PutMax(a, b, c, d);

            if (a > 0 || b > 0 || c > 0 || d > 0)
            {
                if (max == a)
                {
                    // ",全球";
                    basic.Is_Influence_Worldwide = true;
                }
                else if (max == b)
                {
                    // ",洲际";
                    basic.Is_Influence_Intercontinental = true;
                }
                else if (max == c)
                {
                    // ",全国";
                    basic.Is_Influence_Wholecountry = true;
                }
                else if (max == d)
                {
                    // ",全省";
                    basic.Is_Influence_Province = true;
                }
            }
            else
            {
                // ",全市";
                basic.Is_Influence_City = true;
            }

            a = b = c = d = e = 0;

            string ych    = serverpath + @"Content\ThesaurusURL\ych.txt";    //演唱会
            string hz     = serverpath + @"Content\ThesaurusURL\hz.txt";     //会展
            string hy     = serverpath + @"Content\ThesaurusURL\hy.txt";     //会议
            string dfxjjr = serverpath + @"Content\ThesaurusURL\dfxjjr.txt"; //地方性节假日

            a   = TypeSun(txthtml, tyss);
            b   = TypeSun(txthtml, ych);
            c   = TypeSun(txthtml, hz, tyss);
            d   = TypeSun(txthtml, hy);
            e   = TypeSun(txthtml, dfxjjr);
            max = PutMax(a, b, c, d, e);
            if (a > 0 || b > 0 || c > 0 || d > 0 || e > 0)
            {
                if (max == a)
                {
                    // ",体育赛事";
                    basic.Is_Sportevent = true;
                }
                else if (max == b)
                {
                    // ",演唱会";
                    basic.Is_Concert = true;
                }
                else if (max == c)
                {
                    // ",会展";
                    basic.Is_Exhibition = true;
                }
                else if (max == d)
                {
                    // ",会议";
                    basic.Is_Meeting = true;
                }
                else if (max == e)
                {
                    // ",地方性节假日";
                    basic.Is_Localholiday = true;
                }
            }

            ///三大玄学
            Random rd = new Random();

            basic.Event_Fever   = rd.Next(1, 3);
            basic.Event_History = rd.Next(1, 3);
            basic.Freq          = rd.Next(1, 3);
            return(basic);
        }