我正在写一个文本微调器,它工作的很好,因为它应该。但可读语句的准确性很低,因为它只是使用我从数据库中获得的字典。其返回spintax这样使用朴素贝叶斯的文本微调器
{Your} {home| house| residence| property} {is} {your} {castle| mansion| fortress| palace}
并传递到它选择随机同义词,基于所述用户的原始输入输出语句的功能。例如,对于输入:
Your home is your castle.
将返回
Your property is your mansion.
现在我想包括人工智能,因为它会让我的输出语句更具可读性。我想知道如何使用朴素贝叶斯做出更好的选择。我知道我可能需要训练以获得更好的结果。
这是我目前选择单词的方法,现在非常简单。
def spin(spintax):
while True:
word, n = re.subn('{([^{}]*)}',lambda m: random.choice(m.group(1).split("|")),spintax)
if n == 0: break
return word.strip()
谢谢你在前进,如果你们需要我张贴更多的代码,让我知道
谢谢你的建议,我会研究它。 –