Exemple #1
0
        /*public ManyLanguageDetectorModelConfig GetManyLanguageDetectorModelConfig()
         * {
         *  var modelConfig = new ManyLanguageDetectorModelConfig() { ModelDictionaryCapacity = ML_MODEL_DICTIONARY_CAPACITY };
         *  foreach ( var lang in Languages.All )
         *  {
         *      var key = (lang == Language.RU) ? "RU-ML" : lang.ToString();
         *      var modelFilename = ConfigurationManager.AppSettings[ key ];
         *
         *      if ( !string.IsNullOrWhiteSpace( modelFilename ) )
         *      {
         *          modelFilename = Path.Combine( LANGUAGE_MODELS_FOLDER, modelFilename );
         *
         *          var lconfig = new LanguageConfigAdv( lang, modelFilename );
         *          modelConfig.AddLanguageConfig( lconfig );
         *      }
         *  };
         *  return (modelConfig);
         * }*/

        #region [.RussianLanguage.]
        public RDetectorConfig GetRDetectorConfig()
        {
            var config = new RDetectorConfig()
            {
                UrlDetectorModel       = new UrlDetectorModel(URL_DETECTOR_RESOURCES_XML_FILENAME),
                CyrillicLettersPercent = RU_CYRILLIC_LETTERS_PERCENT,
                Threshold = RU_THRESHOLD,
            };

            return(config);
        }
Exemple #2
0
        public ConcurrentFactory(RDetectorConfig config, IRModel model, int instanceCount)
        {
            if (instanceCount <= 0)
            {
                throw (new ArgumentException("instanceCount"));
            }
            if (config == null)
            {
                throw (new ArgumentNullException("config"));
            }
            if (model == null)
            {
                throw (new ArgumentNullException("model"));
            }

            _InstanceCount = instanceCount;
            _Semaphore     = new Semaphore(_InstanceCount, _InstanceCount);
            _Stack         = new ConcurrentStack <ILanguageDetector>();
            for (int i = 0; i < _InstanceCount; i++)
            {
                _Stack.Push(new RDetector(config, model));
            }
            //_IRModel = model;
        }