I
I
Ivan Dronov2019-08-06 19:47:08
PHP
Ivan Dronov, 2019-08-06 19:47:08

Searching for words in a text using a dictionary?

There is a dictionary of 2-3 (Anya, Sasha, Alexandra, Alex) thousands of names and an arbitrary text of 2-3k characters
Is there an optimal way to search for exact occurrences of names in this arbitrary text. 100 thousand names. Perhaps there are any libraries or tools for this?

Answer the question

In order to leave comments, you need to log in

4 answer(s)
U
uvelichitel, 2019-08-06
@barseon

Algorithm Aho - Korasik

D
Dmitry Shitskov, 2019-08-06
@Zarom

I think full-text search systems - sphynx, elasticsearch - will perfectly cope with the task.
But maybe it's a cannon for a sparrow

A
Alexander Alekseev, 2019-08-06
@ntllct

Simple task. The dictionary of names is converted to lowercase and loaded into a hash table or binary search tree. Next, we run through the text, select the words, copy them to the buffer, converting uppercase letters to lowercase, and look for the word in the hash table (or search tree). Faster only due to low-level optimizations or I misunderstood the task.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question