Macos MovieLens数据集-shell脚本
我正在使用找到的数据集和shell脚本。当我使用以下命令运行shell脚本时:Macos MovieLens数据集-shell脚本,macos,shell,Macos,Shell,我正在使用找到的数据集和shell脚本。当我使用以下命令运行shell脚本时: sh分割评级。sh 终端显示: ratings count: expr: syntax error set size: expr: syntax error remainder: tail: -: No such file or directory expr: syntax error head: -: No such file or directory expr: syntax error head: -:
sh分割评级。sh
终端显示:
ratings count:
expr: syntax error
set size:
expr: syntax error
remainder:
tail: -: No such file or directory
expr: syntax error
head: -: No such file or directory
expr: syntax error
head: -: No such file or directory
expr: syntax error
tail: -: No such file or directory
tail: -: No such file or directory
r1.test created. lines.
r1.train created. lines.
tail: -: No such file or directory
expr: syntax error
head: -: No such file or directory
expr: syntax error
head: -: No such file or directory
expr: syntax error
tail: -: No such file or directory
tail: -: No such file or directory
r2.test created. lines.
r2.train created. lines.
tail: -: No such file or directory
expr: syntax error
head: -: No such file or directory
expr: syntax error
head: -: No such file or directory
expr: syntax error
tail: -: No such file or directory
tail: -: No such file or directory
r3.test created. lines.
r3.train created. lines.
expr: syntax error
tail: -: No such file or directory
head: -: No such file or directory
expr: syntax error
head: -: No such file or directory
expr: syntax error
tail: -: No such file or directory
tail: -: No such file or directory
r4.test created. lines.
r4.train created. lines.
tail: -: No such file or directory
expr: syntax error
head: -: No such file or directory
expr: syntax error
head: -: No such file or directory
expr: syntax error
tail: -: No such file or directory
tail: -: No such file or directory
r5.test created. lines.
r5.train created. lines.
ra.test created. lines.
ra.train created. lines.
rb.test created. lines.
rb.train created. lines.
所有文件都显示在文件夹中;然而,其中大多数是空的r5.test
是唯一包含数据的.test
文件,它包含以下数据:
==> ratings.dat <==
71567::1984::1::912580553
71567::1985::1::912580553
71567::1986::1::912580553
71567::2012::3::912580722
71567::2028::5::912580344
71567::2107::1::912580553
71567::2126::2::912649143
71567::2294::5::912577968
71567::2338::2::912578016
71567::2384::2::912578173
==>ratings.dat我也有同样的问题。事实上,我用Xubuntu试过,效果非常好。所以我打开了split_ratings.sh
,试图找出脚本的错误。令人惊讶的是,问题出在第一行。如果您在终端上运行
$ wc -l ratings.dat | cut -d ' ' -f 1
它不会返回任何东西。第一个命令(位于管道左侧)统计文件包含的额定值数。第二,从字符串中提取数字。如果你跑
$ wc -l ratings.dat | cut -d ' ' -f 2
您将看到它正确返回数字
所以如果你改变这个
RATINGS_COUNT=`wc -l ratings.dat | cut -d ' ' -f 1`
对此
RATINGS_COUNT=`wc -l ratings.dat | cut -d ' ' -f 2`
脚本现在将知道有多少收视率。此外,如果在第23、24、28、29、32和33行应用相同的更改,脚本将输出每个生成文件的行数(评级)
我希望有帮助