You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

46 lines
2.5 KiB
Python

9 months ago
import random
import nltk
from nltk.corpus import wordnet
from loguru import logger
# word_list = [
# "the", "be", "and", "of", "a", "in", "to", "have", "it", "I",
# "that", "for", "you", "he", "with", "on", "do", "say", "this", "they",
# "at", "but", "we", "his", "from", "that's", "not", "by", "she", "or",
# "as", "what", "go", "their", "can", "who", "get", "if", "would", "her",
# "all", "my", "make", "about", "know", "will", "as's", "up", "one", "time",
# "has", "been", "there", "year", "so", "think", "when", "which", "them", "some",
# "me", "people", "take", "out", "into", "just", "see", "him", "your", "come",
# "could", "now", "than", "like", "other", "how", "then", "its", "our", "two",
# "more", "these", "want", "way", "look", "first", "also", "new", "because", "day",
# "more than", "use", "no", "man", "find", "here", "thing", "give", "many", "well",
# "only", "those", "tell", "don't", "same", "between", "don't know", "kind", "often", "too",
# "may", "need", "feel", "doesn't", "everybody", "still", "most", "own", "other", "after", "while", "long", "should",
# "some time", "today", "together", "maybe", "such", "follow", "work", "there's", "down", "because of", "over",
# "before", "whos", "behind", "all of", "become", "hear", "little", "never", "number", "really", "something",
# "tell me", "way of", "even as", "back", "come out", "first time", "into the", "like to", "lot of", "need to",
# "part of", "table of", "ability to", "according to", "all over", "amount of", "around the", "call on", "common in",
# "for the first time", "good idea", "have been", "in front of", "in need of", "look at", "make sure", "nothing but",
# "paid for", "quite a few", "sort of", "stick to", "the best way to", "the reason why", "thing of", "things like",
# "think about", "want to do", "around here", "before long", "ever since then", "feel free to", "from time to time",
# "let me know if you need anything", "look forward to hearing from you soon", "make a difference to sb/sth ",
# "not at all ", "the answer to this question ", "the key to success ",
# ]
# 生成随机语句
class Goupi():
def __init__(self):
logger.debug("start down and load words")
nltk.download('wordnet')
self.word_list = list(wordnet.words())
logger.debug("down and load words done")
word_list = list(wordnet.words())
nltk.download('wordnet')
def butong(self, num=10):
sentence = ' '.join(random.choices(self.word_list, k=num)) + '.'
return sentence