Example #1
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 #2
0
 internal static void EndLoad()
 {
     BaseMorphoFormNative.EndLoad();
     MorphoTypeNative.EndLoad();
     tempBufferPairs = null;
 }