Example #1
0
        internal static void BeginLoad()
        {
            const int DEFAULT_CAPACITY = 11;

            BaseMorphoFormNative.BeginLoad();
            MorphoTypeNative.BeginLoad();

            tempBufferPairs = new PairSet(DEFAULT_CAPACITY);
        }
        public void AppendMorphoFormEndings(BaseMorphoFormNative other)
        {
            Debug.Assert(_morphoFormEndings[0] == other._morphoFormEndings[0],
                         "_MorphoFormEndings[ 0 ] != baseMorphoForms._MorphoFormEndings[ 0 ]");

            //select longest array of morpho-form-endings
            char *[] first, second;
            if (_morphoFormEndings.Length < other._morphoFormEndings.Length)
            {
                first  = other._morphoFormEndings;
                second = _morphoFormEndings;
            }
            else
            {
                first  = _morphoFormEndings;
                second = other._morphoFormEndings;
            }

            fixed(char **morphoFormEndingsBase = first)
            {
                for (int i = 0, len = first.Length; i < len; i++)
                {
                    tempBufferHS.Add(new IntPtr(*(morphoFormEndingsBase + i)));
                }
            }

            //store curreent count in 'tempBufferHS'
            var count = tempBufferHS.Count;

            fixed(char **morphoFormEndingsBase = second)
            {
                for (int i = 0, len = second.Length; i < len; i++)
                {
                    tempBufferHS.Add(new IntPtr(*(morphoFormEndingsBase + i)));
                }
            }

            //if count of 'tempBufferHS' not changed, then [_MorphoFormEndings] & [other._MorphoFormEndings] are equals
            if (count != tempBufferHS.Count)
            {
                _morphoFormEndings = new char *[tempBufferHS.Count];
                fixed(char **morphoFormEndingsBase = _morphoFormEndings)
                {
                    var it = tempBufferHS.GetEnumerator();

                    for (var i = 0; it.MoveNext(); i++)
                    {
                        *(morphoFormEndingsBase + i) = (char *)it.Current;
                    }
                }
            }
            tempBufferHS.Clear();
        }
Example #3
0
        /// добавление слова и всех его форм в словарь
        /// wordBase   - marshaled-слово
        /// morphoType - морфотип
        /// nounType   - тип сущетсвительного
        public void AddWord(char *wordBase, MorphoTypeNative morphoType, ref MorphoAttributePair?nounType)
        {
            var baseMorphoForm = new BaseMorphoFormNative(wordBase, morphoType);

            for (TreeDictionaryNative _this = this, _this_next; ;)
            {
                var first_char = _UPPER_INVARIANT_MAP[*wordBase];

                #region [.сохранение характеристик if end-of-word.]
                if (first_char == '\0')
                {
                    var len = morphoType.MorphoFormEndingUpperAndMorphoAttributes.Length;
                    SortedListIntPtrKey <Pair[]> .Tuple[] tuples;
                    int tuplesOffset;
                    if (!_this.HasEndings())
                    {
                        tuplesOffset = 0;
                        tuples       = new SortedListIntPtrKey <Pair[]> .Tuple[len];
                    }
                    else
                    {
                        tuplesOffset = _this._endings.Count;
                        tuples       = new SortedListIntPtrKey <Pair[]> .Tuple[len + tuplesOffset];

                        for (int i = 0; i < tuplesOffset; i++)
                        {
                            tuples[i] = _this._endings.Array[i];
                        }
                    }

                    for (int i = 0; i < len; i++)
                    {
                        var p = morphoType.MorphoFormEndingUpperAndMorphoAttributes[i];
                        var pairs_current_len = p.MorphoAttributes.Length;
                        var pairs_current     = new Pair[pairs_current_len];
                        for (int j = 0; j < pairs_current_len; j++)
                        {
                            var ma = MorphoAttributePair.GetMorphoAttribute(morphoType, p.MorphoAttributes[j], ref nounType);
                            pairs_current[j] = new Pair(baseMorphoForm, ma);
                        }
                        tuples[i + tuplesOffset] = new SortedListIntPtrKey <Pair[]> .Tuple()
                        {
                            Key = p.EndingUpper, Value = pairs_current
                        };
                    }

                    ShellSortAscending(tuples);
                    MergeSorted(ref tuples);
                    _this._endings.SetArray(tuples);
                    return;
                }
                #endregion

                if (!_this._slots.TryGetValue(first_char, out _this_next))
                {
                    /// добавление новой буквы
                    _this_next = new TreeDictionaryNative();
                    _this._slots.Add(first_char, _this_next);
                }
                _this = _this_next;
                wordBase++;
            }
        }
Example #4
0
 internal static void EndLoad()
 {
     BaseMorphoFormNative.EndLoad();
     MorphoTypeNative.EndLoad();
     tempBufferPairs = null;
 }
Example #5
0
 public Pair(BaseMorphoFormNative baseMorphoForm, MorphoAttributeEnum morphoAttribute)
 {
     BaseMorphoForm  = baseMorphoForm;
     MorphoAttribute = morphoAttribute;
 }