public static XDocument ProcessText(InputParamsBase inputParams) { var lingvisticResult = _LingvisticServer.ProcessText(inputParams.InputText, false, DateTime.Now, LingvisticsResultOptions.RDF); System.Diagnostics.Debug.Assert(lingvisticResult != null); System.Diagnostics.Debug.Assert(!string.IsNullOrEmpty(lingvisticResult.RDF)); var xdoc = Algorithms.PreprocessRdf(lingvisticResult.RDF); return(xdoc); }
public static XDocument ProcessText(InputParamsBase inputParams) { var lingvisticResult = _LingvisticServer.ProcessText(inputParams.InputText, false, DateTime.Now, LingvisticsResultOptions.RDF); if (lingvisticResult == null || lingvisticResult.RDF.IsEmptyOrNull()) { throw (new InvalidOperationException("LingvisticServer::ProcessText => [lingvisticResult == null || lingvisticResult.RDF.IsEmptyOrNull()]")); } var xdoc = Algorithms.PreprocessRdf(lingvisticResult.RDF); return(xdoc); }
public static DigestTuple ToDigestTuple(this OpinionMiningTuple tuple , TonalityMarkingWcfService.OutputResult4DigestWcfService outputResult4DigestWcfService , InputParamsBase inputParams) { var result = new DigestTuple ( tuple, outputResult4DigestWcfService.Sentence.ToString(), //outputResult4DigestWcfService.Sentence.Convert2OutputFormat( inputParams ).ToString(), outputResult4DigestWcfService.Positive, outputResult4DigestWcfService.Negative ); return(result); }
private static IEnumerable <DigestTuple> GenerateResult(OpinionMiningOutputResult opinionMiningResult, bool executeTonalityMarking, InputParamsBase inputParams) { var digestTuples = default(IEnumerable <DigestTuple>); if (executeTonalityMarking) { var digestTuplesList = new List <DigestTuple>(opinionMiningResult.Tuples.Count); foreach (var tuple in opinionMiningResult.Tuples) { if (tuple.HasObject) { var tonalityMarkingResult = TonalityMarkingWcfService.ExecuteTonalityMarking4DigestWcfService(tuple.GetSentence(), inputParams); digestTuplesList.Add(tuple.ToDigestTuple(tonalityMarkingResult, inputParams)); } else { digestTuplesList.Add(tuple.ToDigestTuple(/*inputParams*/)); } } digestTuples = digestTuplesList; } else { digestTuples = from tuple in opinionMiningResult.Tuples select tuple.ToDigestTuple(/*inputParams*/); } return(digestTuples); }
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 void ErrorEx(this ILog log, string methodName, Exception ex, string clientRemoteAddress, InputParamsBase inputParams) { var value = ("{0}]. ").FormatEx(Interlocked.Increment(ref _TotalLogCount)) + ("{0} => '{1}': '{2}'").FormatEx(methodName, ex.GetType().Name, ex.Message) + ("\r\n\t ClientRemoteAddress: {0}").FormatEx(clientRemoteAddress) + ("\r\n\t Input text (length: {0}): ").FormatEx(inputParams.InputText.Length) + inputParams.InputText.InSingleQuote(); log.Error(value, ex); #if DEBUG lock ( _SynRoot ) { var fc = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine(Environment.NewLine + value + Environment.NewLine + Environment.NewLine + ex.GetType().Name + " => " + ex.ToString()); Console.ForegroundColor = fc; //Console.WriteLine( RuleBase.GetDebugInfoOutput() ); } #endif }
public static void InfoEx(this ILog log, string methodName, string clientRemoteAddress, TimeSpan totalElapsed, InputParamsBase inputParams) { var value = Interlocked.Increment(ref _TotalLogCount) + "]. " + methodName + " => \r\n\t ClientRemoteAddress: " + clientRemoteAddress + "\r\n\t Total processing time: " + totalElapsed + "\r\n\t Input text (length: {0}): ".FormatEx(inputParams.InputText.Length) + inputParams.InputText.Get4Log(); log.Info(value); #if DEBUG lock ( _SynRoot ) { var fc = Console.ForegroundColor; Console.ForegroundColor = ConsoleColor.White; Console.WriteLine(Environment.NewLine + value); Console.ForegroundColor = fc; //Console.WriteLine( RuleBase.GetDebugInfoOutput() ); } #endif }