### Starting LanguageTool Server as a Service with Homebrew (macOS) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/http-server.md This command starts the LanguageTool server as a background service on macOS using Homebrew. If a 'java cannot be found' error occurs, Java 8 or later needs to be installed first. ```shell brew services start languagetool ``` -------------------------------- ### Running LanguageTool Rule Tests on Linux Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This command executes the automatic test cases for LanguageTool rules on Linux. It uses the `example` sentences defined within the rules to verify their detection and suggested corrections. ```Shell sh testrules.sh ``` -------------------------------- ### Running LanguageTool Rule Tests on Windows Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This command executes the automatic test cases for LanguageTool rules on Windows. It uses the `example` sentences defined within the rules to verify their detection and suggested corrections. ```Batch testrules.bat ``` -------------------------------- ### Starting LanguageTool HTTP Server via System Command Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/http-server.md This command provides an alternative way to start the LanguageTool HTTP server, typically used for system package management installations (e.g., Arch Linux). It enables HTTP mode, specifies the configuration file, port, and allows all origins. ```shell languagetool --http --config server.properties --port 8081 --allow-origin "*" ``` -------------------------------- ### Creating a Complete XML Rule in LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This example demonstrates a full LanguageTool XML rule, identifying common typos like 'bed English' or 'bat attitude' and suggesting 'bad' as a correction. It includes a pattern with a marker, a message, and an example for testing. ```XML bed|bat English|attitude Did you mean bad? Sorry for my bed English. ``` -------------------------------- ### Starting LanguageTool HTTP Server via Java Command Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/http-server.md This command starts the LanguageTool HTTP server using Java. It specifies the classpath, the main server class, a configuration file (`server.properties`), the port to listen on (8081), and allows cross-origin requests for browser add-ons. ```shell java -cp languagetool-server.jar org.languagetool.server.HTTPServer --config server.properties --port 8081 --allow-origin ``` -------------------------------- ### Defining a Custom LanguageTool XML Rule Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This XML snippet defines a custom LanguageTool rule named 'My example rule' with ID 'EXAMPLE_RULE'. It detects the phrase 'foo bar' and suggests 'bicycle' as a correction. The rule includes examples to demonstrate its application and non-application. ```XML foo bar Did you mean bicycle? My foo bar is broken. My car is broken. ``` -------------------------------- ### Getting Rule Matches for a File using LanguageTool CLI Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This command-line snippet shows how to run LanguageTool to get all rule matches for a given input file. It specifies the language and encoding, and the output (rule matches) is printed to standard output, which can be piped to another file. ```Bash java -jar languagetool-commandline.jar -l -c ``` -------------------------------- ### Cleaning and Installing Maven Project Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/how-to-make-a-languagetool-release.md Performs a clean build and installs the project artifacts into the local Maven repository. This is a prerequisite for deploying artifacts to Maven Central. ```Maven mvn clean install ``` -------------------------------- ### Applying Start Upper Case Conversion in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This configuration uses 'case_conversion="startupper"' on a element to capitalize the first letter of the matched word. This is useful for ensuring proper capitalization at the beginning of a word. ```XML ``` -------------------------------- ### Pulling Translations with webtranslateit.com (wti) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/translating-messages.md This command allows developers to immediately download the latest translations from webtranslateit.com to their local LanguageTool code repository. It requires a developer setup with the `wti` command-line tool installed as a prerequisite. ```Shell wti pull ``` -------------------------------- ### Building LanguageTool with Maven Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md These commands demonstrate how to build and test the LanguageTool project using Maven. `mvn clean package` compiles the project and packages it, while `mvn clean test` runs the project's tests. The `-Xmx1550m` setting for `MAVEN_OPTS` increases Maven's allocated memory, which is often necessary for building LanguageTool. ```Bash mvn clean package mvn clean test -Xmx1550m ``` -------------------------------- ### Testing LanguageTool Server with HTTP GET Request Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/http-server.md This URL demonstrates how to test the LanguageTool server by sending an HTTP GET request. It includes parameters for the language (`en-US`) and the text to be checked (`my+text`). For actual data transfer, HTTP POST is recommended. ```url http://localhost:8081/v2/check?language=en-US&text=my+text ``` -------------------------------- ### Installing LanguageTool Server with Homebrew (macOS) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/http-server.md This Homebrew command installs the LanguageTool server on macOS. Users should note that Homebrew support is not officially provided by the LanguageTool team. ```shell brew install languagetool ``` -------------------------------- ### Starting LanguageTool Server with N-gram Data (Command Line) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/finding-errors-using-n-gram-data.md This command starts the LanguageTool server, specifying the directory containing the unzipped n-gram data using the `--languagemodel` option. Ensure the path points to the parent directory of the language-specific n-gram folders (e.g., `en`, `de`). ```Shell java -jar languagetool-server.jar --languagemodel /path/to/ngram-index ``` -------------------------------- ### Testing LanguageTool Disambiguation Rules with Examples (XML) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-a-disambiguator.md This XML snippet illustrates how to define test cases for LanguageTool disambiguation rules. An `example` of `type="ambiguous"` specifies an input token with multiple possible Part-of-Speech (POS) tags (`inputform`) and the desired single output POS tag (`outputform`) after disambiguation. An `example` of `type="untouched"` indicates a sentence that should remain unchanged by the rule, ensuring no unintended side effects. ```XML What kind of bread is this? What are you doing? ``` -------------------------------- ### Running LanguageTool Rule Tests with Maven Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md For Java developers, this Maven command executes the automatic test cases for LanguageTool rules. It's an alternative way to run tests, leveraging the project's build system. ```Maven mvn clean test ``` -------------------------------- ### Equivalent Rule for skip='1' with No Skipped Token in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This snippet represents the second part of the equivalence for `skip='1'`, demonstrating the case where no token is skipped between 'A' and 'B'. Together with the empty token example, it covers all possibilities of `skip='1'`. ```XML A B ``` -------------------------------- ### Using the Element for Multiple Condition Matching in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This example demonstrates the `` element, which requires a token to satisfy multiple conditions simultaneously. It ensures that the matched token possesses both 'TAG_A' and 'TAG_B' part-of-speech tags. ```XML ``` -------------------------------- ### Configuring fastText for Language Detection Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/http-server.md This snippet shows the content for a `server.properties` file, used to configure the paths for the fastText language identification model and binary. This setup is optional but highly recommended on Linux and Mac for accurate language detection. ```properties fasttextModel=/path/to/fasttext/lid.176.bin fasttextBinary=/path/to/fasttext/fasttext ``` -------------------------------- ### Running LanguageTool Rule Tests for Specific Language on Windows Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This command allows running automatic tests for LanguageTool rules on Windows, specifically targeting rules for a given language by providing its language code (e.g., 'en' for English). ```Batch testrules.bat en ``` -------------------------------- ### Cloning LanguageTool Source Code Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This command clones the LanguageTool source code repository from GitHub. The `--depth=1` option performs a shallow clone, fetching only the most recent commit to save disk space and time. Omitting this option fetches the full repository history. ```Bash git clone --depth=1 https://github.com/languagetool-org/languagetool.git ``` -------------------------------- ### Running LanguageTool Rule Tests for Specific Language on Linux Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This command allows running automatic tests for LanguageTool rules on Linux, specifically targeting rules for a given language by providing its language code (e.g., 'en' for English). ```Shell sh testrules.sh en ``` -------------------------------- ### Filtering Multiple Tokens: Equivalent Single-Token Rule (XML) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-a-disambiguator.md This XML rule illustrates an equivalent single-token filtering approach for the `filterall` example. It demonstrates how a `filterall` action on multiple tokens can be conceptually broken down into individual `` rules for each token within the pattern, specifically showing the filtering for the determiner token. ```XML ``` -------------------------------- ### Testing Multiple Corrections in LanguageTool XML Rules Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This example illustrates how to test multiple possible suggestions for a correction. The 'correction' attribute accepts multiple alternatives joined by a pipe ('|') character, allowing for flexible rule testing. ```XML How to move back and fourth? ``` -------------------------------- ### Checking Java Version Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/how-to-make-a-languagetool-release.md Verifies the currently installed Java Development Kit (JDK) version. LanguageTool requires Java 17 for building and releasing, so this command ensures the correct environment is set up. ```Shell java -version ``` -------------------------------- ### Conditional Case Conversion for Specific Replacements in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This snippet demonstrates how to apply conditional case conversion using 'case_conversion="preserve"' and 'regexp_match' for specific replacements. It shows how to add a character to the beginning of a word while controlling its case, as seen in the Breton example. ```XML pe ? ``` -------------------------------- ### Matching Token Occurrences within a Range using min and max in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This example illustrates how to specify a range for token occurrences using both `min` and `max` attributes. It matches 'a person', 'a nice person', or 'a nice nice person', allowing 'nice' to appear zero, one, or two times. ```XML a nice person ``` -------------------------------- ### Basic Token Referencing in LanguageTool Suggestions (XML) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This XML snippet shows the basic usage of the '' element within a ''. It inserts the content of the first matched token (tokens are numbered from 1 in suggestions) into the suggestion, providing a simple way to reuse matched text. ```XML ``` -------------------------------- ### Default LanguageTool .info Properties File Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-a-tagger-dictionary.md This snippet illustrates the standard configuration for a LanguageTool `.info` properties file, which must accompany a binary dictionary. It defines the separator character for inflected forms and lemmas, the character encoding used by the dictionary, and the type of encoder for the dictionary automaton. This setup is typical for newly created binary dictionaries. ```Properties # Dictionary properties fsa.dict.separator=+ fsa.dict.encoding=iso-8859-1 fsa.dict.encoder=prefix ``` -------------------------------- ### Examples of Subject Pronoun Tags (PRP_S.*) - LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/new_PRP_tags.md This snippet lists examples of English subject pronouns and their corresponding advanced LanguageTool `PRP_S.*` tags. Each line shows the pronoun, its base form, and the specific tag indicating person, number, and gender (e.g., `PRP_S1S` for 'I'). ```Plain Text I I PRP_S1S you you PRP_S2S you you PRP_S2P he he PRP_S3SM she she PRP_S3SF it it PRP_S3SN we we PRP_S1P they they PRP_S3P they they PRP_S3S ``` -------------------------------- ### Examples of Object Pronoun Tags (PRP_O.*) - LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/new_PRP_tags.md This snippet provides examples of English object pronouns and their advanced LanguageTool `PRP_O.*` tags. Each entry includes the object pronoun, its subject form, and the detailed tag specifying person, number, and gender (e.g., `PRP_O1S` for 'me'). ```Plain Text me I PRP_O1S you you PRP_O2S him he PRP_O3SM her she PRP_O3SF it it PRP_O3SN them they PRP_O3S us we PRP_O1P you you PRP_O2P them they PRP_O3P ``` -------------------------------- ### Updating Local Source with Rebase Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/how-to-make-a-languagetool-release.md Pulls the latest changes from the remote repository and rebases the local branch on top of them. This ensures a clean, linear history before starting release work. ```Git git pull -r ``` -------------------------------- ### Applying Start Lower Case Conversion in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This configuration uses 'case_conversion="startlower"' on a element to convert the first letter of the matched word to lowercase. This is useful for ensuring proper lowercase at the beginning of a word. ```XML ``` -------------------------------- ### Defining XML Token Patterns in LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md These snippets illustrate various ways to define token matching patterns within LanguageTool XML rules, covering exact word matches, phrases, regular expressions, part-of-speech tags, and sentence boundary markers. They show how to control case sensitivity and use negation. ```XML think ``` ```XML think about ``` ```XML think|say ``` ```XML ``` ```XML ``` ```XML cause and|to ``` ```XML foobar ``` ```XML (?-i)Bill ``` -------------------------------- ### Template for LanguageTool Rule XML File (Default) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-robust-rules.md This XML snippet provides a basic template for a LanguageTool grammar rule file, typically found at org/languagetool/rules/xx/grammar.xml. It includes standard XML declaration, stylesheet references, and the root element with schema location and namespace declarations. This template is used as a starting point for creating new rule sets. ```XML ``` -------------------------------- ### Configuring LanguageTool Server N-gram Data (Properties File) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/finding-errors-using-n-gram-data.md This snippet shows how to configure the n-gram data directory using a properties file. The `languageModel` entry in the properties file should point to the root directory of your n-gram data. The server is then started using the `--config` option. ```Properties languageModel=/path/to/ngram-index ``` ```Shell java -jar languagetool-server.jar --config myconfig.properties ``` -------------------------------- ### Using the Element for Alternative Token Matching in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This snippet shows the usage of the `` element to match a token if one of several conditions is met. It allows matching either 't' (as in 'don't') or 'not' before 'walk', providing a compact alternative to multiple rules. ```XML t not walk ``` -------------------------------- ### Simulating a Simple Chunker with skip='1' in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This snippet uses the `skip='1'` attribute to simulate a simple chunker, allowing one token to be skipped between 'A' and 'B'. This is useful for languages with flexible word order, effectively matching 'A [any word] B'. ```XML A B ``` -------------------------------- ### Advanced Case Conversion with Regexp Replace in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This example illustrates a workaround for simultaneously changing a word and its case. It uses 'regexp_match=".*"' and 'regexp_replace="bar"' with 'case_conversion="alllower"' within a element, overriding default case adjustments. ```XML foo Bar Change to ``` -------------------------------- ### Filtering Tags: Shorter Syntax for Simple Filtering (XML) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-a-disambiguator.md This XML rule illustrates a concise syntax for simple tag filtering. Using ``, it filters interpretations of the token 'his' to only retain those tagged as `PRP$`. This syntax is equivalent to the first example but does not allow specifying a lemma and only executes if the token already has the specified tag. ```XML his ``` -------------------------------- ### Building LanguageTool with Maven Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/maven-tips.md This command builds the entire LanguageTool project from its top-level directory. It generates the standalone version with GUI and command-line tool, and the LibreOffice/OpenOffice extension. ```Maven mvn clean package ``` -------------------------------- ### Example of Exported Dictionary Data Format (Plain Text) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-a-tagger-dictionary.md This snippet illustrates the plain text format of the `dictionary.dump` file generated by `DictionaryExporter`. Each line represents a word entry with three tab-separated columns: the inflected word form, its base form (lemma), and its Part-of-Speech (POS) tag. This format is crucial for subsequent dictionary building processes. ```Plain Text boyar boyar NN boyard boyard NN boyardism boyardism NN:UN boyards boyard NNS boyarism boyarism NN:UN boyarisms boyarism NNS boyars boyar NNS ``` -------------------------------- ### Staging Maven Artifacts Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/how-to-make-a-languagetool-release.md Executes the `stage-artifacts.sh` script, which signs and uploads the Maven artifacts to the Sonatype staging area. This process can take over 30 minutes and requires proper `~/.m2/settings.xml` configuration for authentication. ```Shell ./stage-artifacts.sh ``` -------------------------------- ### Example Chunk Analysis Output for English Sentence Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/using-chunks.md This snippet shows the detailed chunk analysis for the sentence 'She put the big knives on the table.' Each word is tagged with its part-of-speech and chunk information, indicating the beginning (B), continuation (I), or end (E) of noun phrases (NP) or verb phrases (VP), along with singular/plural distinctions for noun phrases. ```LanguageTool Output She/**B-NP-singular|E-NP-singular** put/B-VP the/**B-NP-plural** big/**I-NP-plural** knives/**E-NP-plural** on/B-PP the/**B-NP-singular** table/**E-NP-singular** ./O ``` -------------------------------- ### Running LanguageTool Regression Tests (Shell) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-robust-rules.md This snippet refers to a shell script used for regression testing LanguageTool rules locally against plain text files. It helps identify newly introduced false alarms by comparing old and new test results. Requires a developer setup with Java and Maven. ```Shell languagetool-standalone/scripts/regression-test.sh ``` -------------------------------- ### Selective Case Sensitivity in LanguageTool XML Patterns Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This example illustrates how to achieve selective case sensitivity within a rule. By using 'regexp="yes"' and the Java regular expression flag '(?iu)' on a specific token, you can override the pattern's global 'case_sensitive' setting. ```XML (?iu)ten one|two ``` -------------------------------- ### Matching Coordinated Words with skip='-1' and scope='next' Exception in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This snippet demonstrates using `skip='-1'` to match an unlimited number of tokens until 'as' is found, specifically for coordinated words like 'both ... as well as'. The `exception scope='next'` ensures 'and' is only excluded from the skipped tokens, not the 'both' token itself. ```XML bothand as well as ``` -------------------------------- ### Running LanguageTool Rule Overview Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/how-to-make-a-languagetool-release.md Executes the `RuleOverview` utility class, which generates an overview of LanguageTool rules. The output should be pasted into the `languages.html` file. This can be run via Maven's exec plugin or an IDE. ```Maven mvn exec:java -Dexec.mainClass="org.languagetool.dev.RuleOverview" ``` -------------------------------- ### Matching Tokens with Exactly Two Specific POS Tags (AND Logic) in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This example illustrates how to match tokens that possess exactly two specific part-of-speech tags ('tag1' AND 'tag2'). It combines multiple '' elements within an '' block and applies a 'negate_pos' exception to ensure only these two tags are present. ```XML ``` -------------------------------- ### Adding New Readings for Tokens (XML) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-a-disambiguator.md This example demonstrates how to add a completely new reading to a token, which is useful for marking groups like noun phrases or multi-word expressions. The rule uses the 'add' action with a 'wd' element to specify the new lemma ('po ciemku') and POS ('adjp') for the token 'ciemku'. The number of 'wd' elements must match the number of tokens selected by a 'marker' if used. ```XML ciemku ciemku ``` -------------------------------- ### Referencing Previous Tokens in LanguageTool Patterns (XML) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This XML pattern demonstrates how to reference a previously matched token using ''. It allows matching sequences like 'ani...ani' without explicitly listing all combinations, by inserting the first matched token into the second token's position. The 'no="0"' attribute refers to the first token matched in the pattern. ```XML ani|ni|i|lub|albo|czy|oraz, ``` -------------------------------- ### Building Binary POS Dictionary with POSDictionaryBuilder (Java) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-a-tagger-dictionary.md This command utilizes the `POSDictionaryBuilder` tool to compile a plain text dictionary file (`dictionary.dump`) into a binary POS dictionary (`output.dict`). It requires an `.info` file for configuration and expects the input text file to have UNIX line endings. The resulting binary file is optimized for speed and size for use within LanguageTool. ```Java java -cp languagetool.jar org.languagetool.tools.POSDictionaryBuilder -i dictionary.dump -info org/languagetool/resource/en/english.info -o output.dict ``` -------------------------------- ### Building Binary Synthesizer Dictionary with SynthDictionaryBuilder (Java) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-a-tagger-dictionary.md This command uses the `SynthDictionaryBuilder` tool to create a binary synthesizer dictionary (`result.dict`) from a plain text dictionary file (`dictionary.dump`). Unlike the POS dictionary, a synthesizer dictionary maps base forms and POS tags to all inflected forms. It also requires an `.info` file for specific language configurations. ```Java java -cp languagetool.jar org.languagetool.tools.SynthDictionaryBuilder -i dictionary.dump -info org/languagetool/resource/en/english_synth.info -o result.dict ``` -------------------------------- ### Configuring Repetition Rules in XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This XML rule demonstrates how to create a repetition rule using `min_prev_matches` and `distance_tokens`. The rule will only trigger if the pattern (`test`) has matched at least 2 times previously within a total distance of 80 tokens. This allows for detecting repeated phrases or words without writing custom Java code. ```XML test Repeated word. test ``` -------------------------------- ### Applying POS Tag Replacement in XML Rules Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This XML snippet demonstrates the use of `postag_replace` to modify the required POS tags for a suggestion based on the matched word's tags. It uses regular expressions with capturing groups (`$1`, `$2`) to dynamically construct the replacement POS tag pattern. The `postag_regexp` attribute must be set to `yes` for this functionality. ```XML ``` -------------------------------- ### Defining a Token-Based Antipattern in LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This XML snippet shows how to define an `` within a LanguageTool rule. The rule's `` matches 'word1', but the `` prevents a match if 'word1 word2' is found. Antipatterns are used to specify exceptions to a rule's main pattern, ensuring that the rule only triggers for specific contexts. The `example` within the antipattern demonstrates a case where the rule should *not* match. ```XML word1 word2 text word1 word2 more text word1 ... ``` -------------------------------- ### Running All Unit Tests with Maven Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/maven-tips.md This standard Maven command executes all unit tests defined within the LanguageTool project. While not the fastest, it ensures comprehensive test coverage for Java developers. ```Maven mvn clean test ``` -------------------------------- ### Running Specific Rule Tests for LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/maven-tips.md For rule developers, this command executes automatic tests for 'grammar.xml' rule files specific to a chosen language (e.g., 'en' for English). It offers a much faster alternative to running all tests. ```Shell ./testrules.sh en ``` -------------------------------- ### Reviewing Local Git Changes with Gitk Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-for-new-committers.md Gitk is a graphical tool used to visualize and review local Git changes before pushing them to the remote repository. It helps in verifying the commit history and the content of pending changes. ```Git gitk ``` -------------------------------- ### Generating New Language Module Maven Project Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/adding-a-new-language.md This Maven command initializes a new project for the language module using the 'maven-archetype-quickstart'. It sets the 'groupId' to 'org.languagetool' and requires replacing 'artifactId' with the language's ISO 639-1 or ISO 639-3 code, creating the foundational directory structure for the new language. ```Maven mvn archetype:generate -DgroupId=org.languagetool -DartifactId=**xy** -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false ``` -------------------------------- ### Building LanguageTool Skipping Tests with Maven Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/maven-tips.md This command builds the LanguageTool project but skips the execution of all unit tests. It is particularly useful for faster builds when only compilation and packaging are required. ```Maven mvn clean package -DskipTests ``` -------------------------------- ### Examples of Reflexive Pronoun Tags (PRP_R.*) - LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/new_PRP_tags.md This snippet lists examples of English reflexive pronouns and their corresponding advanced LanguageTool `PRP_R.*` tags. Each line shows the reflexive pronoun, its subject form, and the specific tag indicating person, number, and gender (e.g., `PRP_R1S` for 'myself'). ```Plain Text myself I PRP_R1S yourself you PRP_R2S himself he PRP_R3SM herself she PRP_R3SF itself it PRP_R3SN themself they PRP_R3S ourselves we PRP_R1P yourselves you PRP_R2P themselves they PRP_R3P ``` -------------------------------- ### Running All Java JUnit Tests with Maven Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-for-new-committers.md This Maven command executes all JUnit tests defined in the project, ensuring that Java code changes do not introduce regressions. It's a mandatory step before committing any Java modifications. ```Maven mvn clean test ``` -------------------------------- ### Running Specific Language Tests with Maven Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/maven-tips.md These commands allow you to run tests for a specific language module (e.g., 'xy') while ensuring that all its dependencies are also rebuilt. This is useful for focused testing and development. ```Shell ./build.sh xy test ``` ```Maven mvn --projects languagetool-language-modules/xy --also-make clean test ``` -------------------------------- ### Examples of Adjective-like Possessive Tags (PRP$_A.*) - LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/new_PRP_tags.md This snippet provides examples of English adjective-like possessives and their advanced LanguageTool `PRP$_A.*` tags. Each entry includes the possessive adjective, its subject form, and the detailed tag specifying person, number, and gender (e.g., `PRP$_A1S` for 'my'). ```Plain Text my I PRP$_A1S your you PRP$_A2S his he PRP$_A3SM her she PRP$_A3SF its it PRP$_A3SN their they PRP$_A3S our we PRP$_A1P your you PRP$_A2P their they PRP$_A3P ``` -------------------------------- ### Examples of Possessive Pronoun Tags (PRP$_P.*) - LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/new_PRP_tags.md This snippet lists examples of English possessive pronouns and their corresponding advanced LanguageTool `PRP$_P.*` tags. Each line shows the possessive pronoun, its subject form, and the specific tag indicating person, number, and gender (e.g., `PRP$_P1S` for 'mine'). ```Plain Text mine I PRP$_P1S yours you PRP$_P2S his he PRP$_P3SM hers she PRP$_P3SF theirs they PRP$_P3S ours we PRP$_P1P yours you PRP$_P2P theirs they PRP$_P3P ``` -------------------------------- ### Running LanguageTool XML Rule Tests Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-for-new-committers.md These scripts are used to test changes specifically made to LanguageTool's XML rules. 'xx' should be replaced with the two-letter language code (e.g., 'en' for English) to run tests for that specific language's rules. ```Shell testrules.sh xx ``` ```Batch testrules.bat xx ``` -------------------------------- ### Cleaning and Testing Maven Project Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/how-to-make-a-languagetool-release.md Executes a clean build and runs all unit and integration tests for the Maven project. This ensures that all changes are stable and no regressions have been introduced before the release. ```Maven mvn clean test ``` -------------------------------- ### Navigating to Release Scripts Directory Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/how-to-make-a-languagetool-release.md Changes the current working directory to the `languagetool-standalone/scripts` directory, where the artifact staging script is located. This is a preparatory step before running the deployment script. ```Shell cd languagetool-standalone/scripts ``` -------------------------------- ### Building a Binary Spell Dictionary (Java) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/hunspell-support.md This command-line tool allows users to build a LanguageTool binary dictionary from a plain text list of words. It requires the `languagetool.jar` file, a language code (e.g., `de-DE`), the path to the input word list file, and the corresponding `.info` file. The resulting binary dictionary is written to the specified output path. ```Shell java -cp languagetool.jar org.languagetool.tools.SpellDictionaryBuilder de-DE /path/to/dictionary.txt org/languagetool/resource/en/hunspell/en_US.info - -o /tmp/output.dict ``` -------------------------------- ### Testing Single Corrections in LanguageTool XML Rules Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This snippet demonstrates how to test a single word or phrase correction using the 'correction' attribute within an 'incorrect' example tag. It ensures that the rule correctly generates the specified suggestion string. ```XML How to move back and fourth from linux to xmb? ``` -------------------------------- ### Switching to Release Branch (Post-Release) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/how-to-make-a-languagetool-release.md Switches back to the release branch (`vx.y-release`) after the release artifacts have been pushed and tagged. This is done to prepare the branch for future snapshot development. ```Git git checkout vx.y-release ``` -------------------------------- ### Adding a New Language Locale with webtranslateit.com (wti) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/translating-messages.md This command is used to register a new language locale with webtranslateit.com. The 'xx' placeholder should be replaced with the two-letter language code (e.g., 'de' for German). This is a one-time setup required when a new language is introduced for translation. ```Shell wti addlocale xx ``` -------------------------------- ### Matching Optional Tokens with min='0' in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This snippet demonstrates how to make a token optional in LanguageTool rules using the `min` attribute set to `0`. It allows matching phrases like 'a person' or 'a nice person', where 'nice' is an optional word. ```XML a nice person ``` -------------------------------- ### Avoiding Git Force Option Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-for-new-committers.md The '--force' option should never be used with Git commands unless explicitly instructed, as it can overwrite remote history and lead to data loss or conflicts for other collaborators. Seek help on the forum instead. ```Git --force ``` -------------------------------- ### Incorrect Token Negation Example in LanguageTool Rules - XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This XML rule snippet illustrates a common misunderstanding of the `negate="yes"` attribute. When used with a `postag`, it negates the token itself, not the part-of-speech, leading to a match of any end-of-sentence token, which is often not the intended behavior. ```XML ``` -------------------------------- ### Standard Git Pull Operation Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-for-new-committers.md This command fetches changes from the remote repository and merges them into the current branch. Without the '-r' (rebase) option, it can result in "ugly merge commits" that clutter the commit history. ```Git git pull ``` -------------------------------- ### Equivalent Rule for skip='1' with Empty Token in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This snippet shows the explicit equivalent of `skip='1'`, where an empty `` element is used to match any single word between 'A' and 'B'. This clarifies how `skip='1'` implicitly handles a single skipped token. ```XML A B ``` -------------------------------- ### Running LanguageTool Rule Tests for Specific Language (Shell) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This command demonstrates how to execute LanguageTool rule tests from the command line for a specific language. By providing the two-letter language code (e.g., 'ru' for Russian) as a parameter to 'testrules.sh', tests for other languages are skipped. ```Shell ./testrules.sh ru ``` -------------------------------- ### Testing LanguageTool Server with HTTP POST Request using cURL Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/http-server.md This `curl` command shows how to send an HTTP POST request to the LanguageTool server. It includes data parameters for the language (`en-US`) and the text (`a simple test`), which is the recommended method for transferring data in non-testing scenarios. ```shell curl -d "language=en-US" -d "text=a simple test" http://localhost:8081/v2/check ``` -------------------------------- ### Excluding Preceding Tokens with scope='previous' and skip='-1' in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This snippet illustrates using `scope='previous'` within an exception to exclude a specific token that immediately precedes the matched token, especially useful with `skip='-1'`. It matches 'tak' after 'jak' only if 'tak' is not preceded by a comma, providing a powerful way to refine matches. ```XML tak jak tak, ``` -------------------------------- ### Automating LanguageTool Corpus Testing with Level Selection (Bash) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-robust-rules.md This Bash script automates the testing of LanguageTool grammar rules against different levels of a Spanish corpus. It defines a `process` function to iterate through text files, applying `languagetool-commandline.jar` with specific rules disabled (e.g., `WHITESPACE_RULE`). Users can specify a corpus level (1, 2, or all) as a command-line argument, and the script outputs logs for each processed file. ```bash #!/bin/bash # testes-tl.sh # Long test for Spanish grammar # Copyright (C) 2010 Juan Martorell _help() { echo "$0 {level}" echo echo ' where {level} is one of' echo ' 1: Test level 1 corpus: files prefixed with lt-1-' echo ' 2: Test level 2 corpus: files prefixed with lt-2-' echo ' a: Test all levels' exit } function process { for file in $FILELIST { echo "Processing $file" java -jar languagetool-commandline.jar --language es \ --disable WHITESPACE_RULE,UNPAIRED_BRACKETS,COMMA_PARENTHESIS_WHITESPACE,DOUBLE_PUNCTUATION \ $file >$file.log } } if [ -z "$1" ]; then _help elif [ "$1" == "1" ]; then FILELIST=`ls -rS texts/tl-1-*.txt` process elif [ "$1" == "2" ]; then FILELIST=`ls -rS texts/tl-2-*.txt` process elif [ "$1" == "a" ]; then FILELIST=`ls -rS texts/tl-?-*.txt` process elif [ "$1" == "--help" ]; then _help else echo "** $1 is not a valid option." echo _help fi exit ``` -------------------------------- ### Testing LanguageTool Rules on a Corpus - Command Line Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This command-line snippet shows how to execute LanguageTool to check a text file against its rules. It allows specifying the language and encoding, and redirects the output to a file, which is useful for corpus testing and analyzing rule match counts. ```Java (Command Line) java -jar languagetool-commandline.jar -l -c > ``` -------------------------------- ### Running Tests with Parallel Threads in Maven Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/maven-tips.md These commands configure Maven to run tests using multiple threads, either one thread per CPU core or a fixed number of threads. This can significantly improve test execution performance on multi-core systems. ```Maven mvn -T 1C test ``` ```Maven mvn -T 2 ``` -------------------------------- ### Applying Postag Regex Replacement in ASF (XML) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/using-asf.md This XML snippet illustrates how to use `postagReplace:` within the AdvancedSynthesizerFilter (ASF) to modify parts of a token's postag. It highlights the specific syntax for capturing groups, using `\bN` instead of `$N`, as shown in a Spanish example to change singular verb postags to plural. ```XML ``` -------------------------------- ### Displaying Maven Dependency Tree Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/maven-tips.md This command displays the dependency tree of the current Maven project. It is an invaluable tool for debugging issues related to conflicting or missing dependencies. ```Maven mvn dependency:tree ``` -------------------------------- ### Equivalent XML for POS Tag Repetition in LanguageTool Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This XML rule provides an equivalent notation for matching one or more tokens with a specific part-of-speech tag (e.g., 'jj'). It uses a `skip="-1"` attribute combined with a negated exception to achieve the effect of a `+` operator, matching one or more occurrences of the 'jj' tag. ```XML ``` -------------------------------- ### Implementing RuleFilter in XML Patterns Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This XML snippet shows how to integrate a `RuleFilter` into an XML pattern rule. The `filter` element specifies a Java class (`org.languagetool.rules.en.MyFilter`) that implements the `RuleFilter` interface, allowing for custom Java-based filtering logic. Arguments can be passed to the filter using the `args` attribute, with `\1` resolving to the first matching token. ```XML \d \d\d ``` -------------------------------- ### Running LanguageTool Wikipedia Checker (Java/Shell) Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/developing-robust-rules.md This command executes the LanguageTool Wikipedia checker JAR file, displaying its usage. It's the first step to checking rules against a larger set of Wikipedia documents. Requires the languagetool-wikipedia.jar file. ```Shell java -jar languagetool-wikipedia.jar ``` -------------------------------- ### Using Exceptions for POS Negation in LanguageTool Rules - XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/tips-and-tricks.md This XML rule snippet shows an alternative way to achieve part-of-speech negation using an `` tag. It is logically equivalent to using `negate_pos="yes"` and will match tokens that are not tagged as `SENT_START`. ```XML ``` -------------------------------- ### Matching Beginning of Singular Noun Chunk in LanguageTool XML Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/using-chunks.md This XML snippet demonstrates how to match a word that marks the beginning of a singular noun chunk (`B-NP-singular`) within LanguageTool's `grammar.xml` rules. It uses the `chunk` attribute on a `` element to specify the exact chunk tag to match. ```XML ``` -------------------------------- ### Applying RegexAntiPatternFilter with a Regular Expression Rule Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/development-overview.md This XML snippet illustrates how to use `RegexAntiPatternFilter` with a `` rule to prevent false positives. The rule matches 'fo. bar' but is filtered if 'fou' is present, demonstrating an exclusion mechanism for regular expression matches. The `mark` attribute specifies which group of the regex to underline. Multiple antipatterns can be delimited by a pipe (`|`) in the `args` attribute. ```XML (fo.) (bar) ``` -------------------------------- ### Setting Project Version to Snapshot with Maven Source: https://github.com/languagetool-org/languagetool-org.github.io/blob/master/how-to-make-a-languagetool-release.md Interactively sets the project version to the next snapshot version using Maven. When prompted, the user should enter `${revision}` to use the property defined in `pom.xml`. ```Maven mvn versions:set ```