Skip to content

text_models

POSifiedText

Bases: Text

Uses spacy to parse the text into a model.

For information on the inherited properties and functions, see the markovify documentation at https://github.com/jsvine/markovify

word_join

word_join(words)

Join words back into a sentence.

Source code in src/django_markov/text_models.py
def word_join(self, words):
    """Join words back into a sentence."""
    sentence = " ".join(word.split("::")[0] for word in words)
    return sentence

word_split

word_split(sentence)

Split the sentence into words and there respective role in the sentence.

Source code in src/django_markov/text_models.py
def word_split(self, sentence):
    """Split the sentence into words and there respective role in the
    sentence."""
    return ["::".join((word.orth_, word.pos_)) for word in nlp(sentence)]