文件方式實現完整的英文詞頻統計實例
fo=open(‘123.txt‘,‘r‘) a=fo.read() a=a.lower() #小寫 for i in ‘,.‘: a=a.replace(i,‘ ‘) #替換標點符號 words=a.split() #分單詞 print(words) dic={} #字典 keys=set(words) #集合 print(keys) for i in keys: dic[i]=words.count(i) #出現單詞的次數 print(dic) wc = list(dic.items()) #列表 wc.sort(key=lambda x:x[1],reverse=True) print(wc) for i in range(20): print(wc[i]) fo.close()
1、
2、
3、
4、
5、
文件方式實現完整的英文詞頻統計實例
相關推薦
文件方式實現完整的英文詞頻統計實例
() item .com div lambda 英文 [1] 完整 set fo=open(‘123.txt‘,‘r‘) a=fo.read() a=a.lower() #小寫 for i in ‘,.‘: a=a.replace(i,‘ ‘) #替換標點符
組合數據類型練習,英文詞頻統計實例
news forever .com 分隔 ima hat http war nis 實例:由字符串創建一個作業評分列表,做增刪改查詢統計遍歷操作。例如,查詢第一個3分的下標統計1分的同學有多少個,3分的同學有多少個 >>> ap=list("02
組合數據類型和英文詞頻統計實例
think laughing clas self why rms day index oom 1.列表實例:由字符串創建一個作業評分列表,做增刪改查詢統計遍歷操作。例如,查詢第一個3分的下標,統計1分的同學有多少個,3分的同學有多少個等。 >>> ls
組合數據類型練習,英文詞頻統計實例上
元組 one lam 主鍵 必須 分析字符串 logs with spa 1/字典實例:建立學生學號成績字典,做增刪改查遍歷操作。 d={‘10‘:80,‘11‘:87,‘13‘:76,‘13‘:50,‘14‘:89,‘15‘:96,‘16‘:89,‘17‘:100}
組合數據練習,英語詞頻統計實例上
games 1-1 合數 ice 語句 rime ict 項目 tuple 1 >>> d={‘01‘:95,‘02‘:92,‘03‘:86,‘04‘:70}>>> print(d){‘01‘: 95, ‘02‘: 92, ‘03‘: 8
php上傳文件與圖片到七牛的實例詳解
null images n) spa 最簡 neu err allow -c 上傳文件到七牛最簡單的方式就是使用七牛官方最新的SDK 用composer安裝PHP SDK composer require qiniu/php-sdk 上傳文件到七牛 use Qiniu\
字符串、文件操作,英文詞頻統計預處理
ima post 本體 預處理 eight 固定 密鑰 圖片 行政區 1.字符串操作:解析身份證號:生日、性別、出生地等。 地址碼: 表示編碼對象常住戶口所在縣(市、旗、區)的行政區劃代碼。 出生日期碼:表示編碼對象出生的年、月、日,年、月、
Python——字符串、文件操作,英文詞頻統計預處理
string 加密和解密 com 模塊 put 圖片 查詢 url 偏移 一.字符串操作: 解析身份證號:生日、性別、出生地等。 凱撒密碼編碼與解碼 網址觀察與批量生成 2.凱撒密碼編碼與解碼 凱撒加密法的替換方法
字符串操作、文件操作,英文詞頻統計預處理
ews 行政區劃 format bcd ignore hat 密碼 clas 串操作 1.字符串操作: 解析身份證號:生日、性別、出生地等。 凱撒密碼編碼與解碼 網址觀察與批量生成 (1)解析身份證號: ID = input(‘請輸入十八位身份證號碼
2018-08-05 期 MapReduce實現每個單詞在每個文件中坐標信息統計
line 字符 count throws ase protect clas 行處理 tostring package cn.sjq.bigdata.inverted.index;import java.io.IOException;import java.util.Iter
完整的英文詞頻統計
code 空格 存儲 for src res inf 分享圖片 次數 1.準備utf-8編碼的文本文件file 2.通過文件讀取字符串 str 3.對文本進行預處理 4.分解提取單詞 list 5.單詞計數字典 set , dict 6.按詞頻排序 list.sort(ke
通過COM組件方式實現java調用C#寫的DLL文件 轉
time rar .exe 字符串 sys 還需 第一個 運行 system 最近一段時間單位在做一個Web項目,工程師用JAVA語言,需要公用人員信息,統一用戶名和密碼,原有的平臺中是用C#語言開發的,在網上查找解決方法,通過JAVA調用C#的DLL文件實現。網上
python實現讀取檔案英文詞頻統計並寫入到檔案
# _*_ coding: utf-8 _*_ # 作者:dcjmessi import os from collections import Counter # 假設要讀取檔名為read,位於當前路徑 filename = 'read.txt' # 當前程
函數、文件操作實現數據增刪改查---low版本
腳本 python 首先說明這個腳本很low,目前水平有限,只能實現使用固定的語法對數據進行增刪改查。但是現在腳本不low,怎麽讓明年的我來嘲笑今年的自己需求 a.可進行模糊查詢,語法至少支持下面3種: select name,age from staff_table where
Android開發之布局文件裏實現OnClick事件關聯處理方法
intent dsm nbsp ext 關聯 you vertica findview 時間 一般監聽OnClickListener事件,我們都是通過Button button = (Button)findViewById(....); button.se
操作系統概念 文件系統實現
指針 中斷 命令 減少 目標 連續分配 外存 提高 sector 磁盤提供大量的外存空間來維持文件系統。磁盤的下述兩個特點使得其成為存儲多個文件的方便介質。 ①可以原地重寫; ②可以直接訪問磁盤上的任意一塊信息。 為了提供對磁盤的高效且便捷的訪問,操作系統通過文件系統來
java對File文件夾實現刪除
pub rgs ring string void static new rec del //刪除文件夾 public void delete(File f){ //判斷是否文件,若是文件,直接刪除,否則遞歸,刪除所有文件 if(!f.isDirectory()
使用HttpRequest.Files 獲取上傳文件,實現上傳附件功能
post 分享 new 失敗 light 查看 continue 存在 nbsp 使用HttpRequest.Files 獲取上傳文件,實現上傳附件功能,不同瀏覽器會有差異: 獲得在 Google 瀏覽器上傳後得到的 HttpRequest.Files (客戶端上載文件
C++模板類頭文件和實現文件分離
證明 about compile strong 驗證 title htm -c itl http://www.cnblogs.com/lvdongjie/p/4288373.html 如何實現C++模板類頭文件和實現文件分離,這個問題和編譯器有關。 引用<<
軟件工程第二次作業 詞頻統計
mage std pen not pytho replace mon 知識 ljust 1.項目名稱:詞頻統計 2.代碼地址:https://coding.net/u/songyuu/p/python_wf/git 3.代碼如下: 1 import os 2 impo