【问题标题】:TypeError: clean() got an unexpected keyword argumentTypeError: clean() 得到了一个意外的关键字参数
【发布时间】:2021-12-14 15:46:58
【问题描述】:

我正在使用 python 对 Colab Notebook 进行情感分析。 这是我使用 Cleantext 和 spaCy 的代码。

def prep(text):
    cleaned = clean(text, fix_unicode=True, to_ascii=True, lower=False, no_line_breaks=True, no_urls=True,
                    no_emails=True, no_phone_numbers=False, no_numbers=False, no_digits=True, no_currency_symbols=True, 
                    no_punct=True, replace_with_url="URL_ADDRESS", replace_with_email="EMAIL_ADDRESS",
                    replace_with_phone_number="<PHONE>", replace_with_number="<NUMBER>",
                    replace_with_digit="INTEGER", replace_with_currency_symbol="CUR", lang="en")
    doc = nlp(cleaned)
    processed =' '.join([token.lemma_ if str(token) not in ['Our','our','We','we','us'] else str(token) for token in doc])
    return processed

使用此功能预处理数据在本地 jupyter notebook 上工作正常,但在 Colab 上,我得到了TypeError: clean() got an unexpected keyword argument 我该如何解决这个问题?

谢谢

【问题讨论】:

  • 请显示完整的错误
  • 你在哪里定义了你的 clean() 函数?它说你对 clean() 函数使用了错误的参数,只是发现拼写错误,...
  • 检查您使用的版本是否与您用于文档参考的版本相同。

标签: python google-colaboratory spacy


【解决方案1】:

你应该更新你的包。

pip install clean-text[gpl]==0.4.0

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2016-09-17
    • 2012-12-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-12-08
    • 2020-11-16
    相关资源
    最近更新 更多