Example: Fuzzy Searching

At this point, we’ve extracted article text from web pages and then created keyword indexes of those articles based on the nouns that occurred most frequently within them.

Now let’s explore how we could search our new database for articles that match a given query. More usefully, you’ll learn how you can perform a fuzzy search—a search that matches not just the exact query you give it, but also things that are similar to it.

Our first step is to write a simple and exact search. Then we can look at how to improve both the storage of the index and the querying process to broaden the text that is matched by it.

A Simple Search

The simplest search we could write would be to, given a search term, list all the articles that ...

Get Text Processing with Ruby now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.