Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Recognize Missing Space

Tags:

How can I recognize when a user has missed a space when entering a search term? For example, if the user enters "usbcable", I want to search for "usb cable". I'm doing a REGEX search in MySQL to match full words.

I have a table with every term used in a search, so I know that "usb" and "cable" are valid terms. Is there a way to construct a WHERE clause that will give me all the rows where the term matches part of the string?

Something like this:

SELECT st.term 
FROM SearchTerms st
WHERE 'usbcable' LIKE '%' + st.term + '%'

Or any other ideas?

like image 941
Yisroel Avatar asked Feb 27 '09 06:02

Yisroel


1 Answers

Text Segmentation is a part of Natural Language Processing, and is what you're looking for in this specific example. It's used in search engines and spell checkers, so you might have some luck with example source code looking at open source spell checkers and search engines.

Spell checking might be the correct paradigm to consider anyway, as you first need to know whether it's a legitimate word or not before trying to pry it apart.

-Adam

like image 170
Adam Davis Avatar answered Sep 30 '22 18:09

Adam Davis