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

有段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日

悬赏问题

  • ¥15 虚幻5 UE美术毛发渲染
  • ¥15 CVRP 图论 物流运输优化
  • ¥15 Tableau online 嵌入ppt失败
  • ¥100 支付宝网页转账系统不识别账号
  • ¥15 基于单片机的靶位控制系统
  • ¥15 真我手机蓝牙传输进度消息被关闭了,怎么打开?(关键词-消息通知)
  • ¥15 装 pytorch 的时候出了好多问题,遇到这种情况怎么处理?
  • ¥20 IOS游览器某宝手机网页版自动立即购买JavaScript脚本
  • ¥15 手机接入宽带网线,如何释放宽带全部速度
  • ¥30 关于#r语言#的问题:如何对R语言中mfgarch包中构建的garch-midas模型进行样本内长期波动率预测和样本外长期波动率预测