代码19

这是text_tech1文件的样子:

这是调用corenlp的命令行:

java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLP\
-props StanfordCoreNLP-chinese.properties -file file.log -outputFormat text

    -file后接的要处理的文件

    -outputFormat text中的text只是一种格式

为了在更细的粒度下利用corenlp进行相关操作,将每一行用逗号结尾,句号结尾的也是一行。

但直接调用corenlp命令行进行文件操作时,却发现corenlp不是以文件一行一行进行处理,而是以一个句号或者问号进行处理。解决方法是:将每一个逗号写进文件,每次让corenlp处理只含一个逗号的文件。当然需要每次调用命令行。

#!/bin/sh
touch file.out
for line in  $(cat text_tech1)
do
touch file.log
echo $line > file.log
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLP\
 -props StanfordCoreNLP-chinese.properties -file  file.log -outputFormat text
cat file.log.out >> file.out
rm file.log  
done

可以学习:对终端多次输入命令行

posted @ 2017-03-26 16:37  有梦就要去实现他  阅读(272)  评论(0编辑  收藏  举报