/// добавление части слова /// wordPart - оставшася часть слова /// pBase - базовая форма unsafe private void AddWordPart(char *wordPart, BaseMorphoForm baseMorphoForm) { var first_char = *wordPart; if (first_char == '\0') /// сохранение характеристик { var tuples = from morphoForm in baseMorphoForm.MorphoForms select new { ending = morphoForm.EndingUpper, baseMorphoForm, morphoForm, }; var dict = new Dictionary <string, LinkedList <Pair> >(); foreach (var t in tuples) { if (!dict.TryGetValue(t.ending, out LinkedList <Pair> pairs)) { pairs = new LinkedList <Pair>(); dict.Add(t.ending, pairs); } pairs.AddLast(new Pair(t.baseMorphoForm, MorphoAttributePair.GetMorphoAttribute(t.baseMorphoForm, t.morphoForm))); } if (_EndingDictionary == null) { _EndingDictionary = new Dictionary <string, Pair[]>(); } foreach (var p in dict) { if (!_EndingDictionary.TryGetValue(p.Key, out Pair[] pairs))
internal void SetMorphoForms(List <MorphoFormNative> morphoForms) { if (morphoForms.Count != 0) { LinkedList <MorphoAttributeEnum> morphoAttributes = null; for (int i = 0, len = morphoForms.Count; i < len; i++) { var morphoForm = morphoForms[i]; tempBufferHS.Add((IntPtr)morphoForm.Ending); var endingUpperPtr = (IntPtr)morphoForm.EndingUpper; if (!tempBufferDict.TryGetValue(endingUpperPtr, ref morphoAttributes)) { morphoAttributes = PopLinkedList(); tempBufferDict.Add(endingUpperPtr, morphoAttributes); } var morphoAttribute = MorphoAttributePair.GetMorphoAttribute(this, morphoForm); morphoAttributes.AddLast(morphoAttribute); } _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(); _morphoFormEndingUpperAndMorphoAttributes = new MorphoFormEndingUpperAndMorphoAttribute[tempBufferDict.Count]; var it2 = tempBufferDict.GetEnumerator(); for (var i = 0; it2.MoveNext(); i++) { _morphoFormEndingUpperAndMorphoAttributes[i] = new MorphoFormEndingUpperAndMorphoAttribute(it2.Current_IntPtr, it2.Current_Value); PushLinkedList(it2.Current_Value); } tempBufferDict.Clear(); } else { _morphoFormEndings = EMPTY_ENDINGS; _morphoFormEndingUpperAndMorphoAttributes = EMPTY_MFUEMA; } }
/// поиск слова в слоте /// wordPart - оставшаяся часть слова /// pSlot - слот /// letterIndex - индекс буквы unsafe private void FillWordFormMorphologies_Core(char *wordPart, int wordPartLength, int fullWordLength, List <WordFormMorphology> result, WordFormMorphologyModeEnum wordFormMorphologyMode) { if (_BaseMorphoForms == null) { return; } foreach (var baseMorphoForm in _BaseMorphoForms) { int baseLength = baseMorphoForm.Base.Length; if ((fullWordLength < baseLength) || (baseLength + baseMorphoForm.MorphoType.MaxEndingLength < fullWordLength) ) { continue; } foreach (var morphoForm in baseMorphoForm.MorphoType.MorphoForms) { var endingLength = morphoForm.EndingUpper.Length; if (baseLength + endingLength != fullWordLength) { continue; } if (endingLength != wordPartLength) { continue; } if (wordPartLength == 0) { ; } else if (!StringsHelper.IsEqual(morphoForm.EndingUpper, wordPart, wordPartLength)) { continue; } switch (wordFormMorphologyMode) { case WordFormMorphologyModeEnum.Default: { var wfmi = new WordFormMorphology(baseMorphoForm, MorphoAttributePair.GetMorphoAttribute(baseMorphoForm, morphoForm)); result.Add(wfmi); } break; case WordFormMorphologyModeEnum.StartsWithLowerLetter: { fixed(char *normalForm_ptr = baseMorphoForm.NormalForm) { var first_char = *normalForm_ptr; if ((first_char != '\0') && *(XlatUnsafe.Inst._UPPER_INVARIANT_MAP + first_char) == first_char) { continue; } } var wfmi = new WordFormMorphology(baseMorphoForm, MorphoAttributePair.GetMorphoAttribute(baseMorphoForm, morphoForm)); result.Add(wfmi); } break; case WordFormMorphologyModeEnum.StartsWithUpperLetter: { fixed(char *normalForm_ptr = baseMorphoForm.NormalForm) { var first_char = *normalForm_ptr; if ((first_char != '\0') && *(XlatUnsafe.Inst._UPPER_INVARIANT_MAP + first_char) != first_char) { continue; } } var wfmi = new WordFormMorphology(baseMorphoForm, MorphoAttributePair.GetMorphoAttribute(baseMorphoForm, morphoForm)); result.Add(wfmi); } break; case WordFormMorphologyModeEnum.FirstStartsWithUpperAfterLowerLetter: case WordFormMorphologyModeEnum.FirstStartsWithLowerAfterUpperLetter: { throw new NotImplementedException(); } } } } }