/// <summary> /// Создание новой сущности с типом союз /// </summary> /// <param name="text">текст</param> /// <param name="conjunction">союз</param> /// <param name="lastUnit">последний юнит союза</param> /// <returns>новая сущность</returns> private Entity CreateNewConjunctionEntity(string text, Conjunction conjunction, UnitTextBase lastUnit) { var info = new ConjunctionEntityInfo(conjunction.Type) { Value = conjunction.Value }; if (lastUnit.IsEntity && (conjunction.Value == lastUnit.Text)) { Entity conjunctionEntity = (Entity)lastUnit; info.Morpho = conjunctionEntity.EntityInfo.Morpho; info.Value = conjunctionEntity.EntityInfo.Value; } return(new Entity(text, conjunction.StartPosition, info)); }
protected override IEnumerable <UnitTextBase> TransformUnitsInSequence(IList <UnitTextBase> units) { List <UnitTextBase> result = new List <UnitTextBase>(); var conjunctionList = DictionaryResource.SelectConjunctions(units); int currentConjunctionIndex = 0; Conjunction currentConjunction = GetCurrentConjunction(conjunctionList, currentConjunctionIndex); ConjunctionBuilder builder = new ConjunctionBuilder(); foreach (UnitTextBase unit in units) { int position = 0; while (currentConjunction != null) { if ((currentConjunction.StartPosition < unit.PositionInfo.End) && (builder.Conjunction == null)) /// начало союза { builder.Conjunction = currentConjunction; position = builder.AddLeftConjunctionBorder(result, unit, position); } if (currentConjunction.EndPosition <= unit.PositionInfo.End) /// конец союза { position = builder.AddAndClearConjunction(result, unit, position); currentConjunction = GetCurrentConjunction(conjunctionList, ++currentConjunctionIndex); continue; } if (builder.Conjunction != null) { position = builder.AppendConjunctionPart(unit.Text, position); } break; } AddUnmarkedPart(result, unit, position); } return(result); }
/// <summary> /// Очистка внутренннего состояния /// </summary> public void Clear() { _conjunction = null; }