Thursday, December 21, 2023
text generator
import random
class ArticleGenerator:
def __init__(self):
self.templates = [
"The {adj1} {noun} {verb} over the {adj2} {noun2}.",
"In a {adj1} turn of events, {noun} {verb} {adj2}ly.",
"{noun} {verb} {adj1}, making it a {adj2} story."
]
self.adjectives = ["quick", "lazy", "brown", "noisy", "blue", "green"]
self.nouns = ["fox", "dog", "head", "leg", "cat"]
self.verbs = ["jumps", "lifts", "bites", "licks", "kicks"]
self.nouns2 = ["table", "chair", "rug", "book", "shoe"]
def generate_article(self):
template = random.choice(self.templates)
adj1 = random.choice(self.adjectives)
adj2 = random.choice(self.adjectives)
noun = random.choice(self.nouns)
verb = random.choice(self.verbs)
noun2 = random.choice(self.nouns2)
article = template.format(adj1=adj1, adj2=adj2, noun=noun, verb=verb, noun2=noun2)
return article
# Example usage:
generator = ArticleGenerator()
for _ in range(5):
generated_article = generator.generate_article()
print(generated_article)
Subscribe to:
Post Comments (Atom)
screan recoder
Screen Recorder Screen Recorder Tool Start Recording Stop Recording...
-
import javax.servlet.ServletException; import javax.servlet.annotation.WebServlet; import javax.servlet.http.HttpServlet; import javax.servl...
-
Screen Recorder Screen Recorder Tool Start Recording Stop Recording...
-
import random class ArticleGenerator: def __init__(self): self.templates = [ "The {adj1} {noun} {verb} over th...
No comments:
Post a Comment