internal void TrySetValueWithCoreferenceInfo(ICoreferenceInfo coreferenceInfo) { if (Entity != null) { var tuple = coreferenceInfo.TryGetMaster(Entity); TrySetValueWithCoreferenceInfo(tuple); } }
private string GetMasterName(XElement entity) { if (_coreferenceInfo != null) { var master = _coreferenceInfo.TryGetMaster(entity); if (master != null) { return(master.Item1); } } return(string.Empty); }
/// <summary> /// Проверка, что заданная сущность является темой /// </summary> /// <param name="entity">сущность</param> /// <param name="coreferenceInfo">информация о корефернтности</param> /// <returns>результат проверки</returns> public static bool IsTheme(XElement entity, ICoreferenceInfo coreferenceInfo) { bool result = false; if (entity.Name.IsEqual(UnitTextType.ENTITY)) { string type = entity.Attribute(BlockAttribute.TYPE); bool isNotTheme = entity.IsContainAttribute(BlockAttribute.NOT_THEME); isNotTheme = isNotTheme || !Enum.GetNames(typeof(EntityType)).Contains(type); isNotTheme = isNotTheme || (type.IsEqual(EntityType.Pronoun) && !entity.IsContainAttribute(BlockAttribute.LINK)); isNotTheme = isNotTheme || type.IsEqual(EntityType.Adverb) || type.IsEqual(EntityType.Homogeneous); isNotTheme = isNotTheme || (entity.Name.IsEqual(UnitTextType.CET) && !type.IsEqual(EntityType.Conjunction)); string masterName = string.Empty; XElement testEntity = entity; if (!isNotTheme) { if (coreferenceInfo != null) { var master = coreferenceInfo.TryGetMaster(entity); if (master != null) { testEntity = master.Item2; masterName = master.Item1; } } if (type.IsEqual(EntityType.PersonName)) { bool isContainLastName = testEntity.IsContainAttribute(BlockAttribute.LN); bool isContainFirstName = testEntity.IsContainAttribute(BlockAttribute.FN); bool isContainMiddleName = testEntity.IsContainAttribute(BlockAttribute.MN); bool isFullName = isContainLastName && (isContainFirstName || isContainMiddleName); isNotTheme |= !(isFullName || testEntity.IsContainAttribute(BlockAttribute.PROF) || testEntity.IsContainAttribute(BlockAttribute.PRE)); } } string theme = GetThemeName(entity, masterName); isNotTheme |= theme.IsEmpty() || (theme.Length > 256); //result = result || (type.IsEqual(EntityType.Date) && (entity.Attribute(BlockAttribute.VALUE) == "0000-00-00/0000-00-00")); isNotTheme |= type.IsEqual(EntityType.Adjective) || type.IsEqual(EntityType.ShortAdjective) || type.IsEqual(EntityType.Comparative) || type.IsEqual(EntityType.Superlative); result = !isNotTheme; } return(result); }
public OpinionMiningTuple(SubjectEssence subject, ObjectEssence @object, XElement sentence , int sentenceNumber, FilterBySynonyms filterBySynonyms, ICoreferenceInfo coreferenceInfo) { var tempSentence = Initialize(subject, sentence, sentenceNumber, filterBySynonyms, coreferenceInfo); @object.ThrowIfNull("object"); #region [.coreference-info.] var tuple = coreferenceInfo.TryGetMaster(@object.Entity); #endregion #region [.Find Object-entity & mark him as-inquiry.] var objectEntityInCopy = tempSentence.DescendantsAndSelf().FirstOrDefault(d => ObjectEntityEqualityComparer.Instance.Equals(d, @object.AnaphoriaAndEntityTuple.Entity)); if (objectEntityInCopy == null) { throw (new ArgumentException("Object-Entity not found in his Sentence. " + ("object.Entity: " + @object.AnaphoriaAndEntityTuple.Entity.ToString().InSingleQuote() + ", sentence: " + sentence.ToString().InSingleQuote()).InBrackets())); } objectEntityInCopy.MarkAsInquiry(); var objectAnaphoriaInCopy = default(XElement); if (@object.AnaphoriaAndEntityTuple.Anaphoria != null) { objectAnaphoriaInCopy = tempSentence.DescendantsAndSelf().FirstOrDefault(d => ObjectEntityEqualityComparer.Instance.Equals(d, @object.AnaphoriaAndEntityTuple.Anaphoria)); if (objectAnaphoriaInCopy == null) { throw (new ArgumentException("Object-Anaphoria-Entity not found in his Sentence. " + ("object.Entity: " + @object.AnaphoriaAndEntityTuple.Anaphoria.ToString().InSingleQuote() + ", sentence: " + sentence.ToString().InSingleQuote()).InBrackets())); } } @object = new ObjectEssence(new SubjectAndAnaphoriaEntityTuple(objectEntityInCopy, objectAnaphoriaInCopy), @object.IsSubjectIndeed); SentenceText = tempSentence.ToString(); tempSentence = null; #endregion Object = @object; #region [.coreference-info.] Object.TrySetValueWithCoreferenceInfo(tuple); #endregion }