words.wordform.WordForm

words.wordform.WordForm(self, children=[], txt=None, sylls_ipa=[], sylls_text=[], syll_sep='.', num=None, text=None, key=None, parent=None, **kwargs)

Represents a specific form of a word.

Attributes

Name Description
rime Get the rime of the word form.

Methods

Name Description
rime_distance Calculate the rime distance between this word form and another.

rime_distance

words.wordform.WordForm.rime_distance(wordform, max_dist=RHYME_MAX_DIST)

Calculate the rime distance between this word form and another.

Uses feature-weighted edit distance on rime phonemes (via panphon), which properly aligns phonemes of different lengths and weights substitution cost by phonetic similarity. Returns a value in [0, 1] where 0 is a perfect rhyme.

Args: wordform (WordForm): The word form to compare with. max_dist: Maximum distance threshold. Distances above this return np.nan. 0 = exact match only. None = no limit.

Returns: float: The rime distance (0-1), or np.nan if above max_dist or comparing identical words.