mlehman / nlp-intent-toolkit

Intent recognition with OpenNLP
The Unlicense
155 stars 51 forks source link

Webserver #2

Closed bastienbot closed 8 years ago

bastienbot commented 8 years ago

Hello, first of all, I'd like to thank you for your work on this repo, it really helps me out as it's just what I need ! I have been trying for a week or two to make a webserver based on your repo but as I don't know Java at all, it hasn't been too easy to make it work...

I could have asked you how to do that two weeks ago but I dont like to give up. So I forked your repo and tried to build some sort of webserver. I first tried to wrap the java application in a ruby app, that did not work, I tried to wrap it in a nodejs app, that did not work either. Actually, when wrapped in an other application, java doesnt seem to be able to find the right console file descriptor so it kind of waits forever regardless of the input in the console.

I came up with a solution that works but is not very efficient : I setup an expressjs app, when a user sends a http request, node generates a hash and crate a files with the name [hash].source, in the mean time, the java application, watches a specific folder and awaits for a .source file to appear, as it appears, it reads the file, does whatever it has to do with the sentence, then crates a file with the same [hash].result. While java is doing this, node is waiting for a [hash].result file, when it finds it, it builds the output, send a response to the user and save the log.

Anyways, now that I have learnt java a little bit through all the changes I have made in your code, I'd like to know if there is a way with maven to easily build a webserver. Would you be able to help me with this ot is it just a huge pain in the butt ?

Thank you in advance for your response, and thank you again for your great work

PS. : my webserver works very well, here is the repo : https://github.com/bastienbot/nlp-intent-toolkit

mlehman commented 8 years ago

More of a general programming question than I expected, so I won't be able to give much advice since its not specific to this example. Maven won't help you create a web server itself, it is just a build tool like npm, but there are lighter, node-like Java web frameworks (e.g. http://sparkjava.com) that you may want to consider. There is nothing wrong with using node either, but as an improvement, you might want to consider using a queue (check out http://queues.io/) between the node and java application instead of files.

bastienbot commented 8 years ago

Don't get me wrong, I like the fact that the webserver runs under node, its the file creation/deletion process that I find very inefficient. I am going to keep working on this project with queues.io, it seems to be a very good replacement for my files job.

Would you like me to create a pull request once this is done ? If so, i'll make sure to propose the webserver as an option rather than a single way to get the result.

Thank you very much for your response, you cannot imagine how difficult it has been for me to get to this result, java is a bit disturbing at first and it was really the first time for me, now I kind of got the hang of it :)