public BaesianClassifier(AnalysisContext context) { this.context = context; foreach(var w in context.SentimentWords) { positiveDict.Add(w, new int[2]); negativeDict.Add(w, new int[2]); } }
public static AnalysisContext CreateContext() { AnalysisContext cont = new AnalysisContext(); var lines = File.ReadAllLines("Files\\words.txt"); foreach(var line in lines) { var pp = line.Split(new[] {';'}, StringSplitOptions.RemoveEmptyEntries); if(pp.Length>1) { var w = new Word() {Base = pp[1], id = int.Parse(pp[0])}; for (int i = 2; i < pp.Length; i++) w.Variations.AddLast(pp[i]); cont.allwords[w.id] = w; } } lines = File.ReadAllLines("Files\\entities.txt"); foreach(var l in lines) { var pp = l.Split(';'); if (pp.Length == 1) cont.Entities.Add(cont.allwords[int.Parse(pp[0])]); else { var f = new Frase(); foreach(var p in pp) { f.Add(cont.allwords[int.Parse(p)]); } cont.Entities.Add(f); } } lines = File.ReadAllLines("Files\\sentwords.txt"); foreach (var l in lines) { var pp = l.Split(';'); if (pp.Length == 1) cont.SentimentWords.Add(cont.allwords[int.Parse(pp[0])]); else { var f = new Frase(); foreach (var p in pp) { f.Add(cont.allwords[int.Parse(p)]); } cont.SentimentWords.Add(f); } } return cont; }