public YearBornBot() { this.network = (FeedforwardNetwork)SerializeObject .Load(Config.FILENAME_WHENBORN_NET); this.histogram = (WordHistogram)SerializeObject .Load(Config.FILENAME_HISTOGRAM); }
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); } }
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."); }
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."); }
public AnalyzeSentences(WordHistogram histogram, int size) { this.histogram = histogram; }
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); } }
public AnalyzeSentences(WordHistogram histogram, int size) { this.histogram = histogram; }