Esempio n. 1
0
        public ConcurrentFactory(PosTaggerProcessorConfig config,
                                 IMorphoModel morphoModel,
                                 MorphoAmbiguityResolverModel morphoAmbiguityModel,
                                 int instanceCount)
        {
            if (instanceCount <= 0)
            {
                throw (new ArgumentException("instanceCount"));
            }
            if (config == null)
            {
                throw (new ArgumentNullException("config"));
            }
            if (morphoModel == null)
            {
                throw (new ArgumentNullException("morphoModel"));
            }
            if (morphoAmbiguityModel == null)
            {
                throw (new ArgumentNullException("morphoAmbiguityModel"));
            }

            _Semaphore = new Semaphore(instanceCount, instanceCount);
            _Stack     = new ConcurrentStack <PosTaggerProcessor>();
            for (int i = 0; i < instanceCount; i++)
            {
                _Stack.Push(new PosTaggerProcessor(config, morphoModel, morphoAmbiguityModel));
            }
        }
Esempio n. 2
0
            public static (PosTaggerProcessorConfig config, SentSplitterConfig sentSplitterConfig) CreatePosTaggerProcessorConfig()
            {
                var sentSplitterConfig = new SentSplitterConfig(Config.SENT_SPLITTER_RESOURCES_XML_FILENAME, Config.URL_DETECTOR_RESOURCES_XML_FILENAME);
                var config             = new PosTaggerProcessorConfig(Config.TOKENIZER_RESOURCES_XML_FILENAME, Config.POSTAGGER_RESOURCES_XML_FILENAME, LanguageTypeEnum.Ru, sentSplitterConfig)
                {
                    ModelFilename    = Config.POSTAGGER_MODEL_FILENAME,
                    TemplateFilename = Config.POSTAGGER_TEMPLATE_FILENAME,
                };

                return(config, sentSplitterConfig);
            }
Esempio n. 3
0
        private static void CheckConfig(PosTaggerProcessorConfig config, IMorphoModel morphoModel, MorphoAmbiguityResolverModel morphoAmbiguityModel)
        {
            morphoModel.ThrowIfNull("morphoModel");

            config.ThrowIfNull("config");
            config.Model.ThrowIfNull("Model");
            config.TokenizerConfig.ThrowIfNull("TokenizerConfig");
            config.ModelFilename.ThrowIfNullOrWhiteSpace("ModelFilename");
            config.TemplateFilename.ThrowIfNullOrWhiteSpace("TemplateFilename");

            morphoAmbiguityModel.ThrowIfNull("morphoAmbiguityModel");
        }
Esempio n. 4
0
        public PosTaggerProcessor(PosTaggerProcessorConfig config, IMorphoModel morphoModel, MorphoAmbiguityResolverModel morphoAmbiguityModel)
        {
            CheckConfig(config, morphoModel, morphoAmbiguityModel);

            _Tokenizer                      = new Tokenizer(config.TokenizerConfig);
            _Words                          = new List <word_t>(DEFAULT_WORDSLIST_CAPACITY);
            _PosTaggerScriber               = PosTaggerScriber.Create(config.ModelFilename, config.TemplateFilename);
            _PosTaggerPreMerging            = new PosTaggerPreMerging(config.Model);
            _PosTaggerMorphoAnalyzer        = new PosTaggerMorphoAnalyzer(morphoModel, morphoAmbiguityModel);
            _ProcessSentCallback_1_Delegate = new Tokenizer.ProcessSentCallbackDelegate(ProcessSentCallback_1);
            _ProcessSentCallback_2_Delegate = new Tokenizer.ProcessSentCallbackDelegate(ProcessSentCallback_2);
        }