This topic has been archived. It cannot be replied.
-
工作学习 / 专业技术讨论 / 在请教一道常见的面试编程题统计一段plain text中有多少单词,以及计算出现频率最高的单词。谢谢!
-xm1223(andy);
2007-4-25
{66}
(#3636145@0)
-
看看这个,没时间写完,但能跑了,有空再补上。#!/bin/sh
sed 's/[^a-zA-Z]/ /g' <$1 |tr '[:upper:]' '[:lower:]'|tr '[:blank:]' '\n'|tr -s '\n'|sort>compressed_file
cat compressed_file|uniq>cut_duplicated_file
for var in `cat cut_duplicated_file`
do
echo $var `cat compressed_file|grep $var|wc -l`
done
rm -f compressed_file cut_duplicated_file
-mike20030405(麦客);
2007-4-26
{318}
(#3638432@0)
-
cat filename | tr -sc A-Za-z '\012' | sort | uniq -c | sort -n | tail
-commerce(commerce);
2007-4-29
(#3642771@0)