为什么我的马尔可夫链从语料库中产生相同的句子



我在python中使用markovify马尔可夫链生成器,当使用那里给出的示例代码时,它会为我产生很多重复的句子,我不知道为什么。

代码如下:

import markovify
# Get raw text as string.
with open("testtekst.txt") as f:
text = f.read()
# Build the model.
text_model = markovify.Text(text)
# Print five randomly-generated sentences
for i in range(20):
print(text_model.make_sentence())

这给我的输出:

Time included him on their list of the world's highest-paid athlete by ESPN from 2016 to 2019.
He assumed full captaincy of the world's most marketable and famous athletes, Ronaldo was named the best Portuguese player of all time by the Portuguese Football Federation.
The following year, he led Portugal to their first major tournament title at Euro 2004, where he helped Portugal reach the final.
The following year, he led Portugal to their first major tournament title at Euro 2004, where he helped Portugal reach the final.
He is the first footballer and the FIFA Club World Cup at age 23, he won his first season.
One of the tournament.
He also led them to victory in the world in 2014.
In 2015, Ronaldo was ranked the world's most famous athlete by ESPN from 2016 to 2019.
The following year, he led Portugal to their first major tournament title at Euro 2004, where he helped Portugal reach the final.
In 2015, Ronaldo was ranked the world's most famous athlete by ESPN from 2016 to 2019.
The following year, he led Portugal to their first major tournament title at Euro 2004, where he helped Portugal reach the final.
He is the first footballer and the FIFA Club World Cup at age 23, he won his first international goal at Euro 2004, where he helped Portugal reach the final.
The following year, he led Portugal to their first major tournament title at Euro 2004, where he helped Portugal reach the final.
One of the world's highest-paid athlete by ESPN from 2016 to 2019.
Time included him on their list of the national team in July 2008.
He is the first footballer and the FIFA Club World Cup at age 23, he won his first season.
Time included him on their list of the national team in July 2008.
He also led them to victory in the world in 2014.
The following year, he led Portugal to their first major tournament title at Euro 2004, where he helped Portugal reach the final.
One of the world's most marketable and famous athletes, Ronaldo was ranked the world's most famous athlete by Forbes in 2016 and 2017 and the FIFA Club World Cup at age 23, he won his first international goal at Euro 2016, and received the Silver Boot as top scorer of Euro 2020.

testtekst.txt采用ANSI编码,并具有以下语料库:

罗纳尔多在马德拉出生和长大,开始了他的高级俱乐部生涯在年与曼联签约之前,曾效力于体育CP2003年,18岁,在他的第一个赛季就赢得了足总杯。他也会连续三次赢得英超冠军23岁时,他赢得了他的第一个球d'Or。罗纳尔多是当时最昂贵的协会的对象2009年他转会皇马时的足球转会价值9400万欧元(8000万英镑(,赢得15座奖杯,其中包括两次西甲冠军,两次国王杯冠军和四次冠军联赛冠军,以及成为俱乐部有史以来的最佳射手。他还获得了亚军三次获得金球奖,落后于莱昂内尔·梅西(他认为职业竞争对手(,并在2013年和2014年连续获得金球奖2016年和2017年再次出现。2018年,他转会尤文图斯最初价值1亿欧元(8800万英镑(,是最昂贵的意大利俱乐部的转会,也是最昂贵的转会30岁以上的球员。他赢得了两次意甲冠军,两次超级杯冠军意大利队和意大利杯,年返回曼联2021年。罗纳尔多在2003年18岁时首次代表葡萄牙队参加国际比赛,此后他为葡萄牙队出场180多次葡萄牙出场次数最多的球员。在在国际比赛中,他也是美国历史上得分最高的球员。他参加了11场主要锦标赛并取得了进球在2004年欧洲杯上,他帮助葡萄牙队打入了第一粒国际比赛进球决赛。7月,他正式担任国家队队长2008年。2015年,罗纳尔多被葡萄牙足球联合会评为有史以来最好的葡萄牙球员。第二年,他领导葡萄牙队在2016年欧洲杯上首次夺得大赛冠军获得银靴奖,成为锦标赛他还带领他们在首届欧洲联盟国家赛中获胜在2019年的联赛中,他获得了金靴奖,成为2020年欧洲杯。作为世界上最具市场价值和知名度的运动员之一,罗纳尔多被《福布斯》评为2016年全球收入最高的运动员以及2017年和2016年至2017年ESPN评选的世界最著名运动员《时代》杂志将他列入2014年全球100位最具影响力人物名单。他是第一个也是第三个足球运动员这位运动员的职业生涯收入达到10亿美元。

正如你在输出中看到的那样,有几个相同的句子打印出来,我不知道为什么。默认状态大小应为2。

答案是我的状态大小太大了——在将其设置为1后,它产生了唯一的句子。我也不知道Markovify总是从语料库中句子的第一个单词开始生成新的句子。

没错,Markovify总是从语料库中句子的第一个单词开始生成新句子。答案是你所在州的规模太大了。你自己回答了。然而,你得到了一个好结果。我仔细阅读了关于罗纳尔多的文章。做得好

最新更新