Answer the question
In order to leave comments, you need to log in
What is the algorithm of the service like rifmaslovo.ru?
Hello.
I want to make a service similar to this one - rifmaslovo.ru I'm going
to use a MySQL database with a table with words.
It is not clear how to compose a query to select a specific word
Answer the question
In order to leave comments, you need to log in
You look for articles on how rhyme works, create a set of rules, assign them a rank, look up words in the dictionary according to these rules and issue them to the user, sorted by rank.
The first thing that comes to mind: we take a stress dictionary, cut off the entire ending from the word from the query, starting with the stressed vowel, look in the dictionary for words with the same ending and the same stressed vowel. " beautiful " - "with willow ". This will be the first rank
. The second rank will be a slightly modified ending. For example, if the user entered the word " multiple ", you can replace "a" with "i" and find, for example, " pleasant ". "u" to "u" - "girlfriend " , "
The third rank can be made even softer, for example, there may be one additional consonant in the ending, or the order of consonants may differ.
This just popped into my head. Database with a dictionary, RegEx in hand and go
***
UPD: In the service you have a link in general, everything is primitive. They first output what I described above as the first rank, and then cut off one letter from the ending and look for the same endings. Brad, this is no longer a rhyme
It seems to me that there is some kind of simple 'clumsy' option.
Example in python 3.*:
var = 'Слово'
arrayWords = ['нетослово', 'олово', 'рубилово']
resultArray = []
for i in range(0, len(var) - 1):
# Тут по идее мы должны обращаться к базе с запросом типа:
# SELECT * FROM table_words WHERE word LIKE '%тут_будет_значение';
for word in arrayWords:
if var[-2 - i:] in word:
if word not in resultArray:
resultArray.append(word)
print(resultArray)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question