diff --git a/NewsForm.cs b/NewsForm.cs index a58da6b..2315e9c 100644 --- a/NewsForm.cs +++ b/NewsForm.cs @@ -232,6 +232,20 @@ namespace NewsCrawler Util.Log(Util.LOG_TYPE.NEGATIVE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code.ToString())); break; + case TextCondition.TYPE.POSITIVE_FORCE: + if ((NewsItem.m_Code.m_enType & CodeList.CODE_TYPE.DUPLICATED) == CodeList.CODE_TYPE.DUPLICATED) + { + Util.Log(Util.LOG_TYPE.DUPLICATED, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code.ToString())); + } + else + { + BuyItem(NewsItem.m_Code); + Util.Log(Util.LOG_TYPE.POSITIVE_FORCE, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code.ToString())); + } + + m_CodeList.AddDuplicatedList(NewsItem.m_Code.m_strCode, NewsItem.m_Code.m_strName); + break; + case TextCondition.TYPE.POSITIVE: if((NewsItem.m_Code.m_enType&CodeList.CODE_TYPE.DENIAL) == CodeList.CODE_TYPE.DENIAL) Util.Log(Util.LOG_TYPE.DENIAL, string.Format("[{0}] {1} (keyword:{2}, code:{3})", NewsItem.m_strRef, NewsItem.m_strTitle, MatchResult.m_strKeyword, NewsItem.m_Code.ToString())); diff --git a/TextCondition.cs b/TextCondition.cs index f5d9a54..2353e79 100644 --- a/TextCondition.cs +++ b/TextCondition.cs @@ -13,10 +13,12 @@ namespace NewsCrawler NOT_MATCHED, NEGATIVE, POSITIVE, + POSITIVE_FORCE, MANUAL } List m_Positive = new List(); + List m_PositiveForce = new List(); List m_Negative = new List(); List m_Manual = new List(); List m_Duplicated = new List(); @@ -81,6 +83,31 @@ namespace NewsCrawler } } + public void LoadPositiveForce() + { + m_PositiveForce.Clear(); + + string strPath = Util.GetConfigPath() + "/keyword-positive-force.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_PositiveForce.Add(new Regex(line)); + } + catch (ArgumentException ex) + { + Util.Log(Util.LOG_TYPE.ERROR, string.Format("[keyword-positive-force] 잘못된 키워드 ({0})", ex.Message)); + } + } + } + } + public void LoadManual() { m_Manual.Clear(); @@ -160,6 +187,7 @@ namespace NewsCrawler void LoadAll() { LoadPositive(); + LoadPositiveForce(); LoadNegative(); LoadManual(); LoadDuplicatedKeyword(); @@ -167,7 +195,11 @@ namespace NewsCrawler public string GetKeywordsCnt() { - return string.Format("Positive : {0}\nNegative : {1}\nManual : {2}", m_Positive.Count, m_Negative.Count, m_Manual.Count); + return string.Format("Positive: {0}\nPositiveForce: {1}\nNegative: {2}\nManual: {3}", + m_Positive.Count, + m_PositiveForce.Count, + m_Negative.Count, + m_Manual.Count); } public class RESULT @@ -201,6 +233,10 @@ namespace NewsCrawler if(result != null) return new RESULT(TYPE.POSITIVE, result.ToString()); + result = m_PositiveForce.Find(s => s.IsMatch(strText)); + if (result != null) + return new RESULT(TYPE.POSITIVE_FORCE, result.ToString()); + return new RESULT(TYPE.NOT_MATCHED, ""); } diff --git a/Util.cs b/Util.cs index 28a6877..0f18104 100644 --- a/Util.cs +++ b/Util.cs @@ -19,6 +19,7 @@ namespace NewsCrawler VERVOSE, NEGATIVE, POSITIVE, + POSITIVE_FORCE, MANUAL_KEYWORD, MANUAL_CODE, DUPLICATED, @@ -68,6 +69,7 @@ namespace NewsCrawler LogColor = Color.Blue; break; case LOG_TYPE.POSITIVE: + case LOG_TYPE.POSITIVE_FORCE: case LOG_TYPE.MANUAL_KEYWORD: case LOG_TYPE.BUY: LogColor = Color.Red; diff --git a/configure/keyword-positive-force.txt b/configure/keyword-positive-force.txt new file mode 100644 index 0000000..3adc5e3 --- /dev/null +++ b/configure/keyword-positive-force.txt @@ -0,0 +1 @@ +무조건