Пример #1
0
 public Sentence(AnalysisContext context, string sentence)
 {
     this.context = context;
     Text = sentence;
     Entities = new List<int>();
     SentimentWords = new List<int>();
 }
Пример #2
0
 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]);
     }
 }
Пример #3
0
        public static AnalysisContext CreateContext()
        {
            AnalysisContext cont = new AnalysisContext();
            var lines = File.ReadAllLines(Constants.WordsFile);
            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(Constants.EntitiesFile);
            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(Constants.FrasesFile);
            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;
        }