词频统计 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, ' ...
随机推荐
- 一直误解的memset函数
1.“想当然”导致的后果 今天犯了一个十分低级的错误,在对一个整型数组用memset进行初始化设置所有元素值为1.可是结果却大出所料,很意外啊!接着,我就做了代码测试. #include <io ...
- [转]Git学习笔记与IntelliJ IDEA整合
Git学习笔记与IntelliJ IDEA整合 一.Git学习笔记(基于Github) 1.安装和配置Git 下载地址:http://git-scm.com/downloads Git简要使用说明:h ...
- WordCount 远程集群源码
package test; import java.io.IOException; import java.util.StringTokenizer; import org.apache.hadoop ...
- 文件名中含有连续字符abc,相应文件中也含有字符串abc
find ./ -name '*abc*' -exec grep 'abc' {} -H \; find ./ -name '*abc*' | xargs -I '{}' grep abc {} -H ...
- Asp.net 程序优化js,css合并与压缩
访问时将js和css压缩并且缓存在客户端,采用的是Yahoo.Yui.Compressor组件还完成的,从这里可下载 创建一个IHttpHandler来处理文件 ) }; ) ...
- 记录下Lambda常用的表现形式
纯粹记录下Lambda的表现形式: (x, y) => x * y;//多参数,隐式类型=>表达式 x => x * ;//单参数,隐式类型=>表达式 x => { ; ...
- 安装JDK出现问题 Error opening registry key'software\Javasoft\Java Runtime Environment'
第一次安装JDK测试是否安装成功,打开cmd输入java -version 回车的时候出现如下错误: Error opening registry key'software\Javasoft\Java ...
- oracle 日期函数 求年的最后一天、第一天,月的最后一天
add_months(trunc(to_date('2013','yyyy') ,'yyyy'),12)-1 2013年最后一天 trunc(to_date('2013','yyyy') ,'yyy ...
- Windows7 64bits下安装TensorFlow CPU版本(图文详解)
不多说,直接上干货! Installing TensorFlow on Windows的官网 https://www.tensorflow.org/install/install_windows 首先 ...
- laravel 使用 session
配置方面的不写了,请参考学院君的文章:http://laravelacademy.org/post/5898.html 在开始之前先说一下,使用 request 对象的 session() 方法,和直 ...