Ejemplo n.º 1
0
        private void 快速测试F5ToolStripMenuItem_Click(object sender, EventArgs e)
        {
            this.messageListBox.Items.Clear();
            this.JWordSegmentor.FilterStopWords        = this.checkBox1.Checked;
            this.JWordSegmentor.AutoInsertUnknownWords = true;
            this.JWordSegmentor.AutoStudy = true;
            this.JWordSegmentor.FreqFirst = true;
            string[] keywords = this.JWordSegmentor.Segment(this.TextFile()).ToArray();
            Dictionary <string, ulong> dic = KwHelper.KeywordSortor(keywords, false);

            foreach (var item in dic)
            {
                this.AddText(item.Key + " | " + item.Value.ToString());
            }
        }
        /// <summary>
        /// Server程序启动
        /// </summary>
        private void Start()
        {
            this.StatusString = "开始抓取";
            ///读入一批URL列表
            WebPage[] _CrawlUrls = Service.DbHelper.CrawlUrls;

            foreach (WebPage url in _CrawlUrls)
            {
                ///从URL链接获取该URL的HtmlCode
                Dictionary <string, ulong> keywords = HtmlHelper.SetupSingleUrl(
                    url.Url,
                    true,
                    Service.JWordSegmentor,
                    Service.DbHelper.WebRuleCollections);

                ///根据关键词匹配广告
                long[] adIds = KwHelper.Match(keywords, _AdHelper.AdInvertedIndex);

                ///建立广告位(页面)与广告的相关联的关系文件
                Service.FileService.CreateBillboardRelation(adIds, url.Url);
            }
        }