2014-09-30 30 views
1

我正在使用stanford core-nlp項目,它們提供可執行jar來執行各種nlp內容。從自動生成的文本輸出中刪除第一行

我寫的命令可以從文本文件中讀取輸入,並將jar執行結果寫入output.txt文件。

命令:java -cp stanford-ner.jar edu.stanford.nlp.ie.NERServer -port 9191 -client <input.txt> r.txt

其實這個命令是爲終端,這是要求打印的消息在終端

Input some text and press RETURN to NER tag it, or just RETURN to finish. 

但現在當我讀到來自輸入文件的內容,我不操心該消息

問題是,上面的命令寫這個消息也r.txt。有什麼方法可以排除在r.txt上寫這個消息嗎?或者任何更快的方法,一旦寫入,就從r.txt刪除第一行。

我無法更改jar文件,否則我會刪除該消息。

我正在使用linux並執行.sh文件中的上述命令。

回答

1

tail將做的工作:

java -cp stanford-ner.jar edu.stanford.nlp.ie.NERServer -port 9191 -client < input.txt | tail -n +2 > r.txt 
+0

我的問題需要給予好評,以給予好評答案 – puncrazy 2014-09-30 09:52:34

+1

:d 讓我給予好評的。 – Tomo 2014-09-30 09:53:25

+0

這真的很酷,你可以添加描述什麼'| tail -n +2' – puncrazy 2014-09-30 09:54:23