internal static void BeginLoad() { const int DEFAULT_CAPACITY = 11; //37; BaseMorphoFormNative.BeginLoad(); MorphoTypeNative.BeginLoad(); tempBufferPairs = new PairSet(DEFAULT_CAPACITY); /*---tempBufferPairs = new Dictionary< pair_t, pair_t >( default(pair_t_IEqualityComparer) );*/ }
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(); }
public Pair(BaseMorphoFormNative baseMorphoForm, MorphoAttributeEnum morphoAttribute) { BaseMorphoForm = baseMorphoForm; MorphoAttribute = morphoAttribute; }
/// добавление слова и всех его форм в словарь /// 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') { // sort & merge after insert - may be faster/better (30.04.2014)!!!! //* 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++; } }
internal static void EndLoad() { BaseMorphoFormNative.EndLoad(); MorphoTypeNative.EndLoad(); tempBufferPairs = null; }