26英文字母使用频率的大样本分析
来源:互联网 发布:如何手机注销淘宝店铺 编辑:程序博客网 时间:2024/05/01 14:40
样本:英文世界名著(1000部)
样本容量:1.4亿(包含6918个文件,366M)
#include <stdio.h>#include <stdlib.h>#include <string.h>int CountL[26];int CheckL(char c){ int index; char i, j; int flag = 0; for(i = 'A', j = 'a'; i <= 'Z', j <= 'z'; i++, j++) { if(i == c) { CountL[i - 65]++; flag = 1; break; } if(j == c) { CountL[j - 97]++; flag = 1; break; } } return flag;}long LetterScan(char *filepath){ FILE *fp; long AllCount = 0; char c; if((fp = fopen(filepath, "r")) == NULL) { perror("Can't open!"); exit(1); } while(!feof(fp)) { c = fgetc(fp); if(CheckL(c)) { AllCount++; } } fclose(fp); return AllCount;}char *SortL(){ int i, j, t; char c; char *Letter; Letter = (char *)calloc(26, sizeof(char)); for(i = 0; i < 26; i++) { Letter[i] = i + 97; } for(i = 0; i < 25; i++) { for(j = 0; j < 25 - i; j++) { if(CountL[j] < CountL[j + 1]) { t = CountL[j]; c = Letter[j]; CountL[j] = CountL[j + 1]; Letter[j] = Letter[j + 1]; CountL[j + 1] = t; Letter[j + 1] = c; } } } return Letter;}int main(){ char *FilePath = "/share/test/doc/test.txt"; int i; long count = 0; char *Letter; Letter = (char *)calloc(26, sizeof(char)); system("rm -rf doc/test.txt"); system("cat doc/*txt > doc/test.txt"); count = LetterScan(FilePath); Letter = SortL(); printf("测试文本包含有效英文字母总数:%ld\n", count); for(i = 0; i < 26; i++) { printf("%c共出现%d次,概率是%f\n", Letter[i], CountL[i], (float)CountL[i] / count); } free(Letter); return 0;}
0 0
- 26英文字母使用频率的大样本分析
- 从大样本中均匀提取子集的算法
- Excel在统计分析中的应用—第十一章—相关分析-简单线性相关-相关系数为零的检验(大样本)
- 深度学习是图像识别的新潮流,并行大样本训练自动找到问题特征
- 统计书籍推荐之大样本理论
- Excel在统计分析中的应用—第八章—假设检验-总体方差未知且为大样本下的检验
- 使用nginx的access_log 进行接口调用频率分析
- 游戏的刷新频率分析
- Excel在统计分析中的应用—第六章—抽样分布-大样本的抽样分布(均值的抽样分布)
- Excel在统计分析中的应用—第六章—抽样分布-大样本的抽样分布(比例的抽样分布)
- Excel在统计分析中的应用—第六章—抽样分布-大样本的抽样分布(差的抽样分布)
- Excel在统计分析中的应用—第七章—参数估计-总体均值的估计(总体方差未知且为大样本下估计)
- 有关FFT频率与实际物理频率的分析
- FFT频率和实际物理频率的分析
- 26个英文字母的爱情解释
- 26个英文字母是谁发明的?
- 26个英文字母的爱情含义
- 26個英文字母出現的頻率表
- 3.5、卸载一个应用程序
- C99新特性
- 我的第一篇博客
- PHP面向对象开发的学习(二)
- 通过jstack定位在线运行java系统故障_案例1
- 26英文字母使用频率的大样本分析
- java 泛型嵌套
- sencha touch权威指南---学习笔记4-插入图片单击事件
- 【SDOI2013】保护出题人
- Eclipse上安装GIT插件EGit及使用
- 手势识别器实现界面切换
- Struts中1个Action中多个执行方法时,怎么调用
- Matrix Swapping II - HDU 2830 dp
- 解决action与iframe显示问题