通常在数据处理的时候英文数据层次不齐、同时包含大小写的情况需要归一化,轻松用linux命令来解决:
1.awk命令:
a)针对文本文件格式为文本行的text文件:
awk '{print toupper($0))}' text > new_text
b)针对文本行为utt和文本行的text文件:(utt是指每条文本的编号):
paste -d " " <(cut -f 1 -d" " text) <(cut -f 2- -d" " text | awk '{print toupper($0)}') > new_text
2.sed命令
a)针对文本文件格式为文本行的text文件:
sed ‘s/.*/\U&/’ text > new_text
b)针对文本行为utt和文本行的text文件:(utt是指每条文本的编号):
paste -d " " <(cut -f 1 -d" " text) <(cut -f 2- -d" " text | sed ‘s/.*/\U&/’ text ) > new_text