Beispiel #1
0
 /// <summary>
 /// Extract sentences from string
 /// </summary>
 /// Segment an input string into separate sentences, output result as a string.
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='input'>
 /// Input string
 /// </param>
 /// <param name='cancellationToken'>
 /// The cancellation token.
 /// </param>
 public static async Task <PostOKResponse> PostAsync(this ISentences operations, string input, CancellationToken cancellationToken = default(CancellationToken))
 {
     using (var _result = await operations.PostWithHttpMessagesAsync(input, null, cancellationToken).ConfigureAwait(false))
     {
         return(_result.Body);
     }
 }
        public string RenderData(ISentences sentences)
        {
            StringBuilder result = new StringBuilder();

            foreach (var sentenceFragment in sentences.SentenceFragments)
            {
                result.Append(ProcessSegment(sentenceFragment));
                result.Append(". ");
            }

            return(result.ToString().TrimEnd(' '));
        }
Beispiel #3
0
        public override void VisitSentences(ISentences sentencesParam, IHighlightingConsumer consumer)
        {
            string       lastText      = null;
            ISentence    lastSentence  = null;
            ISentence    startSentence = null;
            const string message       = "Statements can be simplified";

            foreach (var sentence in sentencesParam.SentenceListEnumerable)
            {
                string text;
                if (sentence.Statement != null && sentence.Statement.Subject != null &&
                    !string.IsNullOrEmpty(text = sentence.Statement.Subject.GetText()))
                {
                    if (text.Equals(lastText, StringComparison.Ordinal))
                    {
                        if (startSentence == null)
                        {
                            startSentence = lastSentence;
                        }
                    }
                    else
                    {
                        if (startSentence != null)
                        {
                            this.AddSentenceSuggestionHighlighting(consumer, message, startSentence, lastSentence);
                            startSentence = null;
                        }
                    }

                    lastSentence = sentence;
                    lastText     = text;
                }
            }

            if (startSentence != null)
            {
                this.AddSentenceSuggestionHighlighting(consumer, message, startSentence, lastSentence);
            }
        }
        public override void VisitSentences(ISentences sentencesParam, IHighlightingConsumer consumer)
        {
            string lastText = null;
            ISentence lastSentence = null;
            ISentence startSentence = null;
            const string message = "Statements can be simplified";
            foreach (var sentence in sentencesParam.SentenceListEnumerable)
            {
                string text;
                if (sentence.Statement != null && sentence.Statement.Subject != null &&
                    !string.IsNullOrEmpty(text = sentence.Statement.Subject.GetText()))
                {
                    if (text.Equals(lastText, StringComparison.Ordinal))
                    {
                        if (startSentence == null)
                        {
                            startSentence = lastSentence;
                        }
                    }
                    else
                    {
                        if (startSentence != null)
                        {
                            this.AddSentenceSuggestionHighlighting(consumer, message, startSentence, lastSentence);
                            startSentence = null;
                        }
                    }

                    lastSentence = sentence;
                    lastText = text;
                }
            }

            if (startSentence != null)
            {
                this.AddSentenceSuggestionHighlighting(consumer, message, startSentence, lastSentence);
            }
        }
Beispiel #5
0
 /// <summary>
 /// Extract sentences from string
 /// </summary>
 /// Segment an input string into separate sentences, output result as a string.
 /// <param name='operations'>
 /// The operations group for this extension method.
 /// </param>
 /// <param name='input'>
 /// Input string
 /// </param>
 public static PostOKResponse Post(this ISentences operations, string input)
 {
     return(Task.Factory.StartNew(s => ((ISentences)s).PostAsync(input), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult());
 }