G
G
Grizmar2015-12-11 16:05:55
PHP
Grizmar, 2015-12-11 16:05:55

How to check if one of the phrases occurs in the text?

There is a set of phrases that are similar in meaning, but differ in spelling, for example
, discount, discount
is possible,
discounts until November 30,
huge discounts,
discounts of the year
How can I check if one of these phrases occurs in the text?
(it is desirable that with a large number of phrases (> 300) the search is fast)
Or advise what you can read on this topic.

Answer the question

In order to leave comments, you need to log in

4 answer(s)
A
AM5800, 2015-12-19
@Grizmar

If I understand you correctly, then the Aho-Korasik algorithm
does exactly what you need. And in linear time

A
Anton Fedoryan, 2015-12-11
@AnnTHony

You can try to find a match for a common word first, for example. " СКИДК"
Find out the starting position of the word, cut 10-20 characters back and forth ( У НАС САМЫЕ ОГРОМНЫЕ СКИДКИ И ПОДАР...) and in the resulting string you are already looking for other more complete phrases.
Anything faster than scouring the entire text.

R
Roman Mirilaczvili, 2015-12-11
@2ord

What is Tomita-parser, how Yandex can use it ...
How Yandex uses linguistics in search

R
Robot, 2015-12-11
@iam_not_a_robot

str_replace will work faster than preg_match I think you will get the number from the last argument

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question