public int FindOccurrences(IEnumerable<string> ngram)
{
if (ngram.Count() == 0)
{
// considering unigrams, we need to fit prob 1 total
// this means we have to divide by number of segments total
return Documents.Aggregate(0, (count, doc) => count + doc.LanguageSegments.Count);
}
if (_segmentTable != null)
{
double data;
if (_segmentTable.TryFindValue(ngram, out data))
{
return Convert.ToInt32(data);
}
else
{
return 0;
}
}
int result = 0;
foreach (var item in Documents)
{
result += item.FindOccurrences(ngram);
}
return result;
}