중복 키워드 적용

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

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);
}
}
}