Hot questions for Using Ubuntu in stanford nlp

Top Java Programmings / Ubuntu / stanford nlp

Question:

I'm trying to install Stanford Parser on Ubuntu 18.04.3, purely without installing the NLTK package, but I am not sure how it's installed to be able to use it with Java or Python.

I have already downloaded the complete package and the languages I need from the official website [Stanford Parser] [https://nlp.stanford.edu/software/lex-parser.shtml#Download ]. So, I also have Java JDK and Java JRE installed, but I can't get Stanford Parser paks detected.

I'm new at this. :-|


Answer:

  1. Download and unzip the directory
  2. cd /path/to/stanford-parser-full-2018-10-17
  3. export CLASSPATH=/path/to/stanford-parser-full-2018-10-17/*:
  4. java -Xmx5g edu.stanford.nlp.parser.lexparser.LexicalizedParser -outputFormat "penn,typedDependencies" edu/stanford/nlp/models/lexparser/englishPCFG.ser.gz data/english-onesent.txt

Question:

I downloaded stanfordCoreNLP module version stanford-corenlp-full-2018-02-27 from the download page and unzipped the file. created a example_file.txt file in the directory where it was extracted. I added the text My name is Sam. I want to be an astronaut. I had snacks a while ago.. I navigated to the folder it was extracted to and tried to run the example code given for co-reference resolution in the command line

stanfordNLP page

java -Xmx5g -cp stanford-corenlp-3.9.1.jar:stanford-corenlp-3.9.1-sources.jar:* edu.stanford.nlp.pipeline.StanfordCoreNLP -annotators tokenize,ssplit,pos,lemma,ner,parse,mention,coref -coref.algorithm neural -file example_file.txt

I am getting below error message

Exception in thread "main" java.lang.IllegalArgumentException: File doesn't exist: example_file.txt
    at edu.stanford.nlp.io.FileSequentialCollection$FileSequentialCollectionIterator.primeNextFile(FileSequentialCollection.java:364)
    at edu.stanford.nlp.io.FileSequentialCollection$FileSequentialCollectionIterator.<init>(FileSequentialCollection.java:269)
    at edu.stanford.nlp.io.FileSequentialCollection.iterator(FileSequentialCollection.java:238)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:1166)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.processFiles(StanfordCoreNLP.java:1010)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.run(StanfordCoreNLP.java:1365)
    at edu.stanford.nlp.pipeline.StanfordCoreNLP.main(StanfordCoreNLP.java:1427)

Any help on this?


Answer:

Java lookup resources within the classpath that you defined with -cp option. The directory that contains example_file.txt should probably be included in it

-cp ".:stanford-corenlp-3.9.1.jar:stanford-corenlp-3.9.1-sources.jar:*"

The dot added to the class path means this directory which apparently contains your file. Also, double quotes prevent the shell to expand the wildcard at the end that it should not be there in my opinion unless it contains jars relevant to the app. At most, it could be *.jar.

Question:

I am new to NLP. I need basic idea to get started with installation of it. I have gone through LingPipe and open NLP installation section, but i did not get why to install maven and additional training sets , models etc. Any brief explanation of installation would be helpful for me to get started with coding. Platform - Ubuntu

Sorry if this question is too generic or simple


Answer:

I used OpenNLP in my project. I think this instructions will help you to go through OpenNLP Library. Follow this document

  • Download OpenNLP Library and add it to your build path
  • Download trained models and put it to a folder
  • modelIn = new FileInputStream("path");

InputStream modelIn = null;

try {
  modelIn = new FileInputStream("en-pos-maxent.bin");
  POSModel model = new POSModel(modelIn);
}
catch (IOException e) {
  // Model loading failed, handle the error
  e.printStackTrace();
}
finally {
  if (modelIn != null) {
    try {
      modelIn.close();
    }
    catch (IOException e) {
    }
  }
}