如何从Python中的给定句子创建多个句子
我想通过在python中混淆单词,从给定的句子中创建多个句子 e、 g.假设我有一句话“密码重置成功” 现在,我需要从上面的一个生成各种句子组合 输出:如何从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
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']