我收到此包错误:'模块'texthero.preprocessing'没有属性'remove_stopwords'

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

我以前的计算机出现了问题,因此我需要切换并使用另一台计算机,但在新计算机上,我遇到了此代码错误。我不明白为什么,因为在我以前的电脑上它工作正常。

这是我的代码:

from texthero import preprocessing

custom_pipeline = [preprocessing.fillna # Remplacez les valeurs non affectées par des espaces vides
                   , preprocessing.lowercase # transforme tout le texte en minuscules
                   , preprocessing.remove_digits # Supprimez tous les blocs de chiffres
                   , preprocessing.remove_punctuation # supprimez tous les string.punctuation (! "# $% & '() * +, -. / :; <=>? @ [\] ^ _` {|} ~)
                   , preprocessing.remove_diacritics # Supprimez tous les accents des chaînes
                   , preprocessing.remove_stopwords # Supprimez tous les mots vides
                   , preprocessing.remove_whitespace # Supprimez tout espace blanc entre les mots
                   , preprocessing.remove_html_tags # supprimer toutes les balises HTML d’une chaîne
                   , preprocessing.remove_brackets] # supprimer les crochets de la chaîne 
# custom_pipeline à l'argument pipeline
df_biens_cons_variable_pertinentes['clean_description'] = hero.clean(df_biens_cons_variable_pertinentes['description'], pipeline = custom_pipeline)
df_biens_cons_variable_pertinentes['clean_product_name'] = hero.clean(df_biens_cons_variable_pertinentes['product_name'], pipeline = custom_pipeline)

display(df_biens_cons_variable_pertinentes.head(2))

index = 1000

text=df_biens_cons_variable_pertinentes.description[index]
print('#text brut #:',text)
text_clean =df_biens_cons_variable_pertinentes['clean_description'][index]
print('#text_clean# :',text_clean)

这是错误:

AttributeError: module 'texthero.preprocessing' has no attribute 'remove_stopwords'

它也有一个错误

preprocessing.remove_html_tags

我在网上搜索了一下,似乎没有人遇到

texthero
这样的麻烦,所以我有点迷失了。您知道为什么会发生这种情况吗?

我还有一个问题,为什么

texthero
没有出现在stackoverflow的标签部分?

python python-3.x
1个回答
0
投票

要回答这样的问题,我们需要更多信息,例如您安装的依赖项(特别是您正在使用的

TextHero
的版本)以及为什么您认为您的新电脑可能是问题所在。 但是,您似乎遇到了
AttributeError
,只要您正确完成了模块导入,它就根本不依赖于机器。

然而,进一步分析你的代码很困难,因为你的评论是:

  1. 法语(因此英语人士无法阅读......)
  2. 对于数据清理过程来说是不必要的(函数名称,例如
    remove_stopwords
    ,足够明确)。

因此,请尝试编辑您的代码和您的问题,以使后者真正可以回答。

当谈到 StackOverflow 上缺少

texthero
标签时,嗯 - 与该领域更成熟的其他自然语言处理包(例如
nltk
SpaCy
)相比,它的知名度要低得多。对于诸如文本清理或标记化之类的任务,您可能需要使用这些,因为它们的文档更加丰富,并且程序员在 StackOverflow 上有很多关于这些的问题要问!

© www.soinside.com 2019 - 2024. All rights reserved.