コード例 #1
0
        private List <decimal> GetSequence(string filePath, GetSequenceDelegate workerMethod)
        {
            if (workerMethod == null)
            {
                throw new ArgumentNullException("workerMethod");
            }
            if (!File.Exists(filePath))
            {
                throw new FileNotFoundException("filePath");
            }

            List <decimal> results = new List <decimal>();

            foreach (List <string> sentence in TrainedDataSet.TokenizeTextFile(filePath))
            {
                string lastWord = string.Empty;
                foreach (string word in sentence)
                {
                    if (string.IsNullOrWhiteSpace(word))
                    {
                        continue;
                    }
                    if (!string.IsNullOrEmpty(lastWord))
                    {
                        results.Add(workerMethod(lastWord, word));
                    }
                    lastWord = word;
                }
                results.Add(workerMethod(lastWord, WordDictionary.EndPlaceholder));
            }
            return(results);
        }
コード例 #2
0
 private void NewDataSet()
 {
     if (AskIfSaveFirst())
     {
         dataSet = new TrainedDataSet();
         OnDataSetLoaded();
     }
 }
コード例 #3
0
        private void SaveDataSet()
        {
            string selectedFile = ShowFileDialog(saveFileDialog);

            if (!string.IsNullOrWhiteSpace(selectedFile))
            {
                if (TrainedDataSet.SerializeToXml(dataSet, selectedFile))
                {
                    IsDatasetDirty = false;
                }
            }
        }
コード例 #4
0
        //  text corpus
        // lexicon, idiom, diction, locution, vernacular,
        // continuity, congruity, corpus, collocation,  forensic linguistics, article frequency

        public Stylometry(TrainedDataSet modelDatum)
        {
            if (modelDatum == null)
            {
                throw new ArgumentNullException("modelDatum");
            }
            if (modelDatum._wordDictionary == null)
            {
                throw new ArgumentNullException("modelDatum._wordDictionary");
            }

            _wordDictionary = modelDatum._wordDictionary;
        }
コード例 #5
0
 private void OpenDataSet()
 {
     if (AskIfSaveFirst())
     {
         string selectedFile = ShowFileDialog(openFileDialog);
         if (!string.IsNullOrWhiteSpace(selectedFile) && File.Exists(selectedFile))
         {
             dataSet = TrainedDataSet.DeserializeFromXml(selectedFile);
             if (dataSet != null)
             {
                 OnDataSetLoaded();
             }
         }
     }
 }
コード例 #6
0
 public MainForm()
 {
     InitializeComponent();
     dataSet        = new TrainedDataSet();
     IsDatasetDirty = false;
 }