Note that there are some explanatory texts on larger screens.

plurals
  1. POParsing and formatting search results
    text
    copied!<blockquote> <p><strong>Search:</strong></p> <p>Scripting+Language Web+Pages Applications</p> <p><strong>Results:</strong></p> <p>...<strong>scripting language</strong> originally...producing dynamic <strong>web pages</strong>. It has...graphical <strong>applications</strong>....purpose <strong>scripting language</strong> that is...d creating <strong>web pages</strong> as output...</p> </blockquote> <p>Suppose I want a value that represents the amount of characters to allow as padding on either side of the matched terms, and another value that represents how many matches will be shown in the result (ie, I want to see only the first 5 matches, nothing more).</p> <p>How exactly would <em>you</em> go about doing this?</p> <p>This is pretty language-agnostic, but I will be implementing the solution in a PHP environment, so please restrict answers to options that do not require a specific language or framework.</p> <p><strong>Here's my thought process:</strong> create an array from the search words. Determine which search word has the lowest index regarding where it's found in the article-body. Gather that portion of the body into another variable, and then remove that section from the article-body. Return to step 1. You might even add a counter to each word, skipping it when the counter reaches 3 or so.</p> <p><strong>Important:</strong></p> <p>The solution must match all search terms in a non-linear fashion. Meaning, term one should be found after term two if it exists after term two. Likewise, it should be found after term 3 as well. Term 3 should be found before term 1 and 2, if it happens to exist before them.</p> <p>The solution should allow me to declare "Only allow up to three matches for each term, then terminate the summary."</p> <p><strong>Extra Credit:</strong></p> <p>Get the padding-variable to optionally pad words, rather than chars.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload