如何在python中正确使用TextToSequences

问题描述 投票:0回答:1

这是一个Python脚本:

from zeugma import TextsToSequences

test = ['I am here to stay', 'Who are you', 'Hello World']

sequencer = TextsToSequences()
embedded_sequ = sequencer.fit_transform(test)

它返回此错误:

ValueError: setting an array element with a sequence. The requested array has an inhomogeneous shape after 1 dimensions. The detected shape was (3,) + inhomogeneous part.

如何解决这个问题? 谢谢

我尝试为测试的每个元素赋予相同的长度。

我希望有一份退货号码清单

python deep-learning nlp
1个回答
0
投票

将其转换为单词列表:

test = [['I', 'am', 'here', 'to', 'stay'], ['Who', 'are', 'you'], ['Hello', 'World']]

sequencer = TextsToSequences()
embedded_sequ = sequencer.fit_transform(test)
© www.soinside.com 2019 - 2024. All rights reserved.