階段作業1:完整的中英文詞頻統計
阿新 • • 發佈:2018-09-27
ini str clas rms encoding nic app 英文 around
strBig =‘‘‘Big Big World Emilia I‘m a big big girl In a big big world It‘s not a big big thing if you leave me But I do do feel that I too too will miss you much Miss you much. I can see the first leaf falling It‘s all yellow and nice It‘s so very cold outside Like the way I‘m feeling inside I‘m a big big girl In a big big world It‘s not a big big thing if you leave me But I do do feel that I too too will miss you much Miss you much. Outside it‘s now raining And tears are falling from my eyes Why did it have to happen Why did it all have to end I‘m a big big girl In a big big world It‘s not a big big thing if you leave me But I do do feel that I too too will miss you much Miss you much. I have your arms around me warm like fire But when I open my eyes You‘re gone. I‘m a big big girl In a big big world It‘s not a big big thing if you leave me But I do do feel that I too too will miss you much Miss you much. I‘m a big big girl In a big big world It‘s not a big big thing if you leave me But I do feel that will miss you much Miss you much. ‘‘‘ fo =open(‘bigbigworld.txt‘,‘r‘,encoding=‘utf-8‘) big =fo.read().lower() fo.close() print(big) #字符串預處理 sep =‘‘‘ .,:;?!-_‘‘‘ for ch in sep: strBig =strBig.replace(ch,‘ ‘) strList =strBig.split() print(len(strList),strList) strSet =set(strList) print(len(strSet),strSet) strDict ={} for word in strSet: strDict[word] = strList.count(word) print(len(strDict),strDict) wcList =list(strDict.items()) print(wcList) wcList.sort(key=lambda x:x[1],reverse=True) print(wcList)
C:\Users\Administrator\AppData\Local\Programs\Python\Python36\python.exe C:/Users/Administrator/PycharmProjects/untitled/bcd.py big big world emilia i‘m a big big girl in a big big world it‘s not a big big thing if you leave me but i do do feel that i too too will miss you much miss you much. i can see the first leaf falling it‘s all yellow and nice it‘s so very cold outside like the way i‘m feeling inside i‘m a big big girl in a big big world it‘s not a big big thing if you leave me but i do do feel that i too too will miss you much miss you much. outside it‘s now raining and tears are falling from my eyes why did it have to happen why did it all have to end i‘m a big big girl in a big big world it‘s not a big big thing if you leave me but i do do feel that i too too will miss you much miss you much. i have your arms around me warm like fire but when i open my eyes you‘re gone. i‘m a big big girl in a big big world it‘s not a big big thing if you leave me but i do do feel that i too too will miss you much miss you much. i‘m a big big girl in a big big world it‘s not a big big thing if you leave me but i do feel that will miss you much miss you much. 244 [‘Big‘, ‘Big‘, ‘World‘, ‘Emilia‘, "I‘m", ‘a‘, ‘big‘, ‘big‘, ‘girl‘, ‘In‘, ‘a‘, ‘big‘, ‘big‘, ‘world‘, "It‘s", ‘not‘, ‘a‘, ‘big‘, ‘big‘, ‘thing‘, ‘if‘, ‘you‘, ‘leave‘, ‘me‘, ‘But‘, ‘I‘, ‘do‘, ‘do‘, ‘feel‘, ‘that‘, ‘I‘, ‘too‘, ‘too‘, ‘will‘, ‘miss‘, ‘you‘, ‘much‘, ‘Miss‘, ‘you‘, ‘much‘, ‘I‘, ‘can‘, ‘see‘, ‘the‘, ‘first‘, ‘leaf‘, ‘falling‘, "It‘s", ‘all‘, ‘yellow‘, ‘and‘, ‘nice‘, "It‘s", ‘so‘, ‘very‘, ‘cold‘, ‘outside‘, ‘Like‘, ‘the‘, ‘way‘, "I‘m", ‘feeling‘, ‘inside‘, "I‘m", ‘a‘, ‘big‘, ‘big‘, ‘girl‘, ‘In‘, ‘a‘, ‘big‘, ‘big‘, ‘world‘, "It‘s", ‘not‘, ‘a‘, ‘big‘, ‘big‘, ‘thing‘, ‘if‘, ‘you‘, ‘leave‘, ‘me‘, ‘But‘, ‘I‘, ‘do‘, ‘do‘, ‘feel‘, ‘that‘, ‘I‘, ‘too‘, ‘too‘, ‘will‘, ‘miss‘, ‘you‘, ‘much‘, ‘Miss‘, ‘you‘, ‘much‘, ‘Outside‘, "it‘s", ‘now‘, ‘raining‘, ‘And‘, ‘tears‘, ‘are‘, ‘falling‘, ‘from‘, ‘my‘, ‘eyes‘, ‘Why‘, ‘did‘, ‘it‘, ‘have‘, ‘to‘, ‘happen‘, ‘Why‘, ‘did‘, ‘it‘, ‘all‘, ‘have‘, ‘to‘, ‘end‘, "I‘m", ‘a‘, ‘big‘, ‘big‘, ‘girl‘, ‘In‘, ‘a‘, ‘big‘, ‘big‘, ‘world‘, "It‘s", ‘not‘, ‘a‘, ‘big‘, ‘big‘, ‘thing‘, ‘if‘, ‘you‘, ‘leave‘, ‘me‘, ‘But‘, ‘I‘, ‘do‘, ‘do‘, ‘feel‘, ‘that‘, ‘I‘, ‘too‘, ‘too‘, ‘will‘, ‘miss‘, ‘you‘, ‘much‘, ‘Miss‘, ‘you‘, ‘much‘, ‘I‘, ‘have‘, ‘your‘, ‘arms‘, ‘around‘, ‘me‘, ‘warm‘, ‘like‘, ‘fire‘, ‘But‘, ‘when‘, ‘I‘, ‘open‘, ‘my‘, ‘eyes‘, "You‘re", ‘gone‘, "I‘m", ‘a‘, ‘big‘, ‘big‘, ‘girl‘, ‘In‘, ‘a‘, ‘big‘, ‘big‘, ‘world‘, "It‘s", ‘not‘, ‘a‘, ‘big‘, ‘big‘, ‘thing‘, ‘if‘, ‘you‘, ‘leave‘, ‘me‘, ‘But‘, ‘I‘, ‘do‘, ‘do‘, ‘feel‘, ‘that‘, ‘I‘, ‘too‘, ‘too‘, ‘will‘, ‘miss‘, ‘you‘, ‘much‘, ‘Miss‘, ‘you‘, ‘much‘, "I‘m", ‘a‘, ‘big‘, ‘big‘, ‘girl‘, ‘In‘, ‘a‘, ‘big‘, ‘big‘, ‘world‘, "It‘s", ‘not‘, ‘a‘, ‘big‘, ‘big‘, ‘thing‘, ‘if‘, ‘you‘, ‘leave‘, ‘me‘, ‘But‘, ‘I‘, ‘do‘, ‘feel‘, ‘that‘, ‘will‘, ‘miss‘, ‘you‘, ‘much‘, ‘Miss‘, ‘you‘, ‘much‘] 71 {‘feeling‘, ‘tears‘, ‘falling‘, ‘And‘, ‘have‘, "I‘m", ‘it‘, ‘see‘, ‘Why‘, ‘fire‘, ‘leave‘, ‘not‘, ‘a‘, ‘But‘, ‘end‘, ‘Emilia‘, ‘feel‘, ‘will‘, ‘the‘, ‘nice‘, ‘arms‘, ‘when‘, ‘too‘, ‘now‘, "You‘re", ‘that‘, ‘world‘, ‘can‘, ‘so‘, ‘from‘, ‘miss‘, ‘raining‘, ‘girl‘, ‘In‘, ‘leaf‘, ‘did‘, ‘cold‘, ‘first‘, ‘open‘, ‘Big‘, ‘Outside‘, "it‘s", ‘my‘, ‘you‘, ‘are‘, ‘much‘, ‘way‘, ‘your‘, ‘yellow‘, ‘warm‘, ‘if‘, ‘big‘, ‘Like‘, "It‘s", ‘happen‘, ‘around‘, ‘inside‘, ‘World‘, ‘and‘, ‘outside‘, ‘like‘, ‘Miss‘, ‘do‘, ‘thing‘, ‘all‘, ‘I‘, ‘very‘, ‘to‘, ‘eyes‘, ‘gone‘, ‘me‘} 71 {‘feeling‘: 1, ‘tears‘: 1, ‘falling‘: 2, ‘And‘: 1, ‘have‘: 3, "I‘m": 6, ‘it‘: 2, ‘see‘: 1, ‘Why‘: 2, ‘fire‘: 1, ‘leave‘: 5, ‘not‘: 5, ‘a‘: 15, ‘But‘: 6, ‘end‘: 1, ‘Emilia‘: 1, ‘feel‘: 5, ‘will‘: 5, ‘the‘: 2, ‘nice‘: 1, ‘arms‘: 1, ‘when‘: 1, ‘too‘: 8, ‘now‘: 1, "You‘re": 1, ‘that‘: 5, ‘world‘: 5, ‘can‘: 1, ‘so‘: 1, ‘from‘: 1, ‘miss‘: 5, ‘raining‘: 1, ‘girl‘: 5, ‘In‘: 5, ‘leaf‘: 1, ‘did‘: 2, ‘cold‘: 1, ‘first‘: 1, ‘open‘: 1, ‘Big‘: 2, ‘Outside‘: 1, "it‘s": 1, ‘my‘: 2, ‘you‘: 15, ‘are‘: 1, ‘much‘: 10, ‘way‘: 1, ‘your‘: 1, ‘yellow‘: 1, ‘warm‘: 1, ‘if‘: 5, ‘big‘: 30, ‘Like‘: 1, "It‘s": 7, ‘happen‘: 1, ‘around‘: 1, ‘inside‘: 1, ‘World‘: 1, ‘and‘: 1, ‘outside‘: 1, ‘like‘: 1, ‘Miss‘: 5, ‘do‘: 9, ‘thing‘: 5, ‘all‘: 2, ‘I‘: 12, ‘very‘: 1, ‘to‘: 2, ‘eyes‘: 2, ‘gone‘: 1, ‘me‘: 6} [(‘feeling‘, 1), (‘tears‘, 1), (‘falling‘, 2), (‘And‘, 1), (‘have‘, 3), ("I‘m", 6), (‘it‘, 2), (‘see‘, 1), (‘Why‘, 2), (‘fire‘, 1), (‘leave‘, 5), (‘not‘, 5), (‘a‘, 15), (‘But‘, 6), (‘end‘, 1), (‘Emilia‘, 1), (‘feel‘, 5), (‘will‘, 5), (‘the‘, 2), (‘nice‘, 1), (‘arms‘, 1), (‘when‘, 1), (‘too‘, 8), (‘now‘, 1), ("You‘re", 1), (‘that‘, 5), (‘world‘, 5), (‘can‘, 1), (‘so‘, 1), (‘from‘, 1), (‘miss‘, 5), (‘raining‘, 1), (‘girl‘, 5), (‘In‘, 5), (‘leaf‘, 1), (‘did‘, 2), (‘cold‘, 1), (‘first‘, 1), (‘open‘, 1), (‘Big‘, 2), (‘Outside‘, 1), ("it‘s", 1), (‘my‘, 2), (‘you‘, 15), (‘are‘, 1), (‘much‘, 10), (‘way‘, 1), (‘your‘, 1), (‘yellow‘, 1), (‘warm‘, 1), (‘if‘, 5), (‘big‘, 30), (‘Like‘, 1), ("It‘s", 7), (‘happen‘, 1), (‘around‘, 1), (‘inside‘, 1), (‘World‘, 1), (‘and‘, 1), (‘outside‘, 1), (‘like‘, 1), (‘Miss‘, 5), (‘do‘, 9), (‘thing‘, 5), (‘all‘, 2), (‘I‘, 12), (‘very‘, 1), (‘to‘, 2), (‘eyes‘, 2), (‘gone‘, 1), (‘me‘, 6)] [(‘big‘, 30), (‘a‘, 15), (‘you‘, 15), (‘I‘, 12), (‘much‘, 10), (‘do‘, 9), (‘too‘, 8), ("It‘s", 7), ("I‘m", 6), (‘But‘, 6), (‘me‘, 6), (‘leave‘, 5), (‘not‘, 5), (‘feel‘, 5), (‘will‘, 5), (‘that‘, 5), (‘world‘, 5), (‘miss‘, 5), (‘girl‘, 5), (‘In‘, 5), (‘if‘, 5), (‘Miss‘, 5), (‘thing‘, 5), (‘have‘, 3), (‘falling‘, 2), (‘it‘, 2), (‘Why‘, 2), (‘the‘, 2), (‘did‘, 2), (‘Big‘, 2), (‘my‘, 2), (‘all‘, 2), (‘to‘, 2), (‘eyes‘, 2), (‘feeling‘, 1), (‘tears‘, 1), (‘And‘, 1), (‘see‘, 1), (‘fire‘, 1), (‘end‘, 1), (‘Emilia‘, 1), (‘nice‘, 1), (‘arms‘, 1), (‘when‘, 1), (‘now‘, 1), ("You‘re", 1), (‘can‘, 1), (‘so‘, 1), (‘from‘, 1), (‘raining‘, 1), (‘leaf‘, 1), (‘cold‘, 1), (‘first‘, 1), (‘open‘, 1), (‘Outside‘, 1), ("it‘s", 1), (‘are‘, 1), (‘way‘, 1), (‘your‘, 1), (‘yellow‘, 1), (‘warm‘, 1), (‘Like‘, 1), (‘happen‘, 1), (‘around‘, 1), (‘inside‘, 1), (‘World‘, 1), (‘and‘, 1), (‘outside‘, 1), (‘like‘, 1), (‘very‘, 1), (‘gone‘, 1)] Process finished with exit code 0
階段作業1:完整的中英文詞頻統計