중복 키워드 적용

This commit is contained in:
2018-01-01 18:32:02 +09:00
parent ae919bdc95
commit b4e3d0d87b
5 changed files with 104 additions and 9 deletions

58
ConfigForm.Designer.cs generated
View File

@@ -79,6 +79,9 @@
this.tbAnSupplyContractRate = new System.Windows.Forms.TextBox();
this.label9 = new System.Windows.Forms.Label();
this.cbMockTrading = new System.Windows.Forms.CheckBox();
this.groupBox13 = new System.Windows.Forms.GroupBox();
this.btnDuplicatedKeywordApply = new System.Windows.Forms.Button();
this.btnDuplicatedKeywordEdit = new System.Windows.Forms.Button();
this.groupBox1.SuspendLayout();
this.groupBox2.SuspendLayout();
this.groupBox6.SuspendLayout();
@@ -91,6 +94,7 @@
this.groupBox10.SuspendLayout();
this.groupBox11.SuspendLayout();
this.groupBox12.SuspendLayout();
this.groupBox13.SuspendLayout();
this.SuspendLayout();
//
// tbVolume
@@ -166,13 +170,14 @@
//
// groupBox2
//
this.groupBox2.Controls.Add(this.groupBox13);
this.groupBox2.Controls.Add(this.groupBox6);
this.groupBox2.Controls.Add(this.groupBox3);
this.groupBox2.Controls.Add(this.groupBox5);
this.groupBox2.Controls.Add(this.groupBox4);
this.groupBox2.Location = new System.Drawing.Point(280, 12);
this.groupBox2.Name = "groupBox2";
this.groupBox2.Size = new System.Drawing.Size(262, 298);
this.groupBox2.Size = new System.Drawing.Size(372, 246);
this.groupBox2.TabIndex = 10;
this.groupBox2.TabStop = false;
this.groupBox2.Text = "키워드";
@@ -181,7 +186,7 @@
//
this.groupBox6.Controls.Add(this.btnSynonymApply);
this.groupBox6.Controls.Add(this.btnSynonymEdit);
this.groupBox6.Location = new System.Drawing.Point(44, 212);
this.groupBox6.Location = new System.Drawing.Point(17, 20);
this.groupBox6.Name = "groupBox6";
this.groupBox6.Size = new System.Drawing.Size(165, 58);
this.groupBox6.TabIndex = 12;
@@ -212,7 +217,7 @@
//
this.groupBox3.Controls.Add(this.btnPositiveApply);
this.groupBox3.Controls.Add(this.btnPositiveEdit);
this.groupBox3.Location = new System.Drawing.Point(44, 20);
this.groupBox3.Location = new System.Drawing.Point(17, 84);
this.groupBox3.Name = "groupBox3";
this.groupBox3.Size = new System.Drawing.Size(165, 58);
this.groupBox3.TabIndex = 11;
@@ -233,7 +238,7 @@
//
this.groupBox5.Controls.Add(this.btnNegativeApply);
this.groupBox5.Controls.Add(this.btnNegativeEdit);
this.groupBox5.Location = new System.Drawing.Point(44, 148);
this.groupBox5.Location = new System.Drawing.Point(190, 20);
this.groupBox5.Name = "groupBox5";
this.groupBox5.Size = new System.Drawing.Size(165, 58);
this.groupBox5.TabIndex = 12;
@@ -264,7 +269,7 @@
//
this.groupBox4.Controls.Add(this.btnManualApply);
this.groupBox4.Controls.Add(this.btnManualEdit);
this.groupBox4.Location = new System.Drawing.Point(44, 84);
this.groupBox4.Location = new System.Drawing.Point(190, 84);
this.groupBox4.Name = "groupBox4";
this.groupBox4.Size = new System.Drawing.Size(165, 58);
this.groupBox4.TabIndex = 12;
@@ -460,7 +465,7 @@
this.groupBox12.Controls.Add(this.tbAnRevenueRate);
this.groupBox12.Controls.Add(this.label6);
this.groupBox12.Controls.Add(this.tbAnSupplyContractRate);
this.groupBox12.Location = new System.Drawing.Point(280, 316);
this.groupBox12.Location = new System.Drawing.Point(280, 264);
this.groupBox12.Name = "groupBox12";
this.groupBox12.Size = new System.Drawing.Size(262, 270);
this.groupBox12.TabIndex = 19;
@@ -618,11 +623,11 @@
//
this.label9.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label9.AutoSize = true;
this.label9.Location = new System.Drawing.Point(12, 577);
this.label9.Location = new System.Drawing.Point(12, 532);
this.label9.Name = "label9";
this.label9.Size = new System.Drawing.Size(132, 12);
this.label9.TabIndex = 20;
this.label9.Text = "Version : 2017.11.18.01";
this.label9.Text = "Version : 2018.01.01.20";
//
// cbMockTrading
//
@@ -635,11 +640,42 @@
this.cbMockTrading.UseVisualStyleBackColor = true;
this.cbMockTrading.CheckedChanged += new System.EventHandler(this.cbMockTrading_CheckedChanged);
//
// groupBox13
//
this.groupBox13.Controls.Add(this.btnDuplicatedKeywordApply);
this.groupBox13.Controls.Add(this.btnDuplicatedKeywordEdit);
this.groupBox13.Location = new System.Drawing.Point(190, 148);
this.groupBox13.Name = "groupBox13";
this.groupBox13.Size = new System.Drawing.Size(165, 58);
this.groupBox13.TabIndex = 13;
this.groupBox13.TabStop = false;
this.groupBox13.Text = "중복 등록 문구";
//
// btnDuplicatedKeywordApply
//
this.btnDuplicatedKeywordApply.Location = new System.Drawing.Point(86, 14);
this.btnDuplicatedKeywordApply.Name = "btnDuplicatedKeywordApply";
this.btnDuplicatedKeywordApply.Size = new System.Drawing.Size(72, 39);
this.btnDuplicatedKeywordApply.TabIndex = 4;
this.btnDuplicatedKeywordApply.Text = "적용";
this.btnDuplicatedKeywordApply.UseVisualStyleBackColor = true;
this.btnDuplicatedKeywordApply.Click += new System.EventHandler(this.btnDuplicatedKeywordApply_Click);
//
// btnDuplicatedKeywordEdit
//
this.btnDuplicatedKeywordEdit.Location = new System.Drawing.Point(8, 14);
this.btnDuplicatedKeywordEdit.Name = "btnDuplicatedKeywordEdit";
this.btnDuplicatedKeywordEdit.Size = new System.Drawing.Size(72, 39);
this.btnDuplicatedKeywordEdit.TabIndex = 4;
this.btnDuplicatedKeywordEdit.Text = "편집";
this.btnDuplicatedKeywordEdit.UseVisualStyleBackColor = true;
this.btnDuplicatedKeywordEdit.Click += new System.EventHandler(this.btnDuplicatedKeywordEdit_Click);
//
// ConfigForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 12F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(548, 598);
this.ClientSize = new System.Drawing.Size(670, 553);
this.Controls.Add(this.cbMockTrading);
this.Controls.Add(this.label9);
this.Controls.Add(this.groupBox12);
@@ -670,6 +706,7 @@
this.groupBox11.PerformLayout();
this.groupBox12.ResumeLayout(false);
this.groupBox12.PerformLayout();
this.groupBox13.ResumeLayout(false);
this.ResumeLayout(false);
this.PerformLayout();
@@ -727,5 +764,8 @@
private System.Windows.Forms.Label label5;
private System.Windows.Forms.TextBox tbAnProfitChange;
private System.Windows.Forms.CheckBox cbMockTrading;
private System.Windows.Forms.GroupBox groupBox13;
private System.Windows.Forms.Button btnDuplicatedKeywordApply;
private System.Windows.Forms.Button btnDuplicatedKeywordEdit;
}
}

View File

@@ -119,6 +119,16 @@ namespace NewsCrawler
{
m_Listener.ApplySynonym();
}
private void btnDuplicatedKeywordEdit_Click(object sender, EventArgs e)
{
OpenFile("/keyword-duplicated.txt");
}
private void btnDuplicatedKeywordApply_Click(object sender, EventArgs e)
{
m_Listener.ApplyDuplicatedKeyword();
}
#endregion
#region Buy

View File

@@ -280,6 +280,12 @@ namespace NewsCrawler
break;
}
if (m_Condition.IsDuplicatedKeyword(NewsItem.m_strTitle) == true)
{
m_CodeList.AddDuplicatedList(NewsItem.m_Code.m_strCode, NewsItem.m_Code.m_strName);
Util.Log(Util.LOG_TYPE.DEBUG, string.Format("[DUPLICATED_KEYWORD] [{0}] {1}({2})", NewsItem.m_strRef, NewsItem.m_strTitle, NewsItem.m_Code.ToString()));
}
CheckPrice(NewsItem);
}
@@ -840,6 +846,11 @@ namespace NewsCrawler
m_CodeList.LoadSynonym();
}
public void ApplyDuplicatedKeyword()
{
m_Condition.LoadDuplicatedKeyword();
}
private void NewsForm_FormClosing(object sender, FormClosingEventArgs e)
{
Util.Clear();

View File

@@ -19,6 +19,7 @@ namespace NewsCrawler
List<Regex> m_Positive = new List<Regex>();
List<Regex> m_Negative = new List<Regex>();
List<Regex> m_Manual = new List<Regex>();
List<Regex> m_Duplicated = new List<Regex>();
public TextCondition()
{
@@ -130,11 +131,38 @@ namespace NewsCrawler
}
}
public void LoadDuplicatedKeyword()
{
m_Duplicated.Clear();
string strPath = Util.GetConfigPath() + "/keyword-duplicated.txt";
if (File.Exists(strPath) == true)
{
string[] aLines = File.ReadAllLines(strPath);
foreach (string line in aLines)
{
if (line.Trim().Length == 0 || line[0] == '#')
continue;
try
{
m_Duplicated.Add(new Regex(line));
}
catch (ArgumentException ex)
{
Util.Log(Util.LOG_TYPE.ERROR, string.Format("[keyword-duplicated] 잘못된 키워드 ({0})", ex.Message));
}
}
}
}
void LoadAll()
{
LoadPositive();
LoadNegative();
LoadManual();
LoadDuplicatedKeyword();
}
public string GetKeywordsCnt()
@@ -175,5 +203,11 @@ namespace NewsCrawler
return new RESULT(TYPE.NOT_MATCHED, "");
}
public bool IsDuplicatedKeyword(string strText)
{
Regex result = m_Duplicated.Find(s => s.IsMatch(strText));
return (result != null);
}
}
}