回 帖 发 新 帖 刷新版面

主题:求助:字符串问题

你好,我有一个字符串,名字叫 s

请问:如何得出里面每个单词出现的个数呢(及频率)?

比如:有个s="this is a test to get the frequency of the words, how to do it"
然后
this 1
is 1
a 1
test 1
to 2
get 1
the 2
frequency 1
of 1
words 1
how 1
do 1
it 1

麻烦做的给点思路,非常感谢~~~

回复列表 (共1个回复)

沙发

首先使用aaa=split(s," ")得到每个单词,得到aaa后,别忘记替换掉其他标点符号。
然后再用bbb=split(s,aaa(i)),那么ubound(bbb)就是单词的个数。
自己试试

我来回复

您尚未登录,请登录后再回复。点此登录或注册