menzi11 / BullshitGenerator

Needs to generate some texts to test if my GUI rendering codes good or not. so I made this.
Other
15.69k stars 2.88k forks source link

生成文章()函数的修正以及字数统计的修正 #172

Open gittig11 opened 4 years ago

gittig11 commented 4 years ago

1、生成文章()函数的修正 不需要用到for(let 空 in 主题){}循环 2、字数统计的修正 论述、后面垫话句末的空格要删掉,避免字数统计多了1。对应的要修改 增加段落(章节)函数。

Dobby233Liu commented 4 years ago

原版也有for(let 空 in 主题) https://github.com/menzi11/BullshitGenerator/blob/6adb2812cf9efcaa001f71b660a8af63ca085532/%E8%87%AA%E5%8A%A8%E7%8B%97%E5%B1%81%E4%B8%8D%E9%80%9A%E6%96%87%E7%AB%A0%E7%94%9F%E6%88%90%E5%99%A8.py#L42-L43

gittig11 commented 4 years ago

代码中设置了文章为6000字,但是生成的文章有好几万字?(原版没有测试,.html文件是这样的)------------------ 原始邮件 ------------------ 发件人: "Liu-Wen-Yuan"notifications@github.com 发送时间: 2020年2月11日(星期二) 下午2:58 收件人: "menzi11/BullshitGenerator"BullshitGenerator@noreply.github.com; 抄送: "gittig11"1710336112@qq.com;"Author"author@noreply.github.com; 主题: Re: [menzi11/BullshitGenerator] 生成文章()函数的修正以及字数统计的修正 (#172)

原版也有for(let 空 in 主题) https://github.com/menzi11/BullshitGenerator/blob/6adb2812cf9efcaa001f71b660a8af63ca085532/%E8%87%AA%E5%8A%A8%E7%8B%97%E5%B1%81%E4%B8%8D%E9%80%9A%E6%96%87%E7%AB%A0%E7%94%9F%E6%88%90%E5%99%A8.py#L42-L43

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub, or unsubscribe.

Dobby233Liu commented 4 years ago

原版是~6000字。可能js和py3处理字符串遍历的方式不一样。 edit:当时我是用a测试的,用学生会退会就出问题了。~32000字

gittig11 commented 4 years ago

我试了一下,Python版本的代码也有问题。 为什么要用“for x in xx”循环?当len(tmp) >= 6000时,tmp就是所需要的文本,print()打印出来。如果经过for in 循环,会多次打印,文本字数为 6000*len(主题)。 修改后的代码为:

if name == "main": xx = input("请输入文章主题:") tmp = str() while ( len(tmp) < 6000 ) : 分支 = random.randint(0,100) if 分支 < 5: tmp += 另起一段() elif 分支 < 20 : tmp += 来点名人名言() else: tmp += next(下一句废话) print(tmp)

Dobby233Liu commented 4 years ago

这(for x in xx)也许是凑字的其中一种方法...

gittig11 commented 4 years ago

@Dobby233Liu 哈哈,这里可能是作者笔误吧,添加"for x in xx"后字数会多好几倍。