public static string StemAcronym(string s, CliqueTemplates ct) { if (ct.stemmedAcronymIndex.Contains(s)) { return((string)ct.stemmedAcronymIndex[s]); } Matcher matcher = acronymPattern.Matcher(s); if (!matcher.Matches() || Sharpen.Runtime.EqualsIgnoreCase(s, "www")) { log.Info("Not a valid acronym: " + s); return("null"); } string stemmed = matcher.Group(1).ToLower(); if (stemmed.EndsWith("-")) { stemmed = Sharpen.Runtime.Substring(stemmed, 0, stemmed.Length - 1); } ct.stemmedAcronymIndex[s] = stemmed; log.Info("Stemmed: " + s + " to: " + stemmed); if (ct.inverseAcronymMap.Contains(stemmed)) { HashSet set = (HashSet)ct.inverseAcronymMap[stemmed]; set.Add(s); } else { HashSet set = new HashSet(); set.Add(s); ct.inverseAcronymMap[stemmed] = set; } return(stemmed); }
/// <summary> /// Divides this template into partial templates, and updates the counts of these /// partial templates in the /// <see cref="CliqueTemplates"/> /// object. /// </summary> /// <param name="ct">the partial templates counter object</param> /// <param name="score">increment counts by this much</param> public virtual void UnpackToCliqueTemplates(CliqueTemplates ct, double score) { ct.dateCliqueCounter.IncrementCount(new DateTemplate(values[0], values[1], values[2], values[3]), score); if (values[4] != null) { ct.locationCliqueCounter.IncrementCount(values[4], score); } ct.workshopInfoCliqueCounter.IncrementCount(new InfoTemplate(values[6], values[5], values[7], values[9], values[8], values[10], ct), score); }
public InfoTemplate(string whomepage, string wacronym, string wname, string chomepage, string cacronym, string cname, CliqueTemplates ct) { if (whomepage != null) { this.whomepage = whomepage; } if (wacronym != null) { this.wacronym = PascalTemplate.StemAcronym(wacronym, ct); } if (wname != null) { this.wname = wname; } if (chomepage != null) { this.chomepage = chomepage; } if (cacronym != null) { this.cacronym = PascalTemplate.StemAcronym(cacronym, ct); } if (cname != null) { this.cname = cname; } }