public static IMorphoModel Create(MorphoModelConfig config) { config.ThrowIfNull("config"); switch (config.TreeDictionaryType) { case MorphoModelConfig.TreeDictionaryTypeEnum.Classic: case MorphoModelConfig.TreeDictionaryTypeEnum.FastMemPlenty: { var model = new MorphoModel(config); //GC.Collect( GC.MaxGeneration, GCCollectionMode.Forced ); return(model); } case MorphoModelConfig.TreeDictionaryTypeEnum.Native: { var model = new MorphoModelNative(config); //GC.Collect( GC.MaxGeneration, GCCollectionMode.Forced ); return(model); } default: throw (new ArgumentException(config.TreeDictionaryType.ToString())); } }
private static void CheckConfig(MorphoModelConfig config) { config.ThrowIfNull("config"); config.MorphoTypesFilenames.ThrowIfNullOrWhiteSpaceAnyElement("config.MorphoTypesFilenames"); config.ProperNamesFilenames.ThrowIfNullOrWhiteSpaceAnyElement("config.ProperNamesFilenames"); config.CommonFilenames.ThrowIfNullOrWhiteSpaceAnyElement("config.CommonFilenames"); }
/// инициализация морфо-модели /// информация для инициализации морфо-модели private void Initialization(MorphoModelConfig config) { #region [.init field's.] base.Initialization(); if (config.ModelLoadingErrorCallback == null) { _ModelLoadingErrorCallback = (s1, s2) => { }; } else { _ModelLoadingErrorCallback = config.ModelLoadingErrorCallback; } _MorphoTypesDictionary = new Dictionary <string, MorphoType>(); _MorphoAttributeList = new MorphoAttributeList(); _PartOfSpeechList = new PartOfSpeechList(); _PartOfSpeechStringDictionary = Enum.GetValues(typeof(PartOfSpeechEnum)) .Cast <PartOfSpeechEnum>() .ToDictionary(pos => pos, pos => pos.ToString()); #endregion foreach (var morphoTypesFilename in config.MorphoTypesFilenames) { var filename = GetFullFilename(config.BaseDirectory, morphoTypesFilename); ReadMorphoTypes(filename); } foreach (var properNamesFilename in config.ProperNamesFilenames) { var filename = GetFullFilename(config.BaseDirectory, properNamesFilename); ReadWords(filename, MorphoAttributeEnum.Proper); } foreach (var commonFilename in config.CommonFilenames) { var filename = GetFullFilename(config.BaseDirectory, commonFilename); ReadWords(filename, MorphoAttributeEnum.Common); } #region [.uninit field's.] base.UnInitialization(); _ModelLoadingErrorCallback = null; _MorphoTypesDictionary = null; _MorphoAttributeList = null; _PartOfSpeechList = null; _PartOfSpeechStringDictionary = null; #endregion GC.Collect(GC.MaxGeneration, GCCollectionMode.Forced); }
public MorphoModel(MorphoModelConfig config) : base(config) { switch (config.TreeDictionaryType) { case MorphoModelConfig.TreeDictionaryTypeEnum.Classic: _TreeDictionary = new TreeDictionaryClassic(); break; case MorphoModelConfig.TreeDictionaryTypeEnum.FastMemPlenty: _TreeDictionary = new TreeDictionaryFastMemPlenty(); break; default: throw (new ArgumentException(config.TreeDictionaryType.ToString())); } Initialization(config); }
protected MorphoModelBase(MorphoModelConfig config) { CheckConfig(config); }