python复习2

# dic={'purple':'紫色'}
# dic['black']='黑色'
# for key,val in dic.items():
#     print(key)

# 单词统计
stopword=['are','is','my','what','a','am','of', 'to']
s1=["What is deep learning?","Deep learning is a subset of machine learning, which is essentially a neural network with three or more layers.", " These neural networks attempt to simulate the behavior of the human brain—albeit far from matching \ its ability—allowing it to learning from large amounts of data."]
s=s1[0]+' '+s1[1]+' '+s1[2]
words = s.split()  # 把文章以空格分开成列表
new_word = []
for word in words:
    t = word.strip(',|?|.|!')#去除掉标点符号
    if t not in stopword:#去除停用词
        new_word.append(t)#清洗后的单词
count={}
for i in new_word:#把单词带入i
    if i in count:#如果单词存在在列表count
        count[i]+=1#单词量加1
    else:
        count[i]=1#如果单词不存在在列表count,放入类别
# print(count)
max=0
for i in new_word:
    if new_word.count(i)>max:#new_word.count(i) 统计i出现的次数
        t=i
        max=new_word.count(i)
# print(t,max)

set1={'1','2'}#集合去重
word1=set(new_word)
# word1=list(new_word)
print(type(set1))

#逢七拍手
#素数判断 除了1和他本身能够被整除
#歌德巴赫猜想 任何一个大于2的偶数,都可以表示成两个素数的和
#单词统计 去除标点符合和号和停用词
#统计高频词汇
#去除重复词汇

  • 8
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值