Esempio n. 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);
            }
Esempio n. 2
0
 private static void CheckConfig(NerProcessorConfig config)
 {
     config.ThrowIfNull("config");
     config.ModelFilename.ThrowIfNullOrWhiteSpace("ModelFilename");
     config.TemplateFilename.ThrowIfNullOrWhiteSpace("TemplateFilename");
     config.TokenizerConfig.ThrowIfNull("TokenizerConfig");
 }
Esempio n. 3
0
        public NerProcessor(NerProcessorConfig config)
        {
            CheckConfig(config);

            _NerScriber = NerScriber.Create(config.ModelFilename, config.TemplateFilename);
            _Tokenizer  = new Tokenizer(config.TokenizerConfig);
            _Words      = new List <word_t>(DEFAULT_WORDSLIST_CAPACITY);
        }
Esempio n. 4
0
        private static NerProcessorConfig CreateNerProcessorConfig()
        {
            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,
            };

            return(config);
        }
Esempio n. 5
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);
            _Stack     = new ConcurrentStack <NerProcessor>();
            for (int i = 0; i < instanceCount; i++)
            {
                _Stack.Push(new NerProcessor(config));
            }
        }