【问题标题】:How to remove words that dont make any sense from a column of textual observations如何从一列文本观察中删除没有任何意义的单词
【发布时间】:2021-02-23 10:37:19
【问题描述】:

我有大约 200 万条评论,评论中的大部分词都是纯垃圾,如下所示:

[('tcsworklife', 1),
 ('freshs', 1),
 ('elserun', 1),
 ('anathor', 1),
 ('ontract', 1),
 ('locationadibatla', 1),
 ('hindiname', 1),
 ('culturenegotiation', 1),
 ('ਵਭਗ', 1),
 ('ਵਗਰ', 1),
 ('ਭਰਭ', 1),
 ('ਬਹਤ', 1),
 ('ਹ', 1),
 ('ਵਧਆ', 1),
 ('happybcz', 1),
 ('qriruduif', 1),
 ('carpanter', 1),
 ('ghule', 1),
 ('intrapolitics', 1),
 ('collasan', 1),
 ('tcsthe', 1),
 ('oftion', 1),
 ('shiftit', 1),
 ('tellycalling', 1),
 ('majour', 1),
 ('securitied', 1),
 ('balaraju', 1),
 ('minupuri', 1),
 ('sdcvbhgvfcrdxs', 1),
 ('vgfcdxsza', 1),
 ('dscdc', 1),
 ('qdwd', 1),
 ('njn', 1),
 ('njnjn', 1),
 ('njnjnjn', 1),
 ('gbjk', 1),
 ('skhgksd', 1),
 ('kshdsgsd', 1),
 ('sbkhgsdjsg', 1),
 ('shkddshkjsd', 1),
 ('siddharthai', 1),
 ('nbwjh', 1),
 ('satilment', 1),
 ('mallinath', 1),
 ('tippanna', 1),
 ('djciajd', 1),
 ('fnjec', 1),
 ('jxrjcidcjtvm', 1),
 ('aporchunet', 1),
 ('thoraibakkamchennai', 1)]
'chooseeverything', 1),
 ('thatâs', 1),
 ('understandbest', 1),
 ('intercomany', 1),
 ('experiancelow', 1),
 ('anythingmachine', 1),
 ('lifetraveling', 1),
 ('timenight', 1),
 ('hollidayyou', 1),
 ('trsnsport', 1),
 ('workplacegreat', 1),
 ('webdriver', 1),
 ('freinely', 1)

如何去掉这些没有意义的词并保留那些有意义的词? 注意:有些词确实有意义但不包含空格,或者它只是拼写错误而不是像 weqwioeuwiouewq2rtg 这样的垃圾词。我正在寻找最佳的清洁方法。

【问题讨论】:

  • 谢谢,但我的问题也是关于如何更正拼写和间距错误并考虑这些单词

标签: python pandas nlp data-cleaning


【解决方案1】:

您可以将每个单词与相应的字典 s.t. 进行比较

import nltk   # if not installed yet just run pip install nltk
nltk.download('wordnet')
if wordnet.synsets("Human"):
    print("this word belongs to the English Dictionary")
else:
    print("it does not belong to the English Dictionary")

知道它是否属于英语词典中的一个词。

如果您需要,还可以使用其他语言词典。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2014-09-29
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-11-12
    • 2019-01-29
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多