コード例 #1
0
		public GrpClassUtility(string connectionString, int timeoutInSecondsBD, int numberSubprocess, int numberSubprocessLanguageIdentification)
		{
			if (timeoutInSecondsBD <= 0)
				throw new ArgumentException(string.Format("timeoutInSecondsBD must be greather than 0 \"{0}\"", Convert.ToString(timeoutInSecondsBD)));
			else
				if (string.IsNullOrWhiteSpace(connectionString))
					throw new ArgumentNullException("connectionString");
				else
					grpClassDataAccess = new GrpClassDataAccess(connectionString, timeoutInSecondsBD);

			if (numberSubprocess <= 0)
				throw new ArgumentException(string.Format("numberSubprocess  must be greather than 0 \"{0}\"", Convert.ToString(numberSubprocess)));
			else
				this.numberSubprocess = numberSubprocess;

			if (numberSubprocessLanguageIdentification <= 0)
				throw new ArgumentException(string.Format("numberSubprocessLanguageIdentification  must be greather than 0 \"{0}\"", Convert.ToString(numberSubprocessLanguageIdentification)));
			else
				this.numberSubprocessLanguageIdentification = numberSubprocessLanguageIdentification;

			this.stopWords = new Dictionary<string, List<string>>();
			vectorSpaceModelUtility = new VectorSpaceModelUtility(this.stopWords);
			languageIdentificationUtility = new LanguageIdentificationUtility();
			groupingUtility = new GroupingUtility();
		}
コード例 #2
0
		/// <summary>
		/// 
		/// </summary>
		/// <param name="infos"></param>
		/// <returns></returns>
		public Return<object> SetLanguage(List<InfoGrp_Class> infos)
		{
			Return<object> _answer = new Return<object>();
			if (infos == null)
			{
				_answer.theresError = true;
				_answer.error = Utility.GetError(new ArgumentNullException("infos"), this.GetType());
			}
			else
			{
				try
				{
					List<InfoGrp_Class> _infosNoLanguage = infos.Where(i => !i.language.HasValue).ToList();
					if (_infosNoLanguage.Any())
					{
						int _numberSubprocess = _infosNoLanguage.Count < this.numberSubprocessLanguageIdentification ? _infosNoLanguage.Count : this.numberSubprocessLanguageIdentification;
						List<object> _objects = new List<object>();
						for (int _i = 0; _i < _numberSubprocess; _i++)
						{
							LanguageIdentificationUtility _object = new LanguageIdentificationUtility();
							Return<object> _answerLoadDefaultModels = _object.LoadDefaultModels();
							if (_answerLoadDefaultModels.theresError)
							{
								_answer.theresError = true;
								_answer.error = _answerLoadDefaultModels.error;
							}
							else
								_objects.Add(_object);

							if (_answer.theresError)
								break;
						}

						if (!_answer.theresError)
						{
							Stopwatch _stopwatch = new Stopwatch();
							string _tiempo = string.Empty;
							_stopwatch.Start();

							using (Processor<InfoGrp_Class> _processor = new Processor<InfoGrp_Class>(_numberSubprocess, MILLISECONDS_PAUSE_LANGUAGE_IDENTIFICATION, _objects))
							{
								_processor.ErrorProcessEntity += processorSetLanguage_ErrorProcessEntity;
								_processor.Progress += processorSetLanguage_Progress;

								_answer = _numberSubprocess == 1 ? _processor.ProcessSynchronously(_infosNoLanguage, SetLanguage)
																	: _processor.Process(_infosNoLanguage, SetLanguage);
								_processor.ErrorProcessEntity -= processorSetLanguage_ErrorProcessEntity;
								_processor.Progress -= processorSetLanguage_Progress;
							}

							_stopwatch.Stop();
							_tiempo = string.Format("{0} Ticks", _stopwatch.Elapsed.Ticks);
						}
					}
				}
				catch (Exception _ex)
				{
					_answer.theresError = true;
					_answer.error = Utility.GetError(_ex, this.GetType());
				}
			}
			return _answer;
		}
コード例 #3
0
        private void Form1_Load(object sender, EventArgs e)
        {
            languageIdentificationUtility = new LanguageIdentificationUtility();
            languageIdentificationUtility.ProgressCountExistingStrings += languageIdentificationUtility_ProgresoContarCombinacionesExistentes;
            languageIdentificationUtility.ProgressCalculateProbabilitiesChangeState += languageIdentificationUtility_ProgresoCalcularProbabilidadesCambioEstado;
            languageIdentificationUtility.ProgressCalculateProbabilitiesInitialState += languageIdentificationUtility_ProgresoCalcularProbabilidadesEstadoInicial;

            workerCreateLanguageIdentificationModel = new BackgroundWorker() { WorkerSupportsCancellation = true };
            workerCreateLanguageIdentificationModel.DoWork += workerCreateLanguageIdentificationModel_DoWork;
            workerCreateLanguageIdentificationModel.RunWorkerCompleted += workerCreateLanguageIdentificationModel_RunWorkerCompleted;

            groupingUtility = new GroupingUtility();

            appState = enumAppState.showing;

            btnOWL_Click(null, null);
        }