TypeError:无效Text_input类型< class' pandas.core.frame.dataframe'> (必需的str或命令)
from textattack.augmentation import EasyDataAugmenter
eda=EasyDataAugmenter()
eda.augment(train)
此代码上的错误
“火车”数据类型是数据框。扩展程序是带有2列(文本和标签)的CSV。
我想使用EDA来增强数据。
我已经导入并安装了所需的所有软件包:
textattack: Downloading https://textattack.s3.amazonaws.com/word_embeddings/paragramcf.
100%|██████████| 481M/481M [00:21<00:00, 22.6MB/s]
textattack: Unzipping file /root/.cache/textattack/tmp1g7u54ae.zip to /root/.cache/textattack/word_embeddings/paragramcf.
textattack: Successfully saved word_embeddings/paragramcf to cache.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-e7415cc200bf> in <module>()
1 from textattack.augmentation import EasyDataAugmenter
2 eda=EasyDataAugmenter()
----> 3 eda.augment(train)
/usr/local/lib/python3.7/dist-packages/textattack/augmentation/recipes.py in augment(self, text)
64 def augment(self, text):
65 augmented_text = []
---> 66 augmented_text += self.synonym_replacement.augment(text)
67 augmented_text += self.random_deletion.augment(text)
68 augmented_text += self.random_swap.augment(text)
/usr/local/lib/python3.7/dist-packages/textattack/augmentation/augmenter.py in augment(self, text)
111 """Returns all possible augmentations of ``text`` according to
112 ``self.transformation``."""
--> 113 attacked_text = AttackedText(text)
114 original_text = attacked_text
115 all_transformed_texts = set()
/usr/local/lib/python3.7/dist-packages/textattack/shared/attacked_text.py in __init__(self, text_input, attack_attrs)
51 else:
52 raise TypeError(
---> 53 f"Invalid text_input type {type(text_input)} (required str or OrderedDict)"
54 )
55 # Process input lazily.
TypeError: Invalid text_input type <class 'pandas.core.frame.DataFrame'> (required str or OrderedDict)
from textattack.augmentation import EasyDataAugmenter
eda=EasyDataAugmenter()
eda.augment(train)
Error on this code
The "train" data type is dataframe. and the extension is csv with 2 column (text and label).
I want to use EDA to augment the data.
I already import and install all the package it needs:
textattack: Downloading https://textattack.s3.amazonaws.com/word_embeddings/paragramcf.
100%|██████████| 481M/481M [00:21<00:00, 22.6MB/s]
textattack: Unzipping file /root/.cache/textattack/tmp1g7u54ae.zip to /root/.cache/textattack/word_embeddings/paragramcf.
textattack: Successfully saved word_embeddings/paragramcf to cache.
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-18-e7415cc200bf> in <module>()
1 from textattack.augmentation import EasyDataAugmenter
2 eda=EasyDataAugmenter()
----> 3 eda.augment(train)
/usr/local/lib/python3.7/dist-packages/textattack/augmentation/recipes.py in augment(self, text)
64 def augment(self, text):
65 augmented_text = []
---> 66 augmented_text += self.synonym_replacement.augment(text)
67 augmented_text += self.random_deletion.augment(text)
68 augmented_text += self.random_swap.augment(text)
/usr/local/lib/python3.7/dist-packages/textattack/augmentation/augmenter.py in augment(self, text)
111 """Returns all possible augmentations of ``text`` according to
112 ``self.transformation``."""
--> 113 attacked_text = AttackedText(text)
114 original_text = attacked_text
115 all_transformed_texts = set()
/usr/local/lib/python3.7/dist-packages/textattack/shared/attacked_text.py in __init__(self, text_input, attack_attrs)
51 else:
52 raise TypeError(
---> 53 f"Invalid text_input type {type(text_input)} (required str or OrderedDict)"
54 )
55 # Process input lazily.
TypeError: Invalid text_input type <class 'pandas.core.frame.DataFrame'> (required str or OrderedDict)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论