• 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Processing natural language

#1
[eluser]bapobap[/eluser]
Does anyone know of any good resources, books, tips, ideas even code on how to handle natural language?

I was hoping to make my search code a lot better by making it more human friendly and able to recognise (as best as a computer can) certain key words.

A 10-minute google hasn't come up with much other than research papers which are way too complicated.

Any ideas?

Thanks!

#2
[eluser]xwero[/eluser]
The simplest code to identify some keywords is
Code:
$keywords = array('who', 'what', 'where', 'how much', 'how to', 'contains');
$found_keywords = array();
$search_words = str_word_count($_POST['search'], 2); // the 2 is to get the keyword position as key in the array

foreach($keywords as $keyword)
{
   if(($position = array_search($keyword,$search_words)) !== FALSE)
   {
        $found_keywords[] = array($keyword,$position);
   }
}
Then you can build on the $found_keywords to get the values you need to build the search query.

#3
[eluser]bapobap[/eluser]
Is it best to address it in a procedural way like that? That's what I've been doing and the results haven't been as good as I would have liked, though I can't think of any other way to do it!

Thanks!

#4
[eluser]nmweb[/eluser]
There's are reason the research papers are complicated, this subject-matter is incredibly complicated. Rather than looking at natural language handling rather look at command-line handling. Indicate a number of keywords that trigger certain searches. E.g. search query starts with 'who' then search for persons.

#5
[eluser]xwero[/eluser]
As nmweb said if you want to identify all keywords in the search input you are going to do a lot of checks. For instance the search 'users who's name contains me'. The str_word_count will get the who with the added 's string. And the who here is only valid with the user and name parts of the search string.

There is no easy solution for this otherwise it would be floating around already Wink


Digg   Delicious   Reddit   Facebook   Twitter   StumbleUpon  


  Theme © 2014 iAndrew  
Powered By MyBB, © 2002-2020 MyBB Group.