public static InquiriesSynonymsInfo ToInquiriesSynonymsInfo(this string value) { var ip = new TonalityMarkingInputParams("DUMMY") { InquiriesSynonyms = new[] { value }.ToList(), }; var isi = new InquiriesSynonymsInfo(ip.InquiriesSynonyms); return(isi); }
private static IEnumerable <OpinionMiningTuple> ExecuteInternal( XDocument xdocument, InputParamsBase inputParams, ICoreferenceInfo coreferenceInfo) { var language = Config.ThemesManager[inputParams.ThemeType].LanguagesManager[inputParams.LanguageType]; int sentGlobalNumber = 0; int directAndIndirectSpeechGlobalNumber = 0; var opinionMiningTuples = new List <OpinionMiningTuple>(); var objectAllocateMethod = inputParams.ObjectAllocateMethod; var isi = new InquiriesSynonymsInfo(inputParams.InquiriesSynonyms); #region [.Direct-speech & Indirect-speech.] var sents = xdocument.GetSentences(language); foreach (var sent in sents) { #region [.check 'max-sent-count-in-text'.] if (Config.ResultLimit_MaxSentCountInText <= sentGlobalNumber) { LOG.Error("Превышено допустимое число предложений в тексте, будут обработанны только первые '" + Config.ResultLimit_MaxSentCountInText + "' предложений"); break; } #endregion #region [.check 'max-sent-length-without-space'.] var lengthWithoutSpace = sent.Value.LengthWithoutSpace(); if (Config.ResultLimit_MaxSentLengthWithoutSpace < lengthWithoutSpace) { LOG.Error("Превышена допустимая длина (в '" + Config.ResultLimit_MaxSentLengthWithoutSpace + "' символов) одного предложения: '" + lengthWithoutSpace + "', данное предложение не будет обработанно: \r\n" + sent.ToString()); continue; } #endregion var subjectObjectsTuples = language.Rules.Process(sent, ref directAndIndirectSpeechGlobalNumber, inputParams.ObjectAllocateMethod); //[some-concrete-subject] if (subjectObjectsTuples.AnyEx()) { #region foreach (var t in subjectObjectsTuples) { //[some-objects] are exists if (t.Objects.Any()) { #region var omts1 = from o in t.Objects from sd in t.Subjects from s in sd.SubjectEssences let fs = inputParams.InquiriesSynonyms.IsContainsInSynonyms(s, o, coreferenceInfo) where fs.HasValue select new OpinionMiningTuple ( s, o, sent, sentGlobalNumber, fs.Value, coreferenceInfo ); opinionMiningTuples.AddRange(omts1); #endregion } //not has [some-objects] else { #region var omts2 = from sd in t.Subjects from s in sd.SubjectEssences where s.IsContainsInSynonyms(inputParams.InquiriesSynonyms, coreferenceInfo) select new OpinionMiningTuple ( s, sent, sentGlobalNumber, FilterBySynonyms.Subject, coreferenceInfo ); opinionMiningTuples.AddRange(omts2); #endregion } //[Author-subject]-[subject-as-object] #region var omts3 = from sd in t.Subjects from s in sd.SubjectEssences where s.IsContainsInSynonyms(inputParams.InquiriesSynonyms, coreferenceInfo) select OpinionMiningTuple.Create4AuthorSubject ( s.ToObjectEssence(), sent.Copy().RemoveDirectAndIndirectSpeechBeginEndAttributes(), sentGlobalNumber, FilterBySynonyms.Object, coreferenceInfo ); opinionMiningTuples.AddRange(omts3); #endregion } #endregion } //[Author-subject]-[some-objects] else { #region var os = sent.TryAllocateObjects4AuthorSubject(objectAllocateMethod, isi); #region [.check 'max-object-in-one-sent'.] if (Config.ResultLimit_MaxObjectInOneSent < os.Count) { LOG.Error("Превышено допустимое число объектов в одном предложении: '" + os.Count + "', будут использоваться только первые '" + Config.ResultLimit_MaxObjectInOneSent + "' объектов: \r\n" + sent.ToString()); } #endregion var omts = from o in os.Take(Config.ResultLimit_MaxObjectInOneSent) select OpinionMiningTuple.Create4AuthorSubject ( o, sent, sentGlobalNumber, FilterBySynonyms.Object, coreferenceInfo ); opinionMiningTuples.AddRange(omts); #endregion } sentGlobalNumber++; } #endregion #region [.Reprocess EssenceItems 4 Homogeneous.] foreach (var omt in opinionMiningTuples) { Common.ReprocessEssenceItems4Homogeneous(omt, coreferenceInfo /*, inputParams.ObjectAllocateMethod*/); } #endregion return(opinionMiningTuples); }
public static List <XElement> TryAllocateObjects4AuthorSubject(this XElement sent, ObjectAllocateMethod objectAllocateMethod, InquiriesSynonymsInfo isi) { sent.ThrowIfNotSent(); var objects = new List <XElement>(); var subsents = Algorithms.GetSubsents4AllocateInquiry(sent); foreach (var subsent in subsents) { var inquiries = Algorithms.GetAllocateInquiries4Subsent(subsent, objectAllocateMethod, isi, false); foreach (var inquiryEntity in inquiries) { objects.Add(inquiryEntity.SetAttributeISOBJECT_wpfHomogeneous(ATTRIBUTEVALUE_ISOBJECT_4AUTHORSUBJECT)); } } return(objects); }