词频统计 in office
ROSTCM6
1. http://www.writewords.org.uk/word_count.asp
2. http://darylkinsman.ca/tools/wordfreq.shtml
3. http://www.wordcounter.com/
VBA macro of word
Sub ChineseCharCounting()
'统计汉字的字词频,并按降序排序
'中文词语的判断与Word的词典关联
Dim a As Byte
Dim n As Long
Dim TF As Boolean
Dim filetext As String
Dim d
Dim Wd As Range
Dim W As Range
Dim b
Dim e As Long
Dim c() As String
Dim i As Long
Dim temp As String
Dim st As Single
a = MsgBox("词频统计请按“是”,字频统计请按“否”", vbYesNo, "中文字词频统计")
st = Timer
Application.ScreenUpdating = False
n = ActiveDocument.Content.ComputeStatistics(wdStatisticFarEastCharacters)
If ActiveDocument.Content.Text Like "*[【】〖〗《》〈〉〔〕]*" Then TF = True
With ActiveDocument.Content.Find
.Text = "[【】〖〗《》〈〉〔〕]"
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With
Set d = CreateObject("Scripting.Dictionary")
If a = vbYes Then
For Each Wd In ActiveDocument.Words
With Wd
If .Start < e Then .Start = e
e = .End
If .Text Like "*[一-龥]*" And Len(.Text) > 1 Then
If .Text Like "*[!一-龥]*" = False And .Words.Count = 1 Then
d(.Text) = d(.Text) + 1
Else
For i = 1 To Len(.Text)
If Mid(.Text, i, 1) Like "[!一-龥]" Then Exit For
Next
With .Duplicate
.End = .Start + i - 1
For Each W In .Words
With W
If Len(.Text) > 1 Then
If Right(.Text, 1) Like "[!一-龥]" Then .End = .End - 1
If .Text Like "*[!一-龥]*" = False Then d(.Text) = d(.Text) + 1
End If
End With
Next
End With
End If
End If
End With
Next
Else
filetext = ActiveDocument.Content.Text
For i = 1 To Len(filetext)
temp = Mid(filetext, i, 1)
If temp Like "[一-龥]" Then d(temp) = d(temp) + 1
Next
End If
b = d.keys
ReDim c(UBound(b))
For i = 0 To UBound(b)
c(i) = b(i) & vbTab & d(b(i))
Next
If TF = True Then ActiveDocument.Undo 1
With Documents.Add.Content
.Text = "文档共有" & n & "个中文字符。共提取到" & d.Count _
& IIf(a = 6, "个中文词语", "个不同的汉字") & ",其出现次数分别为:" & vbCrLf & Join(c, vbCrLf)
.Parent.DefaultTabStop = .Characters.First.Font.Size * 6
.MoveStart wdParagraph
.Sort , 2, wdSortFieldNumeric, wdSortOrderDescending, 1, , , , , , wdSortSeparateByTabs
End With
MsgBox "提取完毕。用时" & Format(Timer - st, "0") & "秒。"
Application.ScreenUpdating = True
End Sub
词频统计 in office的更多相关文章
- python瓦登尔湖词频统计
#瓦登尔湖词频统计: import string path = 'D:/python3/Walden.txt' with open(path,'r',encoding= 'utf-8') as tex ...
- 作业3-个人项目<词频统计>
上了一天的课,现在终于可以静下来更新我的博客了. 越来越发现,写博客是一种享受.来看看这次小林老师的“作战任务”. 词频统计 单词: 包含有4个或4个以上的字 ...
- C语言实现词频统计——第二版
原需求 1.读取文件,文件内包可含英文字符,及常见标点,空格级换行符. 2.统计英文单词在本文件的出现次数 3.将统计结果排序 4.显示排序结果 新需求: 1.小文件输入. 为表明程序能跑 2.支持命 ...
- c语言实现词频统计
需求: 1.设计一个词频统计软件,统计给定英文文章的单词频率. 2.文章中包含的标点不计入统计. 3.将统计结果以从大到小的排序方式输出. 设计: 1.因为是跨专业0.0···并不会c++和java, ...
- 软件工程第一次个人项目——词频统计by11061153柴泽华
一.预计工程设计时间 明确要求: 15min: 查阅资料: 1h: 学习C++基础知识与特性: 4-5h: 主函数编写及输入输出部分: 0.5h: 文件的遍历: 1h: 编写两种模式的词频统计函数: ...
- Hadoop上的中文分词与词频统计实践 (有待学习 http://www.cnblogs.com/jiejue/archive/2012/12/16/2820788.html)
解决问题的方案 Hadoop上的中文分词与词频统计实践 首先来推荐相关材料:http://xiaoxia.org/2011/12/18/map-reduce-program-of-rmm-word-c ...
- pyspark进行词频统计并返回topN
Part I:词频统计并返回topN 统计的文本数据: what do you do how do you do how do you do how are you from operator imp ...
- 使用storm分别进行计数和词频统计
计数 直接上代码 public class LocalStormSumTopology { public static void main(String[] agrs) { //Topology是通过 ...
- jieba库分词词频统计
代码已发至github上的python文件 词频统计结果如下(词频为1的词组数量已省略): {'是': 5, '风格': 4, '擅长': 4, '的': 4, '兴趣': 4, '宣言': 4, ' ...
随机推荐
- js计算两个时间相差天数
//两个时间相差天数 兼容firefox chrome function datedifference(sDate1, sDate2) { //sDate1和sDate2是2006-12 ...
- navicat上如何导出视图,函数等
如何导出视图,函数,一般通过linux命令行,如果简单点就用navicat把. image.png 这样函数,视图都可以导出来后续更新.....
- kafka学习之-文件存储机制
Kafka是什么 Kafka是最初由Linkedin公司开发,是一个分布式.分区的.多副本的.多订阅者,基于zookeeper协调的分布式日志系统(也可以当做MQ系统),常见可以用于web/nginx ...
- jQuery为动态生成的select元素添加事件的方法
项目中需要在点击按钮时动态生成select元素,为防止每次点击按钮时从服务器端获取数据(因为数据都是相同的),可以这样写代码 1.首先定义全局js变量 var strVoucherGroupSelec ...
- COOKIE和SESSION关系和区别等
一.cookie介绍 cookie 常用于识别用户.cookie 是服务器留在用户计算机中的小文件.每当相同的计算机通过浏览器请求页面时,它同时会发送 cookie.通过 PHP,您能够创建并取回 c ...
- POJ 1946 Cow Cycling(抽象背包, 多阶段DP)
Description The cow bicycling team consists of N (1 <= N <= 20) cyclists. They wish to determi ...
- GIS-ArcGIS 数据库备份还原
Create directory sdebak as 'E:\10_DataFile'; alter system set deferred_segment_creation=false; ALTER ...
- java.lang.OutOfMemoryError 错误分类
java.lang.OutOfMemoryError: Java heap space原因:Heap内存溢出,意味着Young和Old generation的内存不够.解决:调整java启动参数 -X ...
- HTTP 基础术语
URI 和 URL:URI用于标记一个网络资源,URL则表示这个网络资源的访问地址,详细说明 超文本:普通的一段文字叫做文本,如果给这段文字加上超链接,那么就叫做超文本,HTML 就是超文本标记语言 ...
- NUC970烧录文件系统
燒錄U-Boot依照下列步驟將編譯完成的U-Boot燒錄至NAND Flash/SPI Flash/eMMC 中.U-Boot的編譯方法請參考4.3章節.3.11.1 燒錄所需檔案4. u-boot. ...