Exemplo n.º 1
0
        private void TestGrpClassUtilityGrouping()
        {
            try
            {
                GrpClassUtility _grpClassUtility = new GrpClassUtility(this.connectionString, this.timeoutInSecondsBD, numberSubprocess, numberSubprocess);
                string _taskName = "EXPERIMENT_1";
                Return<Training> _answerGetTrainingActive = _grpClassUtility.GetTrainingActive(_taskName, Grp_ClassCommon.TRAINING_TYPE_GROUPING);
                if (_answerGetTrainingActive.theresError)
                    ShowMessage(_answerGetTrainingActive.error.ToString());
                else
                    if (_answerGetTrainingActive.data == null)
                        ShowMessage("We could not find any training");
                    else
                    {
                        Return<List<List<BlatellaGroup>>> _answerGroup = _grpClassUtility.Group(_taskName, _answerGetTrainingActive.data);
                        if (_answerGroup.theresError)
                            ShowMessage(_answerGroup.error.ToString());
                        else
                        {
                            foreach (List<BlatellaGroup> _clustering in _answerGroup.data)
                            {
                                string _clusteringDirectory = Path.Combine(iNfolder, string.Format("clustering_{0}", Convert.ToString(_answerGroup.data.IndexOf(_clustering))));
                                if (Directory.Exists(_clusteringDirectory))
                                    Directory.Delete(_clusteringDirectory, true);
                                Directory.CreateDirectory(_clusteringDirectory);

                                foreach (BlatellaGroup _cluster in _clustering)
                                {
                                    string _clusterDirectoryName = string.Join("_", _cluster.entities.Cast<Document>().Select(d => Convert.ToString(d.id)));
                                    string _clusterDirectory = Path.Combine(_clusteringDirectory, _clusterDirectoryName);
                                    Directory.CreateDirectory(_clusterDirectory);
                                    foreach (Document _document in _cluster.entities.Cast<Document>())
                                    {
                                        XmlDocument _documentoXml = new XmlDocument();
                                        _documentoXml.LoadXml(_document.information);

                                        string _sourceFileName = _documentoXml.FirstChild.InnerText;
                                        string _destFile = Path.GetFileName(_sourceFileName);
                                        string _destFileName = Path.Combine(_clusterDirectory, _destFile);

                                        File.Copy(_sourceFileName, _destFileName);
                                    }
                                }
                            }
                            ShowMessage("process finished");
                        }
                    }
            }
            catch (Exception _ex)
            {
                ShowMessage(_ex.Message);
            }
        }
Exemplo n.º 2
0
        private void TestGrpClassUtilityCreateVectorSpaceModel()
        {
            try
            {
                Dictionary<string, string> _stopWords = new Dictionary<string, string>();
                _stopWords.Add("es-ES", @"stop_words_es.txt");
                _stopWords.Add("ca-ES", @"stop_words_ca.txt");
                _stopWords.Add("en-US", @"stop_words_en.txt");

                GrpClassUtility _grpClassUtility = new GrpClassUtility(this.connectionString, this.timeoutInSecondsBD, numberSubprocess, numberSubprocess, _stopWords);
                string _taskName = "EXPERIMENT_1";
                Return<Training> _answerGetTrainingInConstruction = _grpClassUtility.GetTrainingInConstruction(_taskName, Grp_ClassCommon.TRAINING_TYPE_GROUPING);
                if (_answerGetTrainingInConstruction.theresError)
                    ShowMessage(_answerGetTrainingInConstruction.error.ToString());
                else
                    if (_answerGetTrainingInConstruction.data == null)
                        ShowMessage("We could not find any training");
                    else
                    {
                        Return<List<InfoGrp_Class>> _answerGetInfos = GetInfos();
                        if (_answerGetInfos.theresError)
                            ShowMessage(_answerGetInfos.error.ToString());
                        else
                            if (!_answerGetInfos.data.Any())
                                ShowMessage("No infos");
                            else
                            {//we have infos
                                int sizePartition = 50;
                                Return<object> _answerCreateVectorSpaceModel = _grpClassUtility.CreateVectorSpaceModel(_answerGetInfos.data, _taskName, _answerGetTrainingInConstruction.data, sizePartition);
                                if (_answerCreateVectorSpaceModel.theresError)
                                    ShowMessage(_answerCreateVectorSpaceModel.error.ToString());
                                else
                                    ShowMessage("process finished");
                            }//we have infos

                        /*
                        _answerGetTrainingInConstruction.data.stateTraining = Grp_ClassCommon.TRAINING_STATE_ACTIVE;
                        Return<int> _answerUpdateTraining = _grpClassUtility.UpdateTraining(_answerGetTrainingInConstruction.data);
                        */
                    }
            }
            catch (Exception _ex)
            {
                ShowMessage(_ex.Message);
            }
        }