Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

NLP algorithm to 'fill out' search terms

Tags:

python

nlp

n-gram

I'm trying to write an algorithm (which I'm assuming will rely on natural language processing techniques) to 'fill out' a list of search terms. There is probably a name for this kind of thing which I'm unaware of. What is this kind of problem called, and what kind of algorithm will give me the following behavior?

Input:

    docs = [
    "I bought a ticket to the Dolphin Watching cruise",
    "I enjoyed the Dolphin Watching tour",
    "The Miami Dolphins lost again!",
    "It was good going to that Miami Dolphins game"
    ], 
    search_term = "Dolphin"

Output:

["Dolphin Watching", "Miami Dolphins"]

It should basically figure out that if "Dolphin" appears at all, it's virtually always either in the bigrams "Dolphin Watching" or "Miami Dolphins". Solutions in Python preferred.

like image 456
Trindaz Avatar asked Sep 29 '11 23:09

Trindaz


People also ask

How is NLP used in search?

Natural Language Search is carried out in regular language, phrasing questions as you would ask them if you were speaking to a person. These queries can be typed right into a search engine, spoken aloud with voice search, or posed as a question to a virtual assistant like Siri or Cortana.

What are the three 3 most common tasks addressed by NLP?

One of the most popular text classification tasks is sentiment analysis, which aims to categorize unstructured data by sentiment. Other classification tasks include intent detection, topic modeling, and language detection.


1 Answers

It should basically figure out that if "Dolphin" appears at all, it's virtually always either in the bigrams "Dolphin Watching" or "Miami Dolphins".

Sounds like you want to determine the collocations that Dolphin occurs in. There are various methods for collocation finding, the most popular being to compute point-wise mutual information (PMI) between terms in your corpus, then select the terms with the highest PMI for Dolphin. You might remember PMI from the sentiment analysis algorithm that I suggested earlier.

A Python implementation of various collocation finding methods is included in NLTK as nltk.collocations. The area is covered in some depth in Manning and Schütze's FSNLP (1999, but still current for this topic).

like image 132
Fred Foo Avatar answered Nov 05 '22 07:11

Fred Foo