CoreNLP
CoreNLP copied to clipboard
Running CoreNLP server without internet (offline)
I have read this question https://github.com/stanfordnlp/CoreNLP/issues/384 but it doesn't give a definitive answer.
I can run the server on a windows machine with the command line
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000
the server starts and i can connect to it with a web browser by entering 127.0.0.1:9000 into the browser url bar.
But when inspecting the request in browser dev tool it seems the javascript and other resource files are loading from online sources line standford.edu, cloudflare, jquery, bootstrap etc.
This causes the webpage to break.

also the submit button doesn't work.
Is there a workaround to this to get it to work without an internet connection?
We've never given any consideration to packaging all the assets so the server can work without an internet connection, but it's probably something you can do.
Hi, yes i tried doing that but I didn't know where to start? I don't see any folder with css or js files and the url's to access these may be coded into the jar, I'm not sure if there is any external config file to change those paths. Could you please provide any pointers about where to start digging in.
Probably corenlp-brat.html? It will require rebuilding the jar to make any such edits take effect. The jar program should assist with that (jar -xvf, jar -cvf or jar -u, etc)
Ok thanks for that info, I see some more things being reference in here
I see that the html file you linked (corenlp-brat.html) has the links that we need to modify, i'll try that and see where it goes' will ping back again if i get stuck. thanks.
ok, so i tried doing this, i renamed the stanford-corenlp-4.5.3.jar to zip and then extracted it and found the corenlp-brat.html inside it.
Then downnloaded all the resources and saved it in the same dir as corenlp-brat.html
then changed all the links in corenlp-brat.html to take it from local

then i repackaged the zip to jar and restarted the server but it still can't find the resources. Am I missing something.
I'm not a webdev and I'm secretly hoping that this whole thread goes away without me having to actually do anything. However, looking at the change you made, my first guess is that if you go to http://localhost:9000 and request the page, the local reference src="jquery-2.1.4.min.js" tries to download http://localhost:9000/jquery-2.1.4.min.js but the CoreNLP server has no idea how to do that. What you can do instead is set up a container (Flask? I don't know what kids use these days tbh) on, say, port 8888 which
- serves all of the pages you care about such as jquery-2.1.4.min.js and
- sends requests to the "/" endpoint to the CoreNLP server running at port
- Again, I don't know anything about webdev and these are just words I've heard people say in the past which hopefully correspond in some way to reality.
Also, just a random aside, if you cut & paste text instead of an image it would be a lot easier for me to copy / paste sections of the xml that I care about, plus my gmail account will fill up slower I suppose
On Fri, May 5, 2023 at 2:49 PM mercurial-moon @.***> wrote:
ok, so i tried doing this, i renamed the stanford-corenlp-4.5.3.jar to zip and then extracted it and found the corenlp-brat.html inside it. Then downnloaded all the resources and saved it in the same dir as corenlp-brat.html then changed all the links in corenlp-brat.html to take it from local
then i repackaged the zip to jar and restarted the server but it still can't find the resources. Am I missing something.
— Reply to this email directly, view it on GitHub https://github.com/stanfordnlp/CoreNLP/issues/1356#issuecomment-1536819703, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2AYWNMBRU3QZRVCUO4FCDXEVYVTANCNFSM6AAAAAAXXH2LAI . You are receiving this because you commented.Message ID: @.***>
I appreciate your help At this link i see some code where the java server is handling 2 files internal Java web server
The relevant lines are
withAuth(server.createContext(uriContext+"/corenlp-brat.js", new FileHandler("edu/stanford/nlp/pipeline/demo/corenlp-brat.js", "application/javascript")), basicAuth);
withAuth(server.createContext(uriContext+"/corenlp-brat.cs", new FileHandler("edu/stanford/nlp/pipeline/demo/corenlp-brat.css", "text/css")), basicAuth);
Do you think that add the other resources to this file will do the job? I was trying to avoid compling the jar, but it seems the only way at the moment.
It might work! Clearly I don't know all the internals of the server...
On Sat, May 6, 2023 at 1:09 AM mercurial-moon @.***> wrote:
I appreciate your help At this link i see some code where the java server is handling 2 files internal Java web server https://github.com/stanfordnlp/CoreNLP/blob/139893242878ecacde79b2ba1d0102b855526610/src/edu/stanford/nlp/pipeline/StanfordCoreNLPServer.java#L1546-L1559
The relevant lines are withAuth(server.createContext(uriContext+"/corenlp-brat.js", new FileHandler("edu/stanford/nlp/pipeline/demo/corenlp-brat.js", "application/javascript")), basicAuth); withAuth(server.createContext(uriContext+"/corenlp-brat.cs", new FileHandler("edu/stanford/nlp/pipeline/demo/corenlp-brat.css", "text/css")), basicAuth);
Do you think that add the other resources to this file will do the job? I was trying to avoid compling the jar, but it seems the only way at the moment.
— Reply to this email directly, view it on GitHub https://github.com/stanfordnlp/CoreNLP/issues/1356#issuecomment-1537085666, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2AYWPUCUPGBB5MVRN7K6LXEYBM5ANCNFSM6AAAAAAXXH2LAI . You are receiving this because you commented.Message ID: @.***>
So I finally got it to work without compiling the jar, Steps as under for version 4.5.3
- Rename the
stanford-corenlp-4.5.3.jarto zip (your jar may be different based on the version of Stanford NLP) - Extract the zip to some folder and go to this path inside the zip
edu\stanford\nlp\pipeline\demo - There you need to edit 2 files
corenlp-brat.htmlandcorenlp-brat.js - These files refer to number of external resources that first need to be downloaded and stored on your computer.
- Note down the external link from each file and and paste it in the browser and download the file, make sure you maintain the relative path.
- Rename each link in the files and modify it to
http://localhost/...instead of the external link. - Repackage all the files\folders of the zip and rename to jar.
- Overwrite the original
stanford-corenlp-4.5.3.jarwith the new modified jar. - Copy the downloaded resources to a folder, these need to be served by a local webserver that runs on your pc. Use any server like xampp, caddy, redbean etc. I chose caddy.
- Put all the resources in a folder and keep it next to the caddy executable. Run caddy with
caddy file-server --root "path to folder where caddy resides" - Fire up core nlp server with
java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000 - Open a browser and visit
localhost:9000, and if all goes well you should be able to see the main page of Core Nlp, similar to the online demo
Thanks for the detailed explanation!
On Fri, May 19, 2023 at 9:49 PM mercurial-moon @.***> wrote:
So I finally got it to work without compiling the jar, Steps as under for version 4.5.3
- Rename the stanford-corenlp-4.5.3.jar to zip (your jar may be different based on the version of Stanford NLP)
- Extract the zip to some folder and go to this path inside the zip edu\stanford\nlp\pipeline\demo
- There you need to edit 2 files corenlp-brat.html and corenlp-brat.js
- These files refer to number of external resources that first need to be downloaded and stored on your computer.
- Note down the external link from each file and and paste it in the browser and download the file, make sure you maintain the relative path.
- Copy the downloaded resources to a folder, these need to be served by a local webserver that runs on your pc. Use any server like xampp, caddy, redbean etc. I chose caddy.
- Put all the resources in a folder and keep it next to the caddy executable. Run caddy with caddy file-server --root "path to folder where caddy resides"
- Fire up core nlp server with java -mx4g -cp "*" edu.stanford.nlp.pipeline.StanfordCoreNLPServer -port 9000 -timeout 15000
- Open a browser and visit localhost:9000, and if all goes well you should be able to see the main page of Core Nlp, similar to the online demo
— Reply to this email directly, view it on GitHub https://github.com/stanfordnlp/CoreNLP/issues/1356#issuecomment-1555532571, or unsubscribe https://github.com/notifications/unsubscribe-auth/AA2AYWMCWDXLF5UW2XOTGW3XHBEMLANCNFSM6AAAAAAXXH2LAI . You are receiving this because you commented.Message ID: @.***>