Use the rupo.api.Engine class to perform linguistic analysis on Russian text, including stress prediction, syllable splitting, rhyme checking, and metre classification.
- Initialize the engine with
language="ru". - Load the required models using
.load(<stress model path>, <zalyzniak dict path>). - Use the following methods:
get_stresses(word): Returns the stress position (e.g., [3]).get_word_syllables(word): Returns a list of syllables (e.g., ["ко", "ро", "ва"]).is_rhyme(word1, word2): Returns True if words rhyme.classify_metre(text): Returns the metre type (e.g., iambos).
from rupo.api import Engine
engine = Engine(language="ru")
engine.load(<stress model path>, <zalyzniak dict path>)
# Examples
print(engine.get_stresses("корова")) # [3]
print(engine.get_word_syllables("корова")) # ['ко', 'ро', 'ва']
print(engine.is_rhyme("корова", "здорова")) # True
text = "Горит восток зарёю новой.\nУж на равнине, по холмам\nГрохочут пушки. Дым багровый\nКругами всходит к небесам."
print(engine.classify_metre(text)) # iambos