예제 #1
0
        public static ConcurrentFactory GetConcurrentFactory()
        {
            var f = _ConcurrentFactory;

            if (f == null)
            {
                lock (_SyncLock)
                {
                    f = _ConcurrentFactory;
                    if (f == null)
                    {
                        var sentSplitterConfig = new SentSplitterConfig(Config.SENT_SPLITTER_RESOURCES_XML_FILENAME,
                                                                        Config.URL_DETECTOR_RESOURCES_XML_FILENAME);
                        var config = new NerProcessorConfig(Config.TOKENIZER_RESOURCES_XML_FILENAME,
                                                            Config.LANGUAGE_TYPE,
                                                            sentSplitterConfig)
                        {
                            ModelFilename    = Config.NER_MODEL_FILENAME,
                            TemplateFilename = Config.NER_TEMPLATE_FILENAME,
                        };
                        f = new ConcurrentFactory(config, Config.CONCURRENT_FACTORY_INSTANCE_COUNT);
                        _ConcurrentFactory = f;
                    }
                }
            }
            return(f);
        }
예제 #2
0
        public ConcurrentFactory(NerProcessorConfig config, int instanceCount)
        {
            if (instanceCount <= 0)
            {
                throw (new ArgumentException("instanceCount"));
            }
            if (config == null)
            {
                throw (new ArgumentNullException("config"));
            }

            _Semaphore          = new Semaphore(instanceCount, instanceCount);
            _stackNetProcessors = new ConcurrentStack <NerProcessor>();
            for (int i = 0; i < instanceCount; i++)
            {
                var proc = new NerProcessor(config);
                _stackNetProcessors.Push(proc);
            }
        }