快速对语料进行词频统计
- tokenize the words
tr -sc 'A-Za-z' '\n' < sh.txt
目的: 用于将文本序列中每一个non-characters更改至新行
A-Za-z: 字母
-c:A-Za-z的补集也即非字母
-s: 删除所有重复出现字符序列,只保留第一个;即将重复出现字符串压缩为一个字符串。
- tokenize the words
并且按照字母顺序排序
并且找到每个token的唯一值
tf -sc 'A-Za-z' '\n' < sh.txt | sort | uniq -c
-c折叠重复token并且计数
-
tokenize the words
并且将所有大写转换为小写
并且按照字母顺序排序
并且找到每个token的唯一值
tr -sc 'A-Za-z' '\n' < sh.txt | tr A-Z a-z | sort | uniq -c -
tokenize the words
并且将所有大写转换为小写
并且按照字母顺序排序
并且找到每个token的唯一值
并且按照数值大小排序(从大到小)
tr -sc 'A-Za-z' '\n' < sh.txt | tr A-Z a-z | sort | uniq -c | sort -n -r
-n按照数值进行排序
-r从大到小排序










网友评论