Reputation: 5407
As there's simple way to write result to output file using > <outputfule.txt>
but this does not work in my case
I have client server kind of scenario, where first I start the server -
java -mx500m -cp stanford-ner-with-classifier.jar edu.stanford.nlp.ie.NERServer -port 9191 -loadClassifier classifiers/english.all.3class.distsim.crf.ser.gz &
Now server is in listening mode. Here I am starting client instant where I have issue.
java -cp stanford-ner-with-classifier.jar edu.stanford.nlp.ie.NERServer -port 9191 -client
This ask to entere the input sentence and prints result on command line on pressing enter. I tried in this way
java -cp stanford-ner-with-classifier.jar edu.stanford.nlp.ie.NERServer -port 9191 -client > result.txt
which stops client instant. I am ok if it read input from text file and write it to resultant text file.
What is correct way to do this?
Upvotes: 2
Views: 772
Reputation: 97
If I understand your query correctly, you expect
" java -cp stanford-ner-with-classifier.jar edu.stanford.nlp.ie.NERServer -port 9191 -client "
to take input from "result.txt".
In that case, your should execute
"java -cp stanford-ner-with-classifier.jar edu.stanford.nlp.ie.NERServer -port 9191 -client < result.txt"
Corrected Reply:
Then you should try this .
"java -cp stanford-ner-with-classifier.jar edu.stanford.nlp.ie.NERServer -port 9191 -client < x.txt > y.txt"
Where you read input from x.txt and write output to y.txt
Upvotes: 2
Reputation: 1209
And if you want you can redirect both standard input and standard output at the same time:
java -cp stanford.jar NERServer -port 9191 -client < input.txt > result.txt
Or do something like this:
echo -e "line1\nline2" | java -cp stanford.jar NERServer -port 9191 -client > r.txt
When doing input/output redirection the application runs exactly the same way as if the input/output would not be redirected.
It does not know or care if you type the input from the keyboard or this is redirected from somewhere. So it will always print same things to the standard output (in your case)
press RETURN to NER tag it, or just RETURN to finish
There is nothing that you can do about this apart from throwing away the first line from the results.txt when you interpret them.
Upvotes: 1
Reputation: 27506
Try
echo "input sequence" | xargs java -cp stanford.jar NERServer -port 9191 -client > result.txt
This would be for redirecting command with parameters to the file.
If you simply want to pass arguments to a command, than you just need
java -cp stanford.jar NERServer -port 9191 -client < result.txt`
or
cat params.txt | xargs java -cp stanford.jar NERServer -port 9191 -client
xargs
should send your parameters from the file to the java
program
P.S. I omitted the package names for the sake of brevity and readability
Upvotes: 1