穆穆青风至 2022-09-19 10:53 采纳率: 97.4%
浏览 39
已结题

有段python代码看不明白


text_corpus = [
    "Human machine interface for lab abc computer applications",
    "A survey of user opinion of computer system response time",
    "The EPS user interface management system"
]
stop_list=set('for a of the and to in'.split(' '))
texts = [[word for word in document.lower().split() if word not in stop_list]for document in text_corpus]

主要是最后一行,应该是先执行for document in text_corpus ,也就是从text_corpus中每次去除一个字符串也就是doucument,然后把这个字符串document放到前面执行,然后前面一长串我就不知道咋执行的

  • 写回答

5条回答 默认 最新

  • honestman_ 2022-09-19 11:04
    关注

    拿到了doucument后先做处理document.lower().split()
    然后循环遍历document.lower().split()的元素,如果不在stop_list中,那么就添加到新的列表,否则不添加

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(4条)

报告相同问题?

问题事件

  • 系统已结题 9月30日
  • 已采纳回答 9月22日
  • 创建了问题 9月19日