예제 #1
0
        private bool Init(List <word_t> words)
        {
            if (words.Count == 0)
            {
                return(false);
            }

            //_Words = words;
            var wordsCount = words.Count;

            if (_PinnedWordsBufferSize < wordsCount)
            {
                ReAllocPinnedWordsBuffer(wordsCount);
            }
            for (var i = 0; i < wordsCount; i++)
            {
                var           word     = words[i];
                var           gcHandle = GCHandle.Alloc(word.valueUpper, GCHandleType.Pinned);
                var           basePtr  = (char *)gcHandle.AddrOfPinnedObject().ToPointer();
                PinnedWord_t *pw       = _PinnedWordsBufferPtrBase + i;
                pw->basePtr  = basePtr;
                pw->gcHandle = gcHandle;

                pw->posTaggerInputType     = word.posTaggerInputType;
                pw->posTaggerExtraWordType = word.posTaggerExtraWordType;
                pw->length = word.valueUpper.Length;
            }

            return(true);
        }
예제 #2
0
        private bool Init(IList <word_t> words)
        {
            if (words.Count == 0)
            {
                return(false);
            }

            //_Words = words;
            var wordsCount = words.Count;

            if (_PinnedWordsBufferSize < wordsCount)
            {
                ReAllocPinnedWordsBuffer(wordsCount);
            }
            for (var i = 0; i < wordsCount; i++)
            {
                PinnedWord_t *pw         = _PinnedWordsBufferPtrBase + i;
                var           word       = words[i];
                var           valueUpper = (word.posTaggerLastValueUpperInNumeralChain == null)
                                          ? word.valueUpper : word.posTaggerLastValueUpperInNumeralChain;
                var gcHandle = GCHandle.Alloc(valueUpper, GCHandleType.Pinned);
                var basePtr  = (char *)gcHandle.AddrOfPinnedObject().ToPointer();
                pw->basePtr             = basePtr;
                pw->gcHandle            = gcHandle;
                pw->posTaggerInputType  = word.posTaggerInputType;
                pw->posTaggerOutputType = word.posTaggerOutputType;
                pw->morphoAttribute     = word.morphology.MorphoAttribute;
                pw->length = valueUpper.Length;
            }

            return(true);
        }
예제 #3
0
        private bool Init(IList <word_t> words)
        {
            if (words.Count == 0)
            {
                return(false);
            }

            //_Words = words;
            var wordsCount = words.Count;

            if (_PinnedWordsBufferSize < wordsCount)
            {
                ReAllocPinnedWordsBuffer(wordsCount);
            }
            for (var i = 0; i < wordsCount; i++)
            {
                var           word = words[i];
                PinnedWord_t *pw   = _PinnedWordsBufferPtrBase + i;

                pw->posTaggerInputType  = word.posTaggerInputType;
                pw->posTaggerOutputType = word.posTaggerOutputType;
                pw->morphoAttribute     = word.morphology.MorphoAttribute;
            }

            return(true);
        }
예제 #4
0
 private void DisposePinnedWordsBuffer()
 {
     if (_PinnedWordsBufferPtrBase != null)
     {
         _PinnedWordsBufferGCHandle.Free();
         _PinnedWordsBufferPtrBase = null;
     }
 }
예제 #5
0
        private void ReAllocPinnedWordsBuffer(int newBufferSize)
        {
            DisposePinnedWordsBuffer();

            _PinnedWordsBufferSize = newBufferSize;
            var pinnedWordsBuffer = new PinnedWord_t[_PinnedWordsBufferSize];

            _PinnedWordsBufferGCHandle = GCHandle.Alloc(pinnedWordsBuffer, GCHandleType.Pinned);
            _PinnedWordsBufferPtrBase  = (PinnedWord_t *)_PinnedWordsBufferGCHandle.AddrOfPinnedObject().ToPointer();
        }