Wordnet::Similarity server: how to talk to it from Java?
I installed the WordnetSimilarity server on my Ubuntu. I launch it with the command:
$ similarity_server.pl --logfile server.log
Now I want to use it from my Java/Groovy app, and I wrote this 开发者_StackOverflow中文版code to get the server version:
// open connection
Socket kkSocket = new Socket("localhost", 31134);
def out = new PrintWriter(kkSocket.getOutputStream(), true);
def inbuf = new BufferedReader(new InputStreamReader(kkSocket.getInputStream()));
out.write("v") // command for the server
out.write("\015\012") // end of message
out.flush()
// so far so good
println inbuf.readLine()
// no response, hanging...
Nothing happens, and the server log is empty. The server protocol is defined in here: http://search.cpan.org/~tpederse/WordNet-Similarity-2.05/utils/similarity_server.pl
The server is definitely running, because if I stop it, the socket allocation fails.
Any hint?
Cheers, Mulone
It looks like it should work. I suspect that there is a problem with the server. Some things to try:
- Are there any other clients you can use to see if the server is responding properly?
- Is there any "verbose" output option for the server?
- Is the server able to access whatever resources it needs, e.g., WordNet over an internet connection?
- Can you debug the server process?
- On the client, you can try reading one character at a time.
精彩评论