public static Dictionary<string,int> CountProgramWords(ISrcMLArchive archive)
{
if(archive == null) {
throw new ArgumentNullException("archive");
}
var splitter = new ConservativeIdSplitter();
var observations = new Dictionary<string, int>();
foreach (var fileUnit in archive.FileUnits)
{
//query for all the identifiers
var identifiers = from id in fileUnit.Descendants(SRC.Name)
where !id.Elements().Any()
select id.Value;
foreach (var id in identifiers)
{
string[] words = splitter.Split(id);
foreach (string word in words)
{
int obs;
string lowWord = word.ToLower();
observations.TryGetValue(lowWord, out obs); //gets the number of observations for the word. If it is new, obs is set to 0
observations[lowWord] = obs + 1;
}
}
}
return observations;
}