### Run Stanford CoreNLP Example Demo Application Source: https://github.com/stanfordnlp/corenlp/blob/main/examples/sample-maven-project/README.txt Executes a specific Stanford CoreNLP example application using Maven's `exec:java` plugin. This command allows you to run the main class of a demo application directly from the command line, demonstrating CoreNLP's capabilities. ```bash mvn exec:java -Dexec.mainClass="edu.stanford.nlp.StanfordCoreNLPEnglishTestApp" ``` -------------------------------- ### Build Stanford CoreNLP Maven Project Source: https://github.com/stanfordnlp/corenlp/blob/main/examples/sample-maven-project/README.txt Compiles the Stanford CoreNLP Maven project. This command resolves all project dependencies, compiles the source code, and prepares the application for execution, ensuring all necessary libraries are in place. ```bash mvn compile ``` -------------------------------- ### Run Stanford POS Tagger GUI Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tagger/README.txt Instructions for launching the graphical user interface of the Stanford POS Tagger. This GUI is primarily for demonstration purposes and can be started directly via a Java command or using platform-specific scripts. ```Java java -mx200m -classpath stanford-postagger.jar edu.stanford.nlp.tagger.maxent.MaxentTaggerGUI models/wsj-0-18-left3words-distsim.tagger ``` ```Batch stanford-postagger-gui.bat ``` ```Shell ./stanford-postagger-gui.sh ``` -------------------------------- ### Run Tsurgeon with a Transformation Script Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tsurgeon/README-tsurgeon.txt This example demonstrates how to execute Tsurgeon from the command line. It specifies an input tree file and applies predefined transformation scripts (exciseNP, renameVerb) to the trees within that file. ```Shell ./tsurgeon.csh -treeFile atree exciseNP renameVerb ``` -------------------------------- ### Initialize a GraphicalModel in Java Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/loglinear/QUICKSTART.txt This snippet demonstrates the basic instantiation of a `GraphicalModel` object, which is the foundational structure for building statistical models in the `loglinear` package. ```java GraphicalModel model = new GraphicalModel(); ``` -------------------------------- ### Terminal Interaction Startup Notice for GPL Programs Source: https://github.com/stanfordnlp/corenlp/blob/main/licenses/gpl-3.0/LICENSE.txt This snippet shows a short notice to be displayed by a program when it starts in an interactive terminal mode. It informs users about the lack of warranty and the free software nature, suggesting hypothetical commands (`show w`, `show c`) to access more detailed license information. ```Terminal Output Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Applying GNU GPL to Source Files: Copyright and License Notice Source: https://github.com/stanfordnlp/corenlp/blob/main/LICENSE.txt This snippet provides the standard copyright and license notice to be attached to the start of each source file when distributing a program under the GNU General Public License. It includes placeholders for the program name, year, and author, and directs users to the full GPL text. ```Plaintext Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Tsurgeon Example Operations: delete, prune, excise, relabel Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tsurgeon/README-tsurgeon.txt Demonstrates the usage and effects of 'delete', 'prune', 'excise', and 'relabel' commands on a sample parse tree, highlighting their differences and specific behaviors in tree manipulation. ```APIDOC Initial Tree (used in all examples): (ROOT (S (NP (NNP Maria_Eugenia_Ochoa_Garcia)) (VP (VBD was) (VP (VBN arrested) (PP (IN in) (NP (NNP May))))) (. .))) Apply delete: Command: VP < PP=prep delete prep Result: (ROOT (S (NP (NNP Maria_Eugenia_Ochoa_Garcia)) (VP (VBD was) (VP (VBN arrested) (. .))) Description: The PP node directly dominated by a VP is removed, as is everything under it. Apply prune: Command: S < (NP < NNP=noun) prune noun Result: (ROOT (S (VP (VBD was) (VP (VBN arrested) (PP (IN in) (NP (NNP May))))) (. .))) Description: The NNP node is removed, and since this results in the NP above it having no terminal children, the NP node is deleted as well. Note: This is different from delete in which the NP above the NNP would remain. Apply excise: Command 1: VP < PP=prep excise prep prep Result 1: (ROOT (S (NP (NNP Maria_Eugenia_Ochoa_Garcia)) (VP (VBD was) (VP (VBN arrested) (IN in) (NP (NNP May))))) (. .))) Description 1: The PP node is removed, and all of its children are added in the place it was previously located. Command 2: VP=verb < PP=prep excise verb prep Result 2: (ROOT (S (NP (NNP Maria_Eugenia_Ochoa_Garcia)) (VP (VBD was) (IN in) (NP (NNP May))) (. .))) Description 2: Removes all the nodes from the first named node to the second named node, and the children of the second node are added as children of the parent of the first node. Apply relabel: Command 1: VP=v < PP=prep relabel prep verbPrep Result 1: (ROOT (S (NP (NNP Maria_Eugenia_Ochoa_Garcia)) (VP (VBD was) (VP (VBN arrested) (verbPrep (IN in) (NP (NNP May))))) (. .))) Description 1: The label for the node called prep (PP) is changed to verbPrep. Command 2 (using regex): /^VB.+/=v relabel v /^VB(.*)$/ #1 Result 2: (ROOT (S (NP (NNP Maria_Eugenia_Ochoa_Garcia)) (VP (D was) Description 2: Relabels nodes whose labels match the regex /^VB.+/ by applying a regex replacement. ``` -------------------------------- ### Displaying GNU GPL Notice in Interactive Programs Source: https://github.com/stanfordnlp/corenlp/blob/main/LICENSE.txt This snippet shows a short notice to be displayed by programs that have terminal interaction when they start in an interactive mode. It informs users about the warranty status and redistribution conditions, suggesting commands to view full license details. ```Plaintext Copyright (C) This program comes with ABSOLUTELY NO WARRANTY; for details type `show w'. This is free software, and you are welcome to redistribute it under certain conditions; type `show c' for details. ``` -------------------------------- ### Running Stanford NER from Command Line Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/ner/README.txt Demonstrates how to execute the Stanford Named Entity Recognizer from the command line using pre-trained models. This includes basic text tagging and outputting results in a tab-separated format. Requires Java 1.8+ and proper CLASSPATH setup. ```Shell java -mx600m -cp stanford-ner.jar:lib/* edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier classifiers/english.all.3class.distsim.crf.ser.gz -textFile sample.txt ``` ```Shell java -mx600m -cp stanford-ner.jar:lib/* edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier classifiers/english.all.3class.distsim.crf.ser.gz -outputFormat tabbedEntities -textFile sample.txt > sample.tsv ``` -------------------------------- ### Compile Stanford CoreNLP with Ant Source: https://github.com/stanfordnlp/corenlp/blob/main/README.md This command navigates into the CoreNLP project directory and initiates the compilation process using Apache Ant. Ensure Ant is installed and configured correctly in your environment before running this command. ```Shell cd CoreNLP ; ant ``` -------------------------------- ### Run Stanford NER Server with a Pre-trained Classifier Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/ner/README-cyc.txt This command initiates the Stanford Named Entity Recognition (NER) server, loading a specified pre-trained classifier. It allocates 1GB of memory to the Java Virtual Machine (-mx1000m) and includes necessary JAR files (stanford-ner.jar and all in lib/) in the classpath. The server listens for connections on the specified port (1234 in this example). Classifiers can be loaded from local file paths or from resources embedded within JAR files present on the classpath, enabling single JAR file deployments. ```bash java -mx1000m -cp stanford-ner.jar:lib/* edu.stanford.nlp.ie.NERServer -loadClassifier models/all.3class.crf.ser.gz 1234 ``` -------------------------------- ### Install Stanford CoreNLP Language Models to Local Maven Repository Source: https://github.com/stanfordnlp/corenlp/blob/main/README.md This Maven command installs a specific Stanford CoreNLP language model JAR (e.g., Spanish models) into your local Maven repository. This makes the model available as a dependency for other Maven projects, allowing them to easily include the necessary language resources without manual classpath management. ```Maven mvn install:install-file -Dfile=/location/of/stanford-spanish-corenlp-models-current.jar -DgroupId=edu.stanford.nlp -DartifactId=stanford-corenlp -Dversion=4.5.4 -Dclassifier=models-spanish -Dpackaging=jar ``` -------------------------------- ### Compile and Run Custom Java Program with Stanford POS Tagger Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tagger/README.txt Illustrates how to compile a custom Java application (TaggerDemo.java) that integrates the Stanford POS Tagger library and then execute it. This example shows how to specify the classpath and provide a tagger model and input file. ```Java javac -cp stanford-postagger.jar TaggerDemo.java ``` ```Java java -cp ".:stanford-postagger.jar" TaggerDemo models/wsj-0-18-left3words-distsim.tagger sample-input.txt ``` -------------------------------- ### Optimize GraphicalModel Weights in Java Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/loglinear/QUICKSTART.txt This code demonstrates the process of optimizing the weights for a `GraphicalModel` dataset. It initializes an optimizer (e.g., `BacktrackingAdaGradOptimizer`), sets up a `LogLikelihoodFunction`, and calls `optimize` with the training data and regularization constant to find optimal model parameters. ```java GraphicalModel[] trainingSet = //omitted dataset construction; // Create the optimizer we will use AbstractBatchOptimizer opt = new BacktrackingAdaGradOptimizer(); // Call the optimizer, with a dataset, a function to optimize, initial weights, and l2 regularization constant ConcatVector weights = opt.optimize(trainingSet, new LogLikelihoodFunction(), new ConcatVector(0), 0.1); ``` -------------------------------- ### Perform NER Tagging from Command Line Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/ner/README-cyc.txt Examples for performing Named Entity Recognition on a text file directly from the command line. This requires Java to be on the PATH and the stanford-ner.jar file in the CLASSPATH. It demonstrates loading a specific classifier and processing a sample text file. ```Shell ner file ``` ```Java java -mx600m edu.stanford.nlp.ie.crf.CRFClassifier -loadClassifier classifiers/ner-eng.8class.better.crf.gz -textFile sample.txt ``` ```Java java -mx300m -cp stanford-ner.jar edu.stanford.nlp.ie.crf.CRFClassifier -textFile sample.txt ``` -------------------------------- ### Start Stanford NER as a Socket Server Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/ner/README-cyc.txt Instructions for running the Stanford NER system as a network server, listening on a specified port. This allows external applications to send text for NER processing over a socket. It supports loading classifiers from disk or from within the JAR file. ```Java java -mx1000m -cp stanford-ner.jar:lib/* edu.stanford.nlp.ie.NERServer 1234 ``` ```Java java -mx1000m -cp stanford-ner.jar:lib/* edu.stanford.nlp.ie.NERServer -loadClassifier classifiers/all.3class.crf.ser.gz 1234 ``` -------------------------------- ### Rebuild TregexParser with javacc Source: https://github.com/stanfordnlp/corenlp/blob/main/src/edu/stanford/nlp/trees/tregex/REBUILD-NOTES.txt Instructions to rebuild the `TregexParser.jj` file using the `javacc` tool. This step is necessary after making changes to the parser's grammar definition. ```shell javacc TregexParser.jj ``` -------------------------------- ### Set Maven JVM Memory for Stanford CoreNLP Source: https://github.com/stanfordnlp/corenlp/blob/main/examples/sample-maven-project/README.txt Configures the maximum heap size for the Maven JVM. This is crucial for Stanford CoreNLP applications, especially when processing large text datasets, to prevent out-of-memory errors during compilation or execution. ```bash export MAVEN_OPTS="-Xmx14000m" ``` -------------------------------- ### Clone Stanford CoreNLP Language Models using Git LFS Source: https://github.com/stanfordnlp/corenlp/blob/main/README.md These commands demonstrate how to obtain Stanford CoreNLP language models (e.g., French) from the Hugging Face Hub using Git Large File Storage (LFS). First, ensure Git LFS is installed on your system, then use `git clone` to download the specific model repository, which handles large files efficiently. ```Git git lfs install git clone https://huggingface.co/stanfordnlp/corenlp-french ``` -------------------------------- ### Tregex Backreferencing Pattern for Identical Nodes Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tregex/README-tregex.txt Illustrates a Tregex pattern using backreferencing (e.g., '=comma') to ensure multiple parts of the pattern match the exact same tree node. This example matches an NP dominating exactly the sequence NP, NP, where the mother NP has no other daughters. ```Tregex (@NP <, (@NP $+ (/,/ $+ (@NP $+ /,/=comma))) <- =comma) ``` -------------------------------- ### Add a Featurized Factor to GraphicalModel in Java Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/loglinear/QUICKSTART.txt This advanced example demonstrates adding a factor to a `GraphicalModel` with a custom featurization closure. It shows how to extract variable assignments, create `ConcatVector` features (dense and sparse), and return them for model training. ```java int[] neighbors = new int[]{2,7}; int[] neighborSizes = new int[]{3,2}; // This must appear in the same order as neighbors model.addFactor(neighbors, neighborSizes, (int[] assignment) -> { // This is how assignment[] is structured int variable2Assignment = assignment[0]; int variable7Assignment = assignment[1]; // Create a new ConcatVector with 2 segments: ConcatVector features = new ConcatVector(); // Add a dense feature as feature 0, of length 2 // (Dense features in ConcatVector's are mostly used for embeddings) features.setDenseComponent(0, new double[]{ variable2Assignment * 2 + variable7Assignment, variable2Assignment + variable7Assignment * 2, }); // Add a sparse (one-hot) feature as feature 1 int sparseIndex = variable2Assignment; double sparseValue = 1.0; features.setSparseComponent(1, sparseIndex, sparseValue); // Return our feature set to complete the closure return features; }); ``` -------------------------------- ### Perform Inference and Calculate MAP/Marginals with CoreNLP CliqueTree Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/loglinear/QUICKSTART.txt This Java snippet illustrates the process of performing inference using Stanford CoreNLP's `CliqueTree`. It initializes a `CliqueTree` instance with a `GraphicalModel` and `ConcatVector` of weights, then calls `calculateMAP()` to get the Maximum A Posteriori assignment and `calculateMarginals()` to obtain global marginal probabilities. The `mapAssignment` array provides assignments for variables by index, while `marginalProbabilities` provides an array of doubles for each variable's possible assignments. ```Java GraphicalModel model = // see previous section; ConcatVector weights = // see first section; CliqueTree tree = new CliqueTree(model, weights); int[] mapAssignment = tree.calculateMAP(); double[][] marginalProbabilities = tree.calculateMarginals(); ``` -------------------------------- ### Tregex Variable Group Coindexation Pattern Example Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tregex/README-tregex.txt An example Tregex pattern designed for Penn Treebank trees that uses variable groups ('%index') to match an SBAR where the WH- node is coindexed with a trace node, ensuring their captured strings are identical. ```Tregex @SBAR < /^WH.*-([0-9]+)$/#1%index<<(__=empty < (/^-NONE-/< /^\\*T\\*-(?:[0-9]+)$/#1%index)) ``` -------------------------------- ### Tsurgeon Command Line Options Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tsurgeon/README-tsurgeon.txt This section details the available command-line arguments for running Tsurgeon. It covers options for specifying input tree files, applying single pattern-operation pairs directly, and controlling the output format. ```APIDOC -treeFile specify the name of the file that has the trees you want to transform. -po Apply a single operation to every tree using the specified match pattern and the specified operation. -s Prints the output trees one per line, instead of pretty-printed. ``` -------------------------------- ### Source File Copyright and License Notice for GPL Programs Source: https://github.com/stanfordnlp/corenlp/blob/main/licenses/gpl-3.0/LICENSE.txt This snippet provides the recommended boilerplate text to include at the beginning of each source file for programs distributed under the GNU General Public License. It specifies copyright information, the chosen license version, and a clear disclaimer of warranty, directing users to the full license text. ```License Boilerplate Copyright (C) This program is free software: you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY and FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with this program. If not, see . ``` -------------------------------- ### Launch Stanford NER GUI Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/ner/README-cyc.txt Instructions for launching the Stanford NER graphical user interface on Windows, Linux, Unix, and MacOSX. This method provides a visual interface for loading classifiers and tagging text files or web pages. It's recommended to use the provided scripts to ensure sufficient memory allocation. ```Shell ner-gui.bat ``` ```Shell ner-gui.sh ``` ```Java java -mx300m -jar stanford-ner.jar ``` -------------------------------- ### Launch Stanford Parser GUI (Windows Batch) Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt This batch command launches the graphical user interface for the Stanford Lexicalized Parser on Windows systems. It provides an interactive way to load files, select parsers, and view parsing results, requiring Java to be on the system's PATH. ```Batch lexparser-gui.bat ``` -------------------------------- ### Combine Multiple NER Models with NERClassifierCombiner Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/ner/README.txt Demonstrates how to use `NERClassifierCombiner` from the command line to apply multiple CRF-based NER models sequentially. This example processes a text file and explicitly disables SUTime for rule-based time expression recognition. ```Java java -mx2g edu.stanford.nlp.ie.NERClassifierCombiner -ner.model \ classifiers/english.conll.4class.distsim.crf.ser.gz,classifiers/english.muc.7class.distsim.crf.ser.gz \ -ner.useSUTime false -textFile sample-w-time.txt ``` -------------------------------- ### Execute Stanford Chinese Segmenter Java Demo Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/segmenter/README-Chinese.txt This command shows how to run the `SegDemo` Java class directly from the command line. It requires setting the classpath to include the necessary JARs and specifies the input file. Users might need to adjust memory allocation and dictionary paths for large datasets or custom environments. ```shell java -mx2g -cp "*:." SegDemo test.simp.utf8 ``` -------------------------------- ### Label Variables for GraphicalModel Training in Java Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/loglinear/QUICKSTART.txt This snippet illustrates how to assign training labels to specific variables within a `GraphicalModel`. It uses `LogLikelihoodFunction.VARIABLE_TRAINING_VALUE` to mark the desired assignment for training purposes, essential for supervised learning. ```java GraphicalModel model = new GraphicalModel(); // Omitted model construction, see previous section // Tell LogLikelihood to treat variable 2 as having the assignment "1" in training labels model.getVariableMetadataByReference(2).put(LogLikelihoodFunction.VARIABLE_TRAINING_VALUE, "1"); // Tell LogLikelihood to treat variable 7 as having the assignment "0" in training labels model.getVariableMetadataByReference(7).put(LogLikelihoodFunction.VARIABLE_TRAINING_VALUE, "0"); ``` -------------------------------- ### Add a Basic Factor to GraphicalModel in Java Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/loglinear/QUICKSTART.txt This code shows how to add a factor to a `GraphicalModel`. A factor connects variables (specified by `neighbors`) and defines their state sizes (`neighborSizes`). The closure currently returns a placeholder `ConcatVector`. ```java int[] neighbors = new int[]{2,7}; int[] neighborSizes = new int[]{3,2}; // This must appear in the same order as neighbors model.addFactor(neighbors, neighborSizes, (int[] assignment) -> { // TODO: In the next paragraph we'll discuss featurizing each possible assignment to neighbors return new ConcatVector(0); }); ``` -------------------------------- ### Run Stanford CoreNLP Lexical Parser Training/Testing Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt Executes the `lexparser-lang-train-test.sh` script for training and evaluating new language-specific grammars within the Stanford CoreNLP lexical parser framework. ```bash lexparser-lang-train-test.sh ``` -------------------------------- ### Stanford Chinese Segmenter Command Line Interface Reference Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/segmenter/README-Chinese.txt Comprehensive documentation for the command-line interfaces provided by the Stanford Chinese Segmenter, including `segment.sh` and the `SegDemo` Java class. It details available parameters, their types, and descriptions for configuring segmentation behavior, input/output, and memory usage. ```APIDOC segment.sh command: Description: Runs the Stanford Chinese Segmenter from the Unix command line. Syntax: segment.sh [-k] [ctb|pku] Parameters: -k: (Optional) Keep all white spaces in the input. ctb|pku: (Required) Segmentation model to use. 'ctb' for Chinese Treebank, 'pku' for Beijing University. filename: (Required) The path to the file to be segmented. Each line is treated as a sentence. encoding: (Required) Character encoding of the input file (e.g., UTF-8, GB18030). Must be a Java-known encoding name. size: (Required) Size of the n-best list. Use '0' to print only the best hypothesis without probabilities. Notes: - Large files may require increasing Java memory allocation (e.g., change -mx2g to -mx8g in segment.sh). - Splitting large files into smaller ones can reduce memory usage. SegDemo Java class execution: Description: Demonstrates how to call the segmenter using a Java class from the command line. Syntax: java -mx -cp "*:." SegDemo Parameters: -mx: (Optional) Java maximum heap size (e.g., -mx2g). -cp "*:.": (Required) Sets the classpath to include current directory and all JARs. SegDemo: (Required) The main class to execute. filename: (Required) The path to the file to be segmented (e.g., test.simp.utf8). Notes: - Assumes execution in the installation's home directory. - If running elsewhere, the path to dictionaries must be explicitly set. ``` -------------------------------- ### Run Treebank Preprocessor for ATB Data (Shell) Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt Executes the Treebank Preprocessor to generate ATB data. This command requires updating configuration file paths to local treebank distributions and setting the classpath in the `cmd_line` variable of `run-tb-preproc`. Configuration files are located in the `/conf` directory. ```Shell bin/run-tb-preproc -v conf/atb-latest.conf ``` -------------------------------- ### Run Tregex from Command Line Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tregex/README-tregex.txt Demonstrates how to execute Tregex from the command line using a shell script. It searches for verb phrases (VP) dominating a past-tense verb (VBD) and a noun phrase (NP) within a specified corpus directory. ```Shell ./tregex.sh 'VP < VBD < NP' corpus_dir ``` -------------------------------- ### Command Line Interface and Configuration for Stanford Classifier Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/classify/README.txt This section details how to run the Stanford Classifier from the command line using `ColumnDataClassifier` and configure its behavior through property files. It covers specifying training/test data, various feature extraction methods like n-grams, string values, and real-valued features, and options for serializing the trained classifier. ```APIDOC Command Line Execution: java -cp "*:." edu.stanford.nlp.classify.ColumnDataClassifier -prop Property File Configuration Options (e.g., examples/cheese2007.prop): Feature Specification: - useClassFeature: Boolean. Indicates if a feature based on class frequency in the training set should be used. - .useNGrams=true: Boolean. Creates n-gram features for values in the specified column (0-indexed). Example: "1.useNGrams=true". - .useString=true: Boolean. Uses the string value in the specified column as a categorical feature. Example: "1.useString=true". - .splitWordsRegexp=[ ] .useSplitWords=true: Configures splitting a longer string into bag-of-words features using a specified regular expression for splitting. Example: "1.splitWordsRegexp=[ ] 1.useSplitWords=true". - .realValued=true: Boolean. Adds the number in the specified column as a feature value. Example: "2.realValued=true". - .logTransform: Boolean. Performs a log transform on the real-valued feature in the specified column. Example: "2.logTransform=true". - .logitTransform: Boolean. Performs a logit transform on the real-valued feature in the specified column. Example: "2.logitTransform=true". Data File Specification: - trainFile=/myPath/myTrainFile.train: Path to the training data file. - testFile=/myPath/myTestFile.test: Path to the test data file. Serialization: - serializeTo=/myPath/serializedClassifier.ser: Path to serialize the trained classifier. ``` -------------------------------- ### Stanford Arabic Segmenter Command-Line Options Reference Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/segmenter/README-Arabic.txt This section provides a comprehensive reference for the various command-line options available for the `edu.stanford.nlp.international.arabic.process.ArabicSegmenter` tool. It includes options for specifying input/output, clitic marking, orthographic normalization, and dialectal processing. ```APIDOC edu.stanford.nlp.international.arabic.process.ArabicSegmenter Command-Line Options: -loadClassifier - Description: Specifies the path to the serialized classifier model. - Example: -loadClassifier data/arabic-segmenter-atb+bn+arztrain.ser.gz -textFile - Description: Specifies the input text file for segmentation. The file should be newline-delimited and UTF-8 encoded. - Example: -textFile my_arabic_file.txt -prefixMarker - Description: Character to mark proclitics split by the segmenter. This character will be inserted before the proclitic. - Example: -prefixMarker # (Output: AA# BBB) -suffixMarker - Description: Character to mark enclitics split by the segmenter. This character will be inserted before the enclitic. - Example: -suffixMarker # (Output: BBB #CC) -orthoOptions - Description: Configures orthographic normalization options for `edu.stanford.nlp.international.arabic.process.ArabicTokenizer`. Options must be consistent between training and test time. - Supported Options: - useUTF8Ellipsis : Replaces sequences of three or more full stops with the Unicode ellipsis character (U+2026). - normArDigits : Converts Arabic digits to their ASCII equivalents. - normArPunc : Converts Arabic punctuation characters to their ASCII equivalents. - normAlif : Normalizes all variant forms of the Arabic alif to a bare alif. - normYa : Maps the Arabic letter ya (U+064A) to alif maqsura (U+0649). - removeDiacritics : Strips all diacritical marks from the text. - removeTatweel : Removes the tatweel (elongation) character (U+0640). - removeQuranChars : Removes specific diacritics that are primarily found in Quranic text. - removeProMarker : Removes the ATB (Arabic Treebank) null pronoun marker. - removeSegMarker : Removes the ATB clitic segmentation marker. - removeMorphMarker : Removes the ATB morpheme boundary markers. - removeLengthening : Replaces sequences of three or more identical characters with a single instance of that character. - atbEscaping : Replaces left and right parentheses with ATB escape characters. -domain - Description: Specifies the dialect for segmentation, enabling domain adaptation. For example, 'arz' indicates Egyptian dialect. - Example: -domain arz -withDomains - Description: Enables per-line dialect specification in the input file. Each line should begin with a dialect code (e.g., 'atb' for MSA or 'arz' for Egyptian) followed by a space character before the text. ``` -------------------------------- ### Run Stanford NER as a Server Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/ner/README.txt Provides commands to run the Stanford NER system as a network server, listening on a specified port. It includes options for loading NER models from a local file path or directly from a resource within the JAR file, enabling flexible deployment scenarios. ```Java java -mx1000m -cp stanford-ner.jar:lib/* edu.stanford.nlp.ie.NERServer 1234 ``` ```Java java -mx1000m -cp stanford-ner.jar:lib/* edu.stanford.nlp.ie.NERServer -loadClassifier classifiers/all.3class.crf.ser.gz 1234 ``` ```Java java -mx1000m -cp stanford-ner.jar:lib/* edu.stanford.nlp.ie.NERServer -loadClassifier models/all.3class.crf.ser.gz 1234 ``` -------------------------------- ### Launch Stanford Parser GUI (Unix/Mac Shell) Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt This shell command launches the graphical user interface for the Stanford Lexicalized Parser on Unix-like systems, including Mac OS X. It's primarily for exploring the parser's capabilities and does not support saving output, requiring command-line or API usage for serious work. ```Shell lexparser-gui.sh ``` -------------------------------- ### Serialize and Load NERClassifierCombiner Configuration Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/ner/README.txt Shows how to serialize a configured `NERClassifierCombiner` instance to a file for later reuse. This example combines three CRF models, disables SUTime, sets the combination mode to HIGH_RECALL, and saves the configuration. A subsequent command demonstrates loading this serialized classifier to process a CONLL-style input file. ```Java java -mx2g edu.stanford.nlp.ie.NERClassifierCombiner -ner.model \ classifiers/english.conll.4class.distsim.crf.ser.gz,classifiers/english.muc.7class.distsim.crf.ser.gz,\ classifiers/english.all.3class.distsim.crf.ser.gz -ner.useSUTime false \ -ner.combinationMode HIGH_RECALL -serializeTo test.serialized.ncc.ncc.ser.gz ``` ```Java java -mx2g edu.stanford.nlp.ie.NERClassifierCombiner -loadClassifier \ classifiers/example.serialized.ncc.ncc.ser.gz -map word=0,answer=1 \ -testFile sample-conll-file.txt ``` -------------------------------- ### Build Stanford CoreNLP JAR File Source: https://github.com/stanfordnlp/corenlp/blob/main/README.md After successful compilation, this command navigates to the compiled classes directory and creates a new JAR file named 'stanford-corenlp.jar'. This JAR will contain the compiled 'edu' package and will be placed in the parent CoreNLP directory, making it ready for deployment or use. ```Shell cd CoreNLP/classes ; jar -cf ../stanford-corenlp.jar edu ``` -------------------------------- ### Rebuild Truecasing Models using Make Source: https://github.com/stanfordnlp/corenlp/blob/main/scripts/truecase/readme.txt This command initiates the truecasing model rebuilding process, typically involving compilation and training steps defined in a Makefile. It requires a machine with substantial RAM due to the computational intensity of model training and feature pruning. ```bash make ``` -------------------------------- ### tb-preproc Script Command Line Interface Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/segmenter/README-Arabic.txt Documentation for the `tb-preproc` script, used for preprocessing Arabic Treebank data. It prepares data splits (dev, train, test, all) from integrated files for segmenter training. The script recursively locates files and appends standard suffixes to the output prefix. ```APIDOC tb-preproc [domain] - atb_base: The most specific directory that is a parent of all integrated files you wish to include. Files will be located recursively by name in this directory. - splits_dir: The directory containing dev, train, and test listings. - output_prefix: The location and filename prefix that will identify the output files. The preprocessor appends "-all.utf8.txt" (and similar for dev, train, test) to this argument. - domain (optional): A label for the Arabic dialect/genre (e.g., "atb", "bn", "arz"). If provided, additional files (e.g., "output_prefix-withDomains-all.utf8.txt") are generated for domain adaptation model training. ``` -------------------------------- ### Run WikiExtractor for Wikipedia Data Processing Source: https://github.com/stanfordnlp/corenlp/blob/main/scripts/truecase/readme.txt This command executes the WikiExtractor tool to process a large Wikipedia XML dump, extracting raw text content. It uses `nohup` to run in the background and redirects all output to `text.out`, ensuring the process continues even if the terminal is closed. ```bash nohup python3 wikiextractor/WikiExtractor.py wiki/enwiki-20190920-pages-articles-multistream.xml > text.out 2>&1 & ``` -------------------------------- ### Run Neural Network Dependency Parser (Java Command-Line) Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt These commands execute the Stanford Neural Network Dependency Parser via Java from the command line. They demonstrate parsing English and Chinese text files using specific pre-trained models and, for Chinese, integrate a language-specific POS tagger. Output is directed to a specified file. ```Shell java -Xmx2g -cp "*" edu.stanford.nlp.parser.nndep.DependencyParser \ -model edu/stanford/nlp/models/parser/nndep/english_UD.gz \ -textFile data/english-onesent.txt -outFile data/english-onesent.txt.out ``` ```Shell java -Xmx2g -cp "*" edu.stanford.nlp.parser.nndep.DependencyParser \ -model edu/stanford/nlp/models/parser/nndep/UD_Chinese.gz \ -tagger.model edu/stanford/nlp/models/pos-tagger/chinese-distsim.tagger \ -textFile data/chinese-onesent-utf8.txt -outFile data/chinese-onesent-utf8.txt.out ``` -------------------------------- ### CoreNLP Class Aliases and Mappings Source: https://github.com/stanfordnlp/corenlp/blob/main/src/edu/stanford/nlp/ie/qe/rules/defs.qe.txt Defines short aliases for fully qualified Java class names used within Stanford CoreNLP's configuration or rule systems. These mappings simplify referencing common CoreNLP components like Unit, QuantifiableEntity, and various CoreAnnotations. ```APIDOC Unit = { type: "CLASS", value: "edu.stanford.nlp.ie.qe.Unit" } UnitPrefix = { type: "CLASS", value: "edu.stanford.nlp.ie.qe.UnitPrefix" } QuantifiableEntity = { type: "CLASS", value: "edu.stanford.nlp.ie.qe.SimpleQuantifiableEntity" } tokens = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$TokensAnnotation" } numtokens = { type: "CLASS", value: "edu.stanford.nlp.ling.CoreAnnotations$NumerizedTokensAnnotation" } ``` -------------------------------- ### Evaluate Stanford CoreNLP Hybrid Coreference Resolution System Source: https://github.com/stanfordnlp/corenlp/blob/main/src/edu/stanford/nlp/coref/hybrid/README.txt This command runs the CorefSystem for evaluation, typically on a test dataset. It also requires 30GB of memory and a properties file for configuration. The system's output is redirected to 'output.txt'. ```shell java -Xmx30g edu.stanford.nlp.hcoref.CorefSystem -props >& output.txt ``` -------------------------------- ### Train Arabic Segmenter with Domain Adaptation and Parallelization Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/segmenter/README-Arabic.txt This command trains the Arabic Segmenter model with domain adaptation and parallelized gradient computation. It is designed for large datasets and multiple domains, requiring significant memory (64GB) and leveraging multiple CPU cores to reduce training time. Replace `` with the actual number of threads. ```Java java -Xmx64g -Xms64g edu.stanford.nlp.international.arabic.process.ArabicSegmenter -withDomains -trainFile atb+arz-withDomains-train.utf8.txt -serializeTo my_trained_segmenter.ser.gz -multiThreadGrad ``` -------------------------------- ### Run Stanford CoreNLP German Neural Dependency Parser Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt Command to run the Stanford CoreNLP neural dependency parser for German. It requires pre-tokenized input (UD 2.2 tokens, whitespace-separated) and specifies the German model and tagger. ```bash java -Xmx2g -cp "*" edu.stanford.nlp.parser.nndep.DependencyParser \ -model edu/stanford/nlp/models/parser/nndep/UD_German.gz \ -tagger.model edu/stanford.nlp/models/pos-tagger/german-ud.tagger \ -tokenized -textFile example.txt -outFile example.txt.out ``` -------------------------------- ### Execute Stanford CoreNLP Grammar Serialization Script Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt Runs `bin/makeSerialized.csh`, a script used internally by Stanford to serialize grammars for distribution. It demonstrates the process of preparing grammars, though it's not directly runnable by external users due to path dependencies. ```bash bin/makeSerialized.csh ``` -------------------------------- ### Launch Multilingual Lexicalized Parser (Shell) Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt This shell command initiates the Stanford Lexicalized Parser configured for multilingual parsing. It allows using trained grammars for various languages like Arabic, Chinese, French, and German, which are supplied with the parser, enabling cross-language text analysis. ```Shell lexparser-lang.sh ``` -------------------------------- ### Build Stanford CoreNLP JAR with Maven Source: https://github.com/stanfordnlp/corenlp/blob/main/README.md This command compiles the Stanford CoreNLP source code and packages it into a JAR file, typically found in the `target/` directory. It also runs associated tests during the build process, ensuring the integrity of the compiled library. ```Maven mvn package ``` -------------------------------- ### Tag Text File from Command Line Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tagger/README.txt Commands to perform part-of-speech tagging on a text file using the Stanford POS Tagger from the command line. This utilizes pre-configured scripts for different operating systems to simplify execution. ```Shell ./stanford-postagger.sh models/wsj-0-18-left3words-distsim.tagger sample-input.txt ``` ```Batch stanford-postagger models\wsj-0-18-left3words-distsim.tagger sample-input.txt ``` -------------------------------- ### Run Stanford CoreNLP French Neural Dependency Parser Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt Command to run the Stanford CoreNLP neural dependency parser for French. It requires pre-tokenized input (UD 2.2 tokens, whitespace-separated) and specifies the French model and tagger. ```bash java -Xmx2g -cp "*" edu.stanford.nlp.parser.nndep.DependencyParser \ -model edu/stanford/nlp/models/parser/nndep/UD_French.gz \ -tagger.model edu/stanford.nlp/models/pos-tagger/french-ud.tagger \ -tokenized -textFile example.txt -outFile example.txt.out ``` -------------------------------- ### Train a New POS Tagger Model Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tagger/README.txt Command to train a new part-of-speech tagging model using the Stanford POS Tagger. This process requires specifying a properties file for configuration, an output path for the new model, and a training data file. ```Java java -classpath stanford-postagger.jar edu.stanford.nlp.tagger.maxent.MaxentTagger -prop propertiesFile -model modelFile -trainFile trainingFile ``` -------------------------------- ### Configure Stanford CoreNLP Environment Defaults Source: https://github.com/stanfordnlp/corenlp/blob/main/src/edu/stanford/nlp/ie/qe/rules/english.qe.txt Sets default environment variables for Stanford CoreNLP, specifically defining the iteration limit for processing stages and the initial stage value. These settings influence the behavior and performance of CoreNLP pipelines. ```CoreNLP Configuration ENV.defaults["stage.limitIters"] = 50 ENV.defaults["stage"] = 1 ``` -------------------------------- ### Run Stanford POS Tagger on Pretokenized Text Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tagger/README.txt Demonstrates how to execute the Stanford POS Tagger from the command line using a pretokenized input file. This method bypasses the internal tokenizer, requiring the input to already be tokenized according to UD 2.0 standards for certain languages like French, German, and Spanish. ```Java java -mx300m -classpath stanford-postagger.jar edu.stanford.nlp.tagger.maxent.MaxentTagger -model models/french-ud.tagger -tokenize false -textFile sample-input.txt > sample-tagged.txt ``` -------------------------------- ### Tsurgeon Tree Syntax for Insertion and Adjunction Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/tsurgeon/README-tsurgeon.txt Explains the LISP-like parenthetical-bracketing syntax used to define trees for Tsurgeon operations, including rules for auxiliary trees, foot nodes, and node naming within the tree structure. ```APIDOC Tree Syntax: - LISP-like parenthetical-bracketing syntax (e.g., Penn Treebank style). - Example for insertion: (NP (Det the) (N dog)) Auxiliary Tree Syntax (for 'adjoin' operations): - Must have exactly one frontier node ending in the character "@", which marks it as the "foot" node for adjunction. - Final instances of "@" in terminal node labels are removed from the actual label. - Example: (VP (Adv breathlessly) VP@ ) - Escaping: All other instances of "@" in terminal nodes must be escaped (e.g., \@). Node Naming within Trees: - Any node can be named by appending = to the node label (similar to tregex). - This name can be referred to by subsequent tsurgeon operations triggered by the same match. - Escaping: All other instances of "=" in node labels must be escaped (e.g., \=). - Example: insert (NP (-NONE- *T*=trace)) - Example usage with coindex: coindex trace antecedent $ ``` -------------------------------- ### Run CoNLL Benchmark for Stanford CoreNLP Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/loglinear/README.txt Executes the CoNLL benchmark from the `edu.stanford.nlp.loglinear` package within the Stanford CoreNLP project. This command is typically used for quick testing and performance evaluation of the log-linear models. ```Go go run edu.stanford.nlp.loglinear.CoNLLBenchmark ``` -------------------------------- ### Run Stanford Chinese Segmenter via Unix Shell Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/segmenter/README-Chinese.txt This snippet demonstrates how to invoke the Stanford Chinese Segmenter from a Unix-like command line. It supports specifying the segmentation model (CTB or PKU), input filename, character encoding, and an optional n-best list size. It also includes an option to preserve whitespace. ```shell segment.sh [-k] [ctb|pku] ``` ```shell segment.sh ctb test.simp.utf8 UTF-8 ``` -------------------------------- ### Run Stanford CoreNLP Spanish Neural Dependency Parser Source: https://github.com/stanfordnlp/corenlp/blob/main/doc/lexparser/README.txt Command to run the Stanford CoreNLP neural dependency parser for Spanish. It requires pre-tokenized input (UD 2.0 tokens, whitespace-separated) and specifies the Spanish model and tagger. ```bash java -Xmx2g -cp "*" edu.stanford.nlp.parser.nndep.DependencyParser \ -model edu/stanford/nlp/models/parser/nndep/UD_Spanish.gz \ -tagger.model edu/stanford.nlp/models/pos-tagger/spanish-ud.tagger \ -tokenized -textFile example.txt -outFile example.txt.out ``` -------------------------------- ### Train Stanford CoreNLP Hybrid Coreference Resolution Model Source: https://github.com/stanfordnlp/corenlp/blob/main/src/edu/stanford/nlp/coref/hybrid/README.txt This command executes the CorefTrainer to train the coreference resolution model. It requires a significant amount of memory (30GB) and a properties file to configure the training process. Output logs are redirected to 'log-train.txt'. ```shell java -Xmx30g edu.stanford.nlp.hcoref.train.CorefTrainer -props >& log-train.txt ```