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 8144417
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T13:22:13+00:00 2026-06-06T13:22:13+00:00

I’m trying to create a service in which the user will input some text

  • 0

I’m trying to create a service in which the user will input some text data, like a blog post or something like that
and my service will replace some “special words” in their text for links. for example:

Blog Post:

"...Pink Floyd were an English rock band that achieved international 
success with their progressive and psychedelic rock music..."

The output will be something like:

"...<a href="http://www.xxx.com?q=pink%20floyd">Pink Floyd</a> 
were an English <a href="http://www.xxx.com?q=rock%20band">rock band</a>
that achieved international success with their 
progressive and psychedelic rock 
<a href="http://www.xxx.com?q=music">music<a/>..."

Something like the wikipedia does!

The general algorithm seems to be very simple:

  1. Remove special characters from the text.
  2. Strip tags.
  3. Lowercase the whole text.
  4. Remove stop words.
  5. Consult the database for the words that left.
  6. Get the original text and replace the words that matched in the database.

But the problem is that, i’m handling with around 1 million words in my database.
I’m using PHP and MySQL for that, by my knowledge PHP is probably not the best tool for text processing.

I’m afraid about the performance, depending of the traffic and the number of requests this algol could be VERY SLOW….

I tried to find another tools or methods to deal with this, i’ve found a lot of things, but i think none of then is the
right tool for the job.
I’ve found mysql full text search, search lucene, sphinx, solr. Correct me if i’m wrong but i think they are not the right tools for this kind of
search.

Can someone suggest me how to deal with this properly.

Things to consider:

  1. The text unfortunately is in portuguese “pt-br”, which i think will be a problem.
  2. It needs to get the full term, in the above exemple it will have to take “rock band” and not split then into “rock” and “band”.
  3. I don’t have deeper knowledge in other programming languages, but if this was the case i’m open for other technologies too!

Thanks

  • 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-06T13:22:14+00:00Added an answer on June 6, 2026 at 1:22 pm

    Don’t worry about performance in this problem.

    You can always:

    • Use indexes in db
    • Use cache (memcached for example) for stop words database or output text
    • Use sphinx (search engine, works with MySQL)
    • Keep formated text in database (the best solution if don’t plain to extend your stop words database)

    Also example of code to search stop words in db:

    ...
    $words = strip_tags($origin);
    $words = strtolower($words);
    // strip anything (symbols, numbers, etc), keep only words
    ...
    $words = explode(' ', $words);
    $found = DB::query(Database::SELECT, "SELECT url, word FROM `stop_words` WHERE word IN (".implode(',',$words).")")->execute()->as_array(); // Kohana framework Database module
    $patterns = array();
    $replacement = array();
    foreach($found AS $row)
    {
      $patterns[] = '/('.$row['word'].')/i';
      $replacement[] = '<a href="'.$row['url'].'">$1</a>';
    }
    $origin = preg_replace($patterns, $replacement, $origin);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

For some reason, after submitting a string like this Jack’s Spindle from a text
I'm trying to create an if statement in PHP that prevents a single post
I have some data like this: 1 2 3 4 5 9 2 6
Basically, what I'm trying to create is a page of div tags, each has
I am trying to understand how to use SyndicationItem to display feed which is
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I am trying to render a haml file in a javascript response like so:
I would like to run a str_replace or preg_replace which looks for certain words
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from

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.