Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8656735
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T15:21:08+00:00 2026-06-12T15:21:08+00:00

I have to extract summary from newspaper article . The summary is extracted based

  • 0

I have to extract summary from newspaper article . The summary is extracted based on given Keyword and according to below mentioned rules .

  1. Summary should be of 200 characters.

  2. Start printing from that sentence in article as soon as keyword
    appears in that sentence and print upto 200 characters

  3. If the matching sentence occurs towards ending of article such that
    summary is coming out to be less than 200 characters , then move
    back from matching sentence towards previous sentences uptill
    finally 200 charcters containing matching sentence are printed
    finally.

What I have done untill now is …

var regex = new Regex(keyword+@"(.{0,200})");

foreach (Match match in regex.Matches(input))
{
    var result = match.Groups[1].Value;
    Console.WriteLine(result);

    // work with the result
}

The above code successfully reaches the first matching sentence but starts printing AFTER the keyword upto 200 characters rather than beginning of matching sentence.

Also there is no backtracking if end of article is reached before 200 characters are printed.

Please guide me how should I proceed . Even if somebody doesn’t know complete solution , PLEASE do help me out in sub parts of question .

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-12T15:21:10+00:00Added an answer on June 12, 2026 at 3:21 pm
    var nextIndex = input.IndexOf(keyword);
    
    while (nextIndex != -1)
    {
        var index = nextIndex;
        // To start the 200chars result from right after the keyword, do instead:
        // var index = nextIndex + keyword.Length;
    
        // If you want to stop after you reached the end of the text once:
        // var end = false;
    
        if (index + 200 >= input.Length)
        {
            index = input.Length - 200;
    
            // If you want to stop after you reached the end of the text once:
            // var end = true;
        }
    
        var result = index < 0 ? input : input.Substring(index, 200);
    
        Console.WriteLine(result);
    
        // If you want to stop after you reached the end of the text once:
        // if (end) { break; }
    
        nextIndex = input.IndexOf(keyword, nextIndex + 1);
    }
    

    And if you want to search to be case insensitive, just add StringComparison.OrdinalIgnoreCase as another parameter in both IndexOfs.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm using Selenium for work and I have extract some data from //ul, unfortunately
I have to extract defined variable and function names from a js code passed
I have to extract columns from a text file explained in this post: Extracting
I've a requirement where I have to extract metrics from different Java projects (configured
I have been trying to extract an e-mail address from a website using XPath.
I have been trying to extract e-mail addresses from the following code for quite
I have been trying to extract data from a database and fill in a
I have written a function that extract the domain from hostname. e.g. www.domain.com ->
I have to extract data from a saved search and drop each column into
I have to extract all email addresses from some .txt documents. These emails may

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.