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的更多相关文章

  1. python瓦登尔湖词频统计

    #瓦登尔湖词频统计: import string path = 'D:/python3/Walden.txt' with open(path,'r',encoding= 'utf-8') as tex ...

  2. 作业3-个人项目<词频统计>

    上了一天的课,现在终于可以静下来更新我的博客了.       越来越发现,写博客是一种享受.来看看这次小林老师的“作战任务”.                词频统计 单词: 包含有4个或4个以上的字 ...

  3. C语言实现词频统计——第二版

    原需求 1.读取文件,文件内包可含英文字符,及常见标点,空格级换行符. 2.统计英文单词在本文件的出现次数 3.将统计结果排序 4.显示排序结果 新需求: 1.小文件输入. 为表明程序能跑 2.支持命 ...

  4. c语言实现词频统计

    需求: 1.设计一个词频统计软件,统计给定英文文章的单词频率. 2.文章中包含的标点不计入统计. 3.将统计结果以从大到小的排序方式输出. 设计: 1.因为是跨专业0.0···并不会c++和java, ...

  5. 软件工程第一次个人项目——词频统计by11061153柴泽华

    一.预计工程设计时间 明确要求: 15min: 查阅资料: 1h: 学习C++基础知识与特性: 4-5h: 主函数编写及输入输出部分: 0.5h: 文件的遍历: 1h: 编写两种模式的词频统计函数: ...

  6. 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 ...

  7. pyspark进行词频统计并返回topN

    Part I:词频统计并返回topN 统计的文本数据: what do you do how do you do how do you do how are you from operator imp ...

  8. 使用storm分别进行计数和词频统计

    计数 直接上代码 public class LocalStormSumTopology { public static void main(String[] agrs) { //Topology是通过 ...

  9. jieba库分词词频统计

    代码已发至github上的python文件 词频统计结果如下(词频为1的词组数量已省略): {'是': 5, '风格': 4, '擅长': 4, '的': 4, '兴趣': 4, '宣言': 4, ' ...

随机推荐

  1. jquery获取当前select下拉选的属性值

    body中: <li> <select id="select_phone"></select> <input type="but ...

  2. Spring-导入和混合配置

    javaConfig模式下: 导入: @Import({XX.class,YY.class,...}) 混合: @ImportResource("classpath:xxx.xml" ...

  3. c++ 开放随笔

    1.设计或使用类时 一定先弄清流程 了解对象直接的关系(这个必须清楚) 如多对多,一对多,一对一关系.不然弄list map set时相对麻烦. 2.map 中key是不能重复的,可以看成一个主键,定 ...

  4. js 去掉空格.回车.换行

    Jquery:$("#accuracy").val($("#accuracy").val().replace(/\ +/g,""));//去 ...

  5. 搭建基于 HDFS 碎片文件存储服务

    安装 JDK HDFS 依赖 Java 环境,这里我们使用 yum 安装 JDK 8,在终端中键入如下命令: yum -y install java-1.8.0-openjdk* 使用如下命令查看下 ...

  6. ios 调用系统应用的方法 应用间跳转的方法

    声明一个私有方法: #pragma mark - 私有方法 -(void)openUrl:(NSString *)urlStr{ //注意url中包含协议名称,iOS根据协议确定调用哪个应用,例如发送 ...

  7. 【RF库Collections测试】Dictionary Should Contain Sub Dictionary

    Name:Dictionary Should Contain Sub DictionarySource:Collections <test library>Arguments:[ dict ...

  8. string permutation with upcase and lowcase

    Give a string, which only contains a-z. List all the permutation of upcase and lowcase. For example, ...

  9. linux上如何快速删除一个目录

    在linux中删除一个目录很简单,很多人还是习惯用rmdir,不过一旦目录非空,就陷入深深的苦恼之中,现在使用rm -rf命令即可解决.直接rm就可以了,不过要加两个参数-rf 即:rm -rf   ...

  10. 基于Cocos2d-x学习OpenGL ES 2.0系列——纹理贴图(6)

    在上一篇文章中,我们介绍了如何绘制一个立方体,里面涉及的知识点有VBO(Vertex Buffer Object).IBO(Index Buffer Object)和MVP(Modile-View-P ...