我目前正在尝试使用Stanford CoreNLP管道来运行情感分析。我需要它遍历个别文本文件(其中包含电影评论)的文件夹,以确定每个评论的情感。我试图创建一个批处理脚本,以遍历包含评论的3个不同文件夹。通过壳浇道程序收到以下错误运行脚本时:“f此时意外” - bash脚本
f为在这个时候意外
脚本如下:
dir=C:\stanford-corenlp-full-2016-10-31
for f in "$dir\train\neg" &&
for f in "$dir\train\pos" &&
for f in "$dir\train\unsup" ; do
echo $f >> filelist.txt
java -mx8g edu.stanford.nlp.sentiment.SentimentTraining -numHid 25 -trainPath filelist.txt -devPath dev.txt -train -model model.ser.gz
done
这是第一bash脚本我曾经写过,所以我假设我的语法可能不正确的地方?
我也是使用的是Windows 10
任何意见将是惊人的,
千恩万谢
嗨你的建议一直是非常有用的。试图让我的生活变得更轻松我已经尝试将我的脚本转换为批处理脚本,以便它不应该在Windows上运行时遇到任何问题。我的新脚本如下所示:
@echo off
dir=C:\stanford-corenlp-full-2016-10-31
for %%f in "%dir\train\neg" & "%dir\train\pos" & "%dir\train\unsup" do
ECHO %%f >> filelist.txt
java -mx8g edu.stanford.nlp.sentiment.SentimentTraining -numHid 25 -trainPath filelist.txt -devPath dev.txt -train -model model.ser.gz
done
pause
这将导致以下错误: “%DIR \火车站\ POS”在这个时候
人明白我做错了意外?我假设这是某种语法问题,我只是看不到它。
我确定那不是批处理文件。批处理变量由['set'](https://ss64.com/nt/set.html)命令设置,由'%var%'使用,而不是'$ var',就像在bash中一样。 ['for'](https://ss64.com/nt/for.html)不会以'done'结尾。在批处理中没有';'(实际上是,但不会结束语句) –
因此,您正在使用Linux Windows子系统? – Squashman
对不起,我应该更好地解释一下,我正在使用Windows 10,但我已经安装了cygwin,以便能够使用linux命令更灵活地使用我的bash脚本。 – user7575479