/// <summary> /// Создание объекта подпредложения /// </summary> /// <param name="parentSentence">родительское предложение</param> /// <param name="textSentence">текстовое предложение</param> /// <param name="entities">список сущностей предложения</param> /// <param name="contentIndexes">индексы контентов в предложении</param> /// <returns>объект подпредложения</returns> private SubSentence CreateSubSentenceObject( Sentence parentSentence, TextParsing.Sentence textSentence, IEnumerable <Entity> entities, IEnumerable <int> contentIndexes) { var result = new SubSentence(SubSentenceType.Default, 0) { ParentObject = parentSentence }; var units = GetSubSentenceUnits(result, textSentence, entities); var subSentences = GetChildContentSubSentences(contentIndexes, units, parentSentence); result.SetUnits(units); result.AppendSubSentences(subSentences); return(result); }
/// <summary> /// Создание простого подпредложения из xml-элемента /// </summary> /// <param name="subSentence">xml-элемент</param> /// <param name="language">язык предложения</param> /// <returns>простое подпредложение</returns> private static void SimpleSubSentenceFromXElement(SubSentence subSentence, XElement subSentenceXML, string language) { List <UnitTextBase> units = new List <UnitTextBase>(); List <SubSentence> subSentences = new List <SubSentence>(); foreach (XElement element in subSentenceXML.Elements()) { if (element.IsName(UnitTextType.U)) { units.Add(UnmarkedFromXElement(element)); } else if (element.IsName(UnitTextType.SUB_SENT)) { subSentences.Add(SubSentenceFromXElement(element, language)); } else if (IsEntity(element)) { units.Add(EntityFromXElement(element, language, subSentence.Type)); } #region [.defense.] else { throw new InvalidOperationException("unknown xml element"); } #endregion } if (subSentenceXML.IsContainAttribute(RDF.Attribute.Subject)) { subSentence.Subject = _sentenceEntities[subSentenceXML.GetAttributeValue(RDF.Attribute.Subject)]; } if (subSentenceXML.IsContainAttribute(RDF.Attribute.IsPassiveSubject)) { subSentence.IsPassiveSubject = bool.Parse(subSentenceXML.GetAttributeValue(RDF.Attribute.IsPassiveSubject)); } subSentence.AppendSubSentences(subSentences); subSentence.SetUnits(units); }