用Mathematica统计字母、字符和单词
1、先给出字符串:
a = "If we give a paragraph of English text, we want to get the number of times each letter appears, we need to use the function: LetterCounts.This article introduces the usage of this function."

2、统计字母频率:
LetterCounts[a]
出现次数最多的是字母e。

3、出现次数最多的双字母是ti:
LetterCounts[a, 2]

4、the是出现次数最多的三字母:
LetterCounts[a, 3]

5、出现次数最多的字符是空格:
CharacterCounts[a]

6、出现次数最多的双字符是"e ":
Reverse[Sort@CharacterCounts[a, 2]]

7、出现次数最多的单词是we、of、the:
Reverse[Sort@WordCounts[a]]

声明:本网站引用、摘录或转载内容仅供网站访问者交流或参考,不代表本站立场,如存在版权或非法内容,请联系站长删除,联系邮箱:site.kefu@qq.com。
阅读量:74
阅读量:159
阅读量:175
阅读量:33
阅读量:46