public static void ExtractDnevnikEmoticonsFeaturesAndUpdateItemFeatures(string commentText, Dictionary<string, double> item) { var matches = Regex.Matches(commentText, @"\[emo-[^\]]*\]"); if (matches.Count > 0) { foreach (Match match in matches) { string emoticon = match.Value.Replace("[", "").Replace("]", "").Replace("-", "_"); item.SetFeatureValue("emo_" + emoticon, 1); } } }
public static void SetFeatureToRegExMatchesCount(string pattern, string featureKey, string commentText, Dictionary<string, double> item) { Regex regEx = new Regex(pattern); var matches = regEx.IsMatch(commentText) ? regEx.Matches(commentText) : null; if (matches == null) { item.SetFeatureValue(featureKey, 0); return; } int numberOfMatches = matches.Count; item.SetFeatureValue(featureKey, numberOfMatches * 1.0); }