Beispiel #1
0
 public Statistic()
 {
     initDict();
     output             = new StatisticOutput();
     output.time        = 0;
     output.feat        = 0;
     output.title       = "";
     output.discount    = 0;
     output.url         = "";
     output.description = "";
     output.keywordList = new Hashtable();
 }
Beispiel #2
0
 public Statistic()
 {
     initDict();
     output = new StatisticOutput();
     output.time = 0;
     output.feat = 0;
     output.title = "";
     output.discount = 0;
     output.url = "";
     output.description = "";
     output.keywordList = new Hashtable();
 }
Beispiel #3
0
 public Statistic(oneUrl item)
 {
     initDict();
     output             = new StatisticOutput();
     output.time        = item.time;
     output.feat        = item.feat;
     output.discount    = 100 - Convert.ToInt32(10 * Convert.ToDouble(item.discount));
     output.title       = item.seller + "-" + item.deal_title;
     output.description = item.description;
     output.keywordList = new Hashtable();
     splitwords(output.title, TITLE_WEIGHT);
     splitwords(item.other, OTHER_WEIGHT);
     splitwords(item.description, DESCRIPTION_WEIGHT);
 }
Beispiel #4
0
 public Statistic(oneUrl item)
 {
     initDict();
     output = new StatisticOutput();
     output.time = item.time;
     output.feat = item.feat;
     output.discount = 100 - Convert.ToInt32(10 * Convert.ToDouble(item.discount));
     output.title = item.seller + "-" + item.deal_title;
     output.description = item.description;
     output.keywordList = new Hashtable();
     splitwords(output.title, TITLE_WEIGHT);
     splitwords(item.other, OTHER_WEIGHT);
     splitwords(item.description, DESCRIPTION_WEIGHT);
 }
Beispiel #5
0
        public StatisticOutput statistic(oneUrl item)
        {//统计item中存储的团购条目信息
            Console.WriteLine("Computing the statisitc data of the item...");
            StatisticOutput oneOutput = new StatisticOutput();

            oneOutput.url         = item.url;
            oneOutput.time        = item.time;
            oneOutput.feat        = item.feat;
            oneOutput.discount    = 100 - Convert.ToInt32(10 * Convert.ToDouble(item.discount));
            oneOutput.title       = item.seller + "-" + item.deal_title;
            oneOutput.description = item.description;
            oneOutput.keywordList = new Hashtable();
            splitwords(ref oneOutput, oneOutput.title, TITLE_WEIGHT);
            splitwords(ref oneOutput, item.other, OTHER_WEIGHT);
            splitwords(ref oneOutput, item.description, DESCRIPTION_WEIGHT);
            Console.WriteLine("Statistic ready.");
            return(oneOutput);
        }
Beispiel #6
0
        private static void splitwords(ref StatisticOutput temOutput, string sentence, int weight)
        {//分词函数,作用同上,但分出的词加入tempOutput的关键词列表中
            List <T_WordInfo> words = m_SimpleDictSeg.SegmentToWordInfos(sentence);

            for (int i = 0; i < words.Count; i++)
            {
                //判断文本是否进入
                if (words[i] == null)
                {
                    continue;
                }
                if (temOutput.keywordList.ContainsKey(words[i].Word))
                {
                    temOutput.keywordList[words[i].Word] = (int)temOutput.keywordList[words[i].Word] + weight;
                }
                else
                {
                    temOutput.keywordList.Add(words[i].Word, weight);
                }
            }
        }
Beispiel #7
0
        private bool addOneUrl(int pos)
        {//添加第pos条团购条目信息
            string query;
            int    link_id;
            MD5    md5 = new MD5CryptoServiceProvider();;
            //XmlNode oneUrl = lashouDocument.DocumentElement.ChildNodes[pos];
            oneUrl          oneUrl = xmlparse.getOneUrl(pos);
            StatisticOutput sta    = staContext.statistic(oneUrl);

            Console.WriteLine("Insert the data to the database....");
            query = "insert into links (site_id, url, title, description) values(5, \"" +
                    sta.url + "\",\"" + sta.title + "\",\"" + sta.description + "\")";
            cmd = new MySQLDriverCS.MySQLCommand(query, conn);
            cmd.ExecuteNonQuery();
            cmd.Dispose();
            query = "select link_id from links where url = \"" + sta.url + "\"";
            cmd   = new MySQLDriverCS.MySQLCommand(query, conn);
            IDataReader dt = cmd.ExecuteReader();

            link_id = Convert.ToInt32(dt.GetSchemaTable().Rows[0]["link_id"]);
            foreach (DictionaryEntry de in sta.keywordList)
            {
                int keyword_id = 0;
                query = "select keyword_id from keywords where keyword = \"" + de.Key + "\"";
                cmd   = new MySQLDriverCS.MySQLCommand(query, conn);
                dt    = cmd.ExecuteReader();
                if (dt.GetSchemaTable().Rows.Count == 0)
                {
                    query = "insert into keywords (keyword) values (\"" + de.Key + "\")";
                    cmd   = new MySQLDriverCS.MySQLCommand(query, conn);
                    cmd.ExecuteNonQuery();
                    cmd.Dispose();

                    query      = "select keyword_id from keywords where keyword = \"" + de.Key + "\"";
                    cmd        = new MySQLDriverCS.MySQLCommand(query, conn);
                    dt         = cmd.ExecuteReader();
                    keyword_id = Convert.ToInt32(dt.GetSchemaTable().Rows[0]["keyword_id"]);
                }
                else
                {
                    keyword_id = Convert.ToInt32(dt.GetSchemaTable().Rows[0]["keyword_id"]);
                }
                byte[] hash = md5.ComputeHash(System.Text.Encoding.Default.GetBytes(de.Key.ToString()));
                string flag;
                switch (hash[0] >> 4)
                {
                case 10:
                    flag = "a";
                    break;

                case 11:
                    flag = "b";
                    break;

                case 12:
                    flag = "c";
                    break;

                case 13:
                    flag = "d";
                    break;

                case 14:
                    flag = "e";
                    break;

                case 15:
                    flag = "f";
                    break;

                default:
                    flag = (hash[0] >> 4).ToString();
                    break;
                }
                query = "insert into link_keyword" + flag + "(link_id, keyword_id, weight, time, feat, discount) values (" +
                        link_id + "," + keyword_id + "," + de.Value + "," + sta.time + "," + sta.feat + "," +
                        sta.discount + ")";
                cmd = new MySQLDriverCS.MySQLCommand(query, conn);
                cmd.ExecuteNonQuery();
                cmd.Dispose();
            }
            Console.WriteLine("Write one link sucessfully!");
            return(true);
        }
Beispiel #8
0
 private static void splitwords(ref StatisticOutput temOutput, string sentence, int weight)
 {
     //分词函数,作用同上,但分出的词加入tempOutput的关键词列表中
     List<T_WordInfo> words = m_SimpleDictSeg.SegmentToWordInfos(sentence);
     for (int i = 0; i < words.Count; i++)
     {
         //判断文本是否进入
         if (words[i] == null)
             continue;
         if (temOutput.keywordList.ContainsKey(words[i].Word))
         {
             temOutput.keywordList[words[i].Word] = (int)temOutput.keywordList[words[i].Word] + weight;
         }
         else
         {
             temOutput.keywordList.Add(words[i].Word, weight);
         }
     }
 }
Beispiel #9
0
 public StatisticOutput statistic(oneUrl item)
 {
     //统计item中存储的团购条目信息
     Console.WriteLine("Computing the statisitc data of the item...");
     StatisticOutput oneOutput = new StatisticOutput();
     oneOutput.url = item.url;
     oneOutput.time = item.time;
     oneOutput.feat = item.feat;
     oneOutput.discount = 100 - Convert.ToInt32(10 * Convert.ToDouble(item.discount));
     oneOutput.title = item.seller + "-" + item.deal_title;
     oneOutput.description = item.description;
     oneOutput.keywordList = new Hashtable();
     splitwords(ref oneOutput, oneOutput.title, TITLE_WEIGHT);
     splitwords(ref oneOutput, item.other, OTHER_WEIGHT);
     splitwords(ref oneOutput, item.description, DESCRIPTION_WEIGHT);
     Console.WriteLine("Statistic ready.");
     return oneOutput;
 }