コード例 #1
0
 private void DisposeNativeResources()
 {
     _TreeDictionary = null;
     TreeDictionaryNative.EndLoad();
     _LOWER_INVARIANT_MAP_GCHandle.Free(); _LOWER_INVARIANT_MAP = null;
     _ENDING_LOWER_BUFFER_GCHandle.Free(); _ENDING_LOWER_BUFFER = null;
     _ENDING_UPPER_BUFFER_GCHandle.Free(); _ENDING_UPPER_BUFFER = null;
     _EndingDictionary          = null;
     _ModelLoadingErrorCallback = null;
     _MorphoTypesDictionary     = null;
     _MorphoAttributeList.Dispose(); _MorphoAttributeList = null;
     _PartOfSpeechList = null;
     _PartOfSpeechToNativeStringMapper.Dispose(); _PartOfSpeechToNativeStringMapper = null;
     _MorphoAttributePairs_Buffer = null;
     _EnumParserMorphoAttribute   = null;
     _EnumParserPartOfSpeech      = null;
     _Config = default;
 }
コード例 #2
0
            public ModelLoader(MorphoModelConfig config, TreeDictionaryNative treeDictionary)
            {
                const int ENDING_DICTIONARY_CAPACITY           = 350003;
                const int MORPHOTYPES_DICTIONARY_CAPACITY      = 4001;
                const int MORPHOATTRIBUTEPAIRS_BUFFER_CAPACITY = 100;

                _TreeDictionary = treeDictionary;
                TreeDictionaryNative.BeginLoad();
                _Config                           = config;
                _EndingDictionary                 = new Dictionary <IntPtr, IntPtr>(ENDING_DICTIONARY_CAPACITY, default(CharIntPtr_IEqualityComparer));
                _MorphoTypesDictionary            = new Dictionary <IntPtr, MorphoTypeNative>(MORPHOTYPES_DICTIONARY_CAPACITY, default(CharIntPtr_IEqualityComparer));
                _MorphoAttributeList              = new MorphoAttributeList();
                _PartOfSpeechList                 = new PartOfSpeechList();
                _PartOfSpeechToNativeStringMapper = new PartOfSpeechToNativeStringMapper();
                _MorphoAttributePairs_Buffer      = new List <MorphoAttributePair>(MORPHOATTRIBUTEPAIRS_BUFFER_CAPACITY);
                _EnumParserMorphoAttribute        = new EnumParser <MorphoAttributeEnum>();
                _EnumParserPartOfSpeech           = new EnumParser <PartOfSpeechEnum>();
                _EndingDictionary.Add(_EMPTY_STRING, _EMPTY_STRING);
                #region ModelLoadingErrorCallback
                if (config.ModelLoadingErrorCallback == null)
                {
                    _ModelLoadingErrorCallback = (s1, s2) => { };
                }
                else
                {
                    _ModelLoadingErrorCallback = config.ModelLoadingErrorCallback;
                }
                #endregion
                #region LOWER_INVARIANT_MAP
                var lower_invariant_map = Xlat.Create_LOWER_INVARIANT_MAP();
                _LOWER_INVARIANT_MAP_GCHandle = GCHandle.Alloc(lower_invariant_map, GCHandleType.Pinned);
                _LOWER_INVARIANT_MAP          = (char *)_LOWER_INVARIANT_MAP_GCHandle.AddrOfPinnedObject().ToPointer();
                #endregion
                #region ENDING_LOWER_BUFFER
                var ending_lower_buffer = new char[ENDING_BUFFER_SIZE];
                _ENDING_LOWER_BUFFER_GCHandle = GCHandle.Alloc(ending_lower_buffer, GCHandleType.Pinned);
                _ENDING_LOWER_BUFFER          = (char *)_ENDING_LOWER_BUFFER_GCHandle.AddrOfPinnedObject().ToPointer();
                #endregion
                #region ENDING_UPPER_BUFFER
                var ending_upper_buffer = new char[ENDING_BUFFER_SIZE];
                _ENDING_UPPER_BUFFER_GCHandle = GCHandle.Alloc(ending_upper_buffer, GCHandleType.Pinned);
                _ENDING_UPPER_BUFFER          = (char *)_ENDING_UPPER_BUFFER_GCHandle.AddrOfPinnedObject().ToPointer();
                #endregion
            }