用Mathematica统计字母、字符和单词

2024-10-12 18:59:29

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

用Mathematica统计字母、字符和单词

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

用Mathematica统计字母、字符和单词

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

用Mathematica统计字母、字符和单词

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

用Mathematica统计字母、字符和单词
猜你喜欢