我目前正在嘗試使用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