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); }
private static void CheckConfig(NerProcessorConfig config) { config.ThrowIfNull("config"); config.ModelFilename.ThrowIfNullOrWhiteSpace("ModelFilename"); config.TemplateFilename.ThrowIfNullOrWhiteSpace("TemplateFilename"); config.TokenizerConfig.ThrowIfNull("TokenizerConfig"); }
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); }
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); }
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)); } }