forked from mrlan/EnglishPal
				
			更新 'app/wordfreqCMD.py'
							parent
							
								
									3ca66d147c
								
							
						
					
					
						commit
						ce2af6665d
					
				|  | @ -40,12 +40,12 @@ def file2str(fname):#文件转字符 | ||||||
| 
 | 
 | ||||||
| 
 | 
 | ||||||
| def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。 | def remove_punctuation(s): # 这里是s是形参 (parameter)。函数被调用时才给s赋值。 | ||||||
|     special_characters = '_©~=+[]*&$%^@.,?!:;#()"“”—‘’'  #把里面的字符都去掉 |     '''special_characters = '_©~=+[]*&$%^@.,?!:;#()"“”—‘’'  #把里面的字符都去掉 | ||||||
|     for c in special_characters: |     for c in special_characters: | ||||||
|         s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况 |         s = s.replace(c, ' ') # 防止出现把 apple,apple 移掉逗号后变成 appleapple 情况 | ||||||
|     s = s.replace('--', ' ') |     s = s.replace('--', ' ')''' | ||||||
|     '''cop = re.compile("[^a-z^A-Z^\\']")#通过正则表达式保留英文字符和-、'两个特殊字符 |     cop = re.compile("[^a-z^A-Z^\\']")#通过正则表达式保留英文字符和-、'两个特殊字符 | ||||||
|     s=cop.sub(' ' , s)''' |     s=cop.sub(' ' , s) | ||||||
|     s = s.strip() # 去除前后的空格 |     s = s.strip() # 去除前后的空格 | ||||||
|     #s=keep_need_punctuation(s,'-') |     #s=keep_need_punctuation(s,'-') | ||||||
|     s=keep_need_punctuation(s,'\'') |     s=keep_need_punctuation(s,'\'') | ||||||
|  |  | ||||||
		Loading…
	
		Reference in New Issue