중복 키워드 적용
This commit is contained in:
@@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user