Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/341.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
如何从Python中的给定句子创建多个句子_Python_Nlp - Fatal编程技术网

如何从Python中的给定句子创建多个句子

如何从Python中的给定句子创建多个句子,python,nlp,Python,Nlp,我想通过在python中混淆单词,从给定的句子中创建多个句子 e、 g.假设我有一句话“密码重置成功” 现在,我需要从上面的一个生成各种句子组合 输出: reset password successful successful reset password successful password reset password reset successful. ... 如何使用python您可以使用: 如果您想在列表中显示: >>> [' '.join(sent) for s

我想通过在python中混淆单词,从给定的句子中创建多个句子

e、 g.假设我有一句话“密码重置成功”

现在,我需要从上面的一个生成各种句子组合

输出:

reset password successful
successful reset password
successful password reset
password reset successful.
...
如何使用python

您可以使用:

如果您想在列表中显示:

>>> [' '.join(sent) for sent in permutations(sentence.split())]
['password reset successful',
 'password successful reset',
 'reset password successful',
 'reset successful password',
 'successful password reset',
 'successful reset password']
如果您不希望列表中出现原始的
句子

>>> combs = [' '.join(sent) for sent in permutations(sentence.split())]
>>> combs.remove(sentence)
>>> combs
['password successful reset',
 'reset password successful',
 'reset successful password',
 'successful password reset',
 'successful reset password']

你做了什么来解决这个问题?如上所述,需要进行一些研究工作。如何将相同的技术应用于包含10行的列。它必须为列中的每一行生成句子
>>> combs = [' '.join(sent) for sent in permutations(sentence.split())]
>>> combs.remove(sentence)
>>> combs
['password successful reset',
 'reset password successful',
 'reset successful password',
 'successful password reset',
 'successful reset password']