Пример #1
0
 public YearBornBot()
 {
     this.network = (FeedforwardNetwork)SerializeObject
             .Load(Config.FILENAME_WHENBORN_NET);
     this.histogram = (WordHistogram)SerializeObject
             .Load(Config.FILENAME_HISTOGRAM);
 }
Пример #2
0
 public void RemoveCommon(WordHistogram other)
 {
     foreach (HistogramElement element in other.Sorted)
     {
         HistogramElement e = this.Get(element.Word);
         if (e == null)
         {
             continue;
         }
         this.sorted.Remove(e);
         this.histogram.Remove(element.Word);
     }
 }
Пример #3
0
        public void Process()
        {
            this.network = NetworkUtil.CreateNetwork();
            Console.WriteLine("Preparing training sets...");
            this.common = new CommonWords(Config.FILENAME_COMMON_WORDS);
            this.histogramGood = new WordHistogram(this.common);
            this.histogramBad = new WordHistogram(this.common);

            // load the good words
            this.histogramGood.BuildFromFile(Config.FILENAME_GOOD_TRAINING_TEXT);
            this.histogramGood.BuildComplete();

            // load the bad words
            this.histogramBad.BuildFromFile(Config.FILENAME_BAD_TRAINING_TEXT);
            this.histogramBad.BuildComplete();

            // remove low scoring words
            this.histogramGood
                    .RemoveBelow((int)this.histogramGood.CalculateMean());
            this.histogramBad.RemovePercent(0.99);

            // remove common words
            this.histogramGood.RemoveCommon(this.histogramBad);

            this.histogramGood.Trim(Config.INPUT_SIZE);

            this.goodAnalysis = new AnalyzeSentences(this.histogramGood,
                    Config.INPUT_SIZE);
            this.badAnalysis = new AnalyzeSentences(this.histogramGood,
                    Config.INPUT_SIZE);

            this.goodAnalysis.Process(this.trainingSet, 0.9,
                    Config.FILENAME_GOOD_TRAINING_TEXT);
            this.badAnalysis.Process(this.trainingSet, 0.1,
                    Config.FILENAME_BAD_TRAINING_TEXT);

            this.sampleCount = this.trainingSet.Ideal.Count;
            Console.WriteLine("Processing " + this.sampleCount + " training sets.");

            AllocateTrainingSets();

            CopyTrainingSets();

            TrainNetworkBackpropBackprop();
            SerializeObject.Save(Config.FILENAME_WHENBORN_NET, this.network);
            SerializeObject.Save(Config.FILENAME_HISTOGRAM, this.histogramGood);
            Console.WriteLine("Training complete.");

        }
Пример #4
0
        public void Process()
        {
            this.network = NetworkUtil.CreateNetwork();
            Console.WriteLine("Preparing training sets...");
            this.common        = new CommonWords(Config.FILENAME_COMMON_WORDS);
            this.histogramGood = new WordHistogram(this.common);
            this.histogramBad  = new WordHistogram(this.common);

            // load the good words
            this.histogramGood.BuildFromFile(Config.FILENAME_GOOD_TRAINING_TEXT);
            this.histogramGood.BuildComplete();

            // load the bad words
            this.histogramBad.BuildFromFile(Config.FILENAME_BAD_TRAINING_TEXT);
            this.histogramBad.BuildComplete();

            // remove low scoring words
            this.histogramGood
            .RemoveBelow((int)this.histogramGood.CalculateMean());
            this.histogramBad.RemovePercent(0.99);

            // remove common words
            this.histogramGood.RemoveCommon(this.histogramBad);

            this.histogramGood.Trim(Config.INPUT_SIZE);

            this.goodAnalysis = new AnalyzeSentences(this.histogramGood,
                                                     Config.INPUT_SIZE);
            this.badAnalysis = new AnalyzeSentences(this.histogramGood,
                                                    Config.INPUT_SIZE);

            this.goodAnalysis.Process(this.trainingSet, 0.9,
                                      Config.FILENAME_GOOD_TRAINING_TEXT);
            this.badAnalysis.Process(this.trainingSet, 0.1,
                                     Config.FILENAME_BAD_TRAINING_TEXT);

            this.sampleCount = this.trainingSet.Ideal.Count;
            Console.WriteLine("Processing " + this.sampleCount + " training sets.");

            AllocateTrainingSets();

            CopyTrainingSets();

            TrainNetworkBackpropBackprop();
            SerializeObject.Save(Config.FILENAME_WHENBORN_NET, this.network);
            SerializeObject.Save(Config.FILENAME_HISTOGRAM, this.histogramGood);
            Console.WriteLine("Training complete.");
        }
Пример #5
0
 public AnalyzeSentences(WordHistogram histogram, int size)
 {
     this.histogram = histogram;
 }
Пример #6
0
        public void RemoveCommon(WordHistogram other)
        {
            foreach (HistogramElement element in other.Sorted )
            {
                HistogramElement e = this.Get(element.Word);
                if (e == null)
                {
                    continue;
                }
                this.sorted.Remove(e);
                this.histogram.Remove(element.Word);

            }
        }
Пример #7
0
 public AnalyzeSentences(WordHistogram histogram, int size)
 {
     this.histogram = histogram;
 }