NLP (natural language processing) service?

I wounder, if anyone, have made a service for the
CoreNlp server
?
I would like to install it on my NixOs server, since I’m developing a system that need
some text analysis.

It is not packaged. For an Ant based Java program, these docs can get you started on a working package, then you’d want to set it up in your configuration as a systemd service. If you try doing that, post your results here and I’d be glad to help.

I am getting this error.

# corenlp
Error: Could not find or load main class edu.stanford.nlp.pipeline.StanfordCoreNLP
Caused by: java.lang.ClassNotFoundException: edu.stanford.nlp.pipeline.StanfordCoreNLP

The derivations are

# cat corenlp.nix
{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation rec {
  pname = "corenlp";
  version = "4.5.7";

  src = pkgs.fetchurl {
    url = "https://nlp.stanford.edu/software/stanford-corenlp-${version}.zip";
    sha256 = "1vvlkkg7n87shf877dinc2bmqa807mk9d36pdma39y5rkn71scbx"; # Replace with actual hash
  };
  
  nativeBuildInputs = [ pkgs.unzip pkgs.makeWrapper ];
  # stripJavaArchivesHook];

  buildPhase = ''
    runHook preBuild
    unzip $src -d $out/
    runHook postBuild
  '';

  installPhase = ''
    runHook preInstall
    mkdir -p $out/share/java $out/bin
    find $out/stanford-corenlp-${version} -name "*.jar" -exec install -Dm644 {} $out/share/java/ \;
    CLASSPATH=$(find $out/share/java -name "*.jar" | tr '\n' ':')
    makeWrapper ${pkgs.jre}/bin/java $out/bin/corenlp \
      --set CLASSPATH "$CLASSPATH" \
      --add-flags "-mx3g -cp $out/share/java edu.stanford.nlp.pipeline.StanfordCoreNLP" 
    makeWrapper ${pkgs.jre}/bin/java $out/bin/corenlp-server \
      --set CLASSPATH "$CLASSPATH" \
      --add-flags "-mx4g -cp $out/share/java edu.stanford.nlp.pipeline.StanfordCoreNLPServer"
    runHook postInstall
  '';

  meta = with pkgs.lib; {
    description = "Stanford CoreNLP suite of tools for natural language processing.";
    homepage = "https://stanfordnlp.github.io/CoreNLP/";
    license = licenses.gpl3; 
    maintainers = with maintainers; [ Isomorph70 ];
  };
}

and

# cat corenlp-english.nix 
{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation rec {
  pname = "corenlp-english";
  version = "4.5.7";
  fname = "stanford-corenlp-${version}-models-english.jar";
  src = pkgs.fetchurl {
    url = "https://nlp.stanford.edu/software/${fname}";
    sha256 = "0ng1nnnvy26mfcx3s8mbnb9blssa9d2gjgfvc5l9x895yxyhw9pv"; # Replace with actual hash
  };

  buildInputs = [ pkgs.corenlp ];
  nativeBuildInputs = [ pkgs.jre ];
  # Disable unpackPhase
  unpackPhase = ":";
    	
  installPhase = ''
    mkdir -p $out/share/java
    install -Dm644 $src $out/share/java/$fname
  '';

  meta = with pkgs.lib; {
    description = "Stanford CoreNLP suite of tools for natural language processing.";
    homepage = "https://stanfordnlp.github.io/CoreNLP/index.html#quickstart";
    license = licenses.gpl2; 
    maintainers = with maintainers; [ Isomorph70 ];
  };
}

Got it to work.

{ pkgs ? import <nixpkgs> {} }:

pkgs.stdenv.mkDerivation rec {
  pname = "corenlp";
  version = "4.5.7";

  src = pkgs.fetchurl {
    url = "https://nlp.stanford.edu/software/stanford-corenlp-${version}.zip";
    sha256 = "1vvlkkg7n87shf877dinc2bmqa807mk9d36pdma39y5rkn71scbx";
  };
  
  nativeBuildInputs = [ pkgs.unzip pkgs.makeWrapper ];
  # stripJavaArchivesHook];
  buildInputs = [ pkgs.jre ]; 
 
  buildPhase = ''
    runHook preBuild
    unzip $src -d $out/
    runHook postBuild
  '';

  classpath = "export CLASSPATH=\$(find /run/current-system/sw/share/java/ -name \"*.jar\" | xargs realpath | tr \"\\n\" \":\" )" ;
  installPhase = ''
    runHook preInstall
    mkdir -p $out/share/java/corenlp $out/bin
    find $out/stanford-corenlp-${version} -name "*.jar" -exec install -Dm644 {} $out/share/java/corenlp/ \;
    makeWrapper ${pkgs.jre}/bin/java $out/bin/corenlp \
      --run "$classpath" \
      --add-flags "-mx3g edu.stanford.nlp.pipeline.StanfordCoreNLP"
    makeWrapper ${pkgs.jre}/bin/java $out/bin/corenlp-server \
      --run "$classpath" \
      --add-flags "-mx4g edu.stanford.nlp.pipeline.StanfordCoreNLPServer"
    runHook postInstall
  '';

  meta = with pkgs.lib; {
    description = "Stanford CoreNLP suite of tools for natural language processing.";
    homepage = "https://stanfordnlp.github.io/CoreNLP/";
    license = licenses.gpl3; 
    maintainers = with maintainers; [ Isomorph70 ];
  };
}

I could not get the automatic generation via jre of CLASSPATH to work. But put an automatic generation in the scripts that is made via makeWrapper.