Skip to content

Grammar

Find, count, and auto-correct grammar, style, and spelling issues in free text using the open-source LanguageTool engine

Connector software
Free and open source
Service credentials
Not needed
Use with an agent

Install the Orchard skill in your project to help your agent find connectors, configure them, and verify SQL results.

npx skills add Query-farm/vgi-skills --skill orchard

Copy this request into your coding agent to get started.

Use https://query.farm/products/orchard/connectors/grammar/index.md to help me query Grammar with DuckDB or Haybarn 2.0.1 and VGI protocol 3.4. Ask only for missing details about the result I need or whether I want local execution, self-hosting or Query Farm hosting. Check the connector's actual hosting availability, credentials and input requirements. Read one format of each needed reference and the exact object declarations before writing SQL. Use a released connector, and distinguish a saved example result from anything you actually execute. If you cannot run the query, tell me what remains to verify.

Find spelling and grammar issues in text

Example output Β· captured
Connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
SELECT rule_id, category, message, suggestions
FROM grammar.main.grammar_check('She go to school every day.')
ORDER BY "offset"
Result
rule_id category message suggestions
HE_VERB_AGR Grammar The pronoun 'She' is usually used with a third-person or a past tense verb. ["goes", "went"]

Quick start

Choose where to run Grammar, then follow the steps below.

The connector runs alongside DuckDB or Haybarn. No Query Farm account is needed.

1. Install the vgi extension

Run this in your SQL client. On DuckDB, keep FROM query_farm on LOAD in later sessions.

setup.sql
SET allow_extension_repositories = 'allowed';

CREATE EXTENSION REPOSITORY IF NOT EXISTS query_farm
    WITH PREFIX 'https://duckdb-extensions.query.farm';

INSTALL vgi FROM query_farm;
LOAD vgi FROM query_farm;

2. Attach the connector

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

ATTACH 'grammar' AS grammar (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-grammar:0.5.0'
);

3. Run a query

query.sql
SELECT rule_id, category, message, suggestions
FROM grammar.main.grammar_check('She go to school every day.')
ORDER BY "offset"
More example queries β†’
Technical details
Verified connector release
v0.5.0
Engine
2.0.1
VGI protocol
3.4.0
Verified on
December 1, 2026
Release notes on GitHub
Pin a version for production

When running the connector yourself, keep a specific release until you’re ready to upgrade. Replace the ATTACH statement above with this one and follow the same extension and credential setup.

Attach the signed image

Needs Docker, Podman or another OCI runtime. The extension runs the container and talks to it over stdio.

ATTACH 'grammar' AS grammar (
  TYPE vgi,
  LOCATION 'oci://ghcr.io/query-farm/vgi-grammar:0.5.0'
);

Overview

Grammar, style, and spelling checking + auto-correction (LanguageTool)

Catalog

Everything grammar exposes once attached β€” read straight from the worker's released build.

grammar 1 schema
main 1 table Β· 4 functions

Grammar, style, and spelling checking and auto-correction functions powered by LanguageTool.

Schema examples (8)
Examples (8)

Surface each grammar/spelling issue in a sentence with its rule, category, and suggested fixes.

SELECT rule_id, category, message, suggestions
FROM grammar.main.grammar_check('She go to school every day.')
ORDER BY "offset";
Result
rule_id category message suggestions
HE_VERB_AGR Grammar The pronoun 'She' is usually used with a third-person or a past tense verb. ["goes", "went"]

Count the writing issues in a piece of text (default en-US).

SELECT grammar.main.grammar_count('I has two dog.') AS issue_count;

Test whether text is free of writing issues.

SELECT grammar.main.is_grammatical('The quick brown fox jumps.') AS clean;

Auto-correct text by applying the top suggested fix for each issue.

SELECT grammar.main.correct('She go to school evry day.') AS corrected;
4 more examples

List the supported English language codes to pass as the language argument.

SELECT code, name
FROM grammar.main.grammar_languages
WHERE code LIKE 'en-%'
ORDER BY code;

Auto-correct a batch of sentences and re-count the issues left in each rewrite (grammar_count over correct), so rows that one pass of top-suggestion fixes did not fully clean (issues_after > 0) sort first.

SELECT txt AS original, grammar.main.grammar_count(txt) AS issues_before,
  grammar.main.correct(txt) AS corrected,
  grammar.main.grammar_count(grammar.main.correct(txt)) AS issues_after
FROM (VALUES ('Thanks for you order, it will ship tomorow.'), ('I could of done it better.'), ('This are a test of the the system.'), ('Your package has been delivered.')) AS t(txt)
ORDER BY issues_after DESC, original;

Explain an auto-correction: list each issue grammar_check flags in a sentence with its category, flagged text, and top suggestion (the replacement correct applies) next to the corrected sentence.

SELECT c.category, c.bad_text, c.suggestions[1] AS applied_fix,
  grammar.main.correct('Thanks for you order, it will ship tomorow.') AS corrected
FROM grammar.main.grammar_check('Thanks for you order, it will ship tomorow.') AS c
ORDER BY c."offset";

Rewrite only the rows that fail the grammar check: filter a text column with is_grammatical, then show each failing row's issue count (grammar_count) and its auto-corrected text (correct), worst first.

SELECT txt AS original, grammar.main.grammar_count(txt) AS issues,
  grammar.main.correct(txt) AS corrected
FROM (VALUES ('Its a nice day, isnt it?'), ('Your package has been delivered.'), ('I could of done it better.')) AS t(txt)
WHERE NOT grammar.main.is_grammatical(txt)
ORDER BY issues DESC, original;
Tables
grammar_languages 6 examples2 cols

One row per language code accepted by the grammar functions' language argument, with its human-readable name.

Columns
codenot null VARCHAR
Language code accepted by the language argument (e.g. en-US).
namenot null VARCHAR
Human-readable language name.
ConstraintsPRIMARY KEY (code)
Examples (6)

List every supported language code with its human-readable name, alphabetically.

SELECT code, name FROM grammar.main.grammar_languages ORDER BY code;

Filter to the English variants accepted by the language argument.

SELECT code
FROM grammar.main.grammar_languages
WHERE code LIKE 'en-%'
ORDER BY code;

Count how many language codes this worker accepts.

SELECT count(*) AS supported_languages FROM grammar.main.grammar_languages;
3 more examples
SELECT code, name FROM grammar.main.grammar_languages() ORDER BY code;
SELECT code
FROM grammar.main.grammar_languages()
WHERE code LIKE 'en-%'
ORDER BY code;
SELECT count(*) AS supported_languages
FROM grammar.main.grammar_languages();
Link
Scalar functions
correct (text VARCHAR, language VARCHAR) +1 overload 4 examples

Auto-correct text by applying the first LanguageTool suggestion for each issue, using the default language (en-US).

Arguments
text VARCHAR
The text to auto-correct; the first suggested fix for each issue is applied (right-to-left, non-overlapping) using the default language (en-US). NULL yields NULL; text with no fixable issues is returned unchanged.
language VARCHAR
Language/locale code to check against (e.g. en-US, en-GB, en-CA); a per-call constant. Controls which spellings and rules apply. An unknown code fails the query.
Overloads
correct(text VARCHAR) β†’ VARCHARcorrect(text VARCHAR, language VARCHAR) β†’ VARCHAR
ReturnsVARCHAR
Examples (4)

Auto-correct a sentence in the default language (fixes the agreement error; the 'evry' typo becomes the top suggestion 'very').

SELECT grammar.main.correct('She go to school evry day.');

Auto-correct text in a specific language (fixes verb and noun agreement).

SELECT grammar.main.correct('I has two dog.', 'en-US');

Auto-correct a batch of sentences and re-count the issues left in each rewrite (grammar_count over correct), so rows that one pass of top-suggestion fixes did not fully clean (issues_after > 0) sort first.

SELECT txt AS original, grammar.main.grammar_count(txt) AS issues_before,
  grammar.main.correct(txt) AS corrected,
  grammar.main.grammar_count(grammar.main.correct(txt)) AS issues_after
FROM (VALUES ('Thanks for you order, it will ship tomorow.'), ('I could of done it better.'), ('This are a test of the the system.'), ('Your package has been delivered.')) AS t(txt)
ORDER BY issues_after DESC, original;
1 more example
SELECT grammar.main.correct('She go to school evry day.') AS fixed;
Link
grammar_count (text VARCHAR, language VARCHAR) +1 overload 3 examples

Count grammar, style, and spelling issues in a piece of text, checked in the default language (en-US) with LanguageTool.

Arguments
text VARCHAR
The text to check; each row's grammar, style, and spelling issues are counted using the default language (en-US). NULL yields NULL.
language VARCHAR
Language/locale code to check against (e.g. en-US, en-GB, en-CA); a per-call constant. Controls which spellings and rules apply. An unknown code fails the query.
Overloads
grammar_count(text VARCHAR) β†’ INTEGERgrammar_count(text VARCHAR, language VARCHAR) β†’ INTEGER
ReturnsINTEGER
Examples (3)

Count the grammar/spelling issues in a sentence (default en-US).

SELECT grammar.main.grammar_count('She go to the store yesterday.');

Count issues using a specific language; 'colour' flags as a spelling issue in en-US.

SELECT grammar.main.grammar_count('I love this colour.', 'en-US');
SELECT grammar.main.grammar_count('She go to the store yesterday.') AS n;
Link
is_grammatical (text VARCHAR, language VARCHAR) +1 overload 4 examples

True when a piece of text has zero grammar/style/spelling issues, checked in the default language (en-US) with LanguageTool.

Arguments
text VARCHAR
The text to test; returns true when it has zero grammar, style, and spelling issues in the default language (en-US), else false. NULL yields NULL.
language VARCHAR
Language/locale code to check against (e.g. en-US, en-GB, en-CA); a per-call constant. Controls which spellings and rules apply. An unknown code fails the query.
Overloads
is_grammatical(text VARCHAR) β†’ BOOLEANis_grammatical(text VARCHAR, language VARCHAR) β†’ BOOLEAN
ReturnsBOOLEAN
Examples (4)

Test whether a sentence is free of issues in the default language (returns true).

SELECT grammar.main.is_grammatical('The quick brown fox jumps.');

Test grammaticality in a specific language (returns false - subject-verb agreement).

SELECT grammar.main.is_grammatical('She don''t like it.', 'en-US');

Rewrite only the rows that fail the grammar check: filter a text column with is_grammatical, then show each failing row's issue count (grammar_count) and its auto-corrected text (correct), worst first.

SELECT txt AS original, grammar.main.grammar_count(txt) AS issues,
  grammar.main.correct(txt) AS corrected
FROM (VALUES ('Its a nice day, isnt it?'), ('Your package has been delivered.'), ('I could of done it better.')) AS t(txt)
WHERE NOT grammar.main.is_grammatical(txt)
ORDER BY issues DESC, original;
1 more example
SELECT grammar.main.is_grammatical('The quick brown fox jumps.') AS ok;
Link
Table functions
grammar_check (text VARCHAR, language := VARCHAR) 5 examples

Check grammar, style, and spelling of a piece of text with LanguageTool; returns one row per issue with suggested replacements. Accepts an optional language argument (default en-US).

Positional arguments
text VARCHAR
The prose to check. Each writing problem LanguageTool detects in this text becomes one output row. NULL or empty text yields no rows.
Named arguments
language := VARCHAR
Optional language/locale code to check against (e.g. en-US, en-GB, en-CA); defaults to en-US. Controls which spellings and rules apply. An unknown code fails the query. Β· default "en-US"
Returns columns
rule_id VARCHAR
LanguageTool rule identifier that fired for this issue.
category VARCHAR
Human-readable rule category (e.g. Grammar, Typos, Style).
message VARCHAR
Explanation of the issue LanguageTool reported.
offset INTEGER
0-based character offset of the flagged span in the input text.
length INTEGER
Character length of the flagged span.
bad_text VARCHAR
The flagged substring of the input text.
suggestions VARCHAR[]
Suggested replacements, best first (may be empty).
Examples (5)

List each grammar/spelling issue in a sentence with its rule, category, flagged text, and suggested fixes, in reading order.

SELECT rule_id, category, message, bad_text, suggestions
FROM grammar.main.grammar_check('She go to school every day.')
ORDER BY "offset";

Show the single best suggested replacement for every fixable issue, checking a specific language variant.

SELECT rule_id, message, suggestions[1] AS top_fix
FROM grammar.main.grammar_check('I has a apple.', language := 'en-US')
WHERE length(suggestions) > 0;

Aggregate how many issues fall into each LanguageTool category for a passage.

SELECT category, count(*) AS issues
FROM grammar.main.grammar_check('Their going too the store, its there problem.')
GROUP BY category
ORDER BY issues DESC;
2 more examples

Explain an auto-correction: list each issue grammar_check flags in a sentence with its category, flagged text, and top suggestion (the replacement correct applies) next to the corrected sentence.

SELECT c.category, c.bad_text, c.suggestions[1] AS applied_fix,
  grammar.main.correct('Thanks for you order, it will ship tomorow.') AS corrected
FROM grammar.main.grammar_check('Thanks for you order, it will ship tomorow.') AS c
ORDER BY c."offset";
SELECT rule_id, category, message
FROM grammar.main.grammar_check('She go to school every day.');
Link

Try these queries

Count the writing issues in a piece of text (default en-US).

SELECT grammar.main.grammar_count('I has two dog.') AS issue_count

Uses grammar_count

Test whether text is free of writing issues.

SELECT grammar.main.is_grammatical('The quick brown fox jumps.') AS clean

Uses is_grammatical

Auto-correct text by applying the top suggested fix for each issue.

SELECT grammar.main.correct('She go to school evry day.') AS corrected

Uses correct

List the supported English language codes to pass as the language argument.

SELECT code, name
FROM grammar.main.grammar_languages
WHERE code LIKE 'en-%'
ORDER BY code

Uses grammar_languages

List every supported language code with its human-readable name, alphabetically.

SELECT code, name FROM grammar.main.grammar_languages() ORDER BY code

Filter to the English variants accepted by the language argument.

SELECT code
FROM grammar.main.grammar_languages()
WHERE code LIKE 'en-%'
ORDER BY code

20 more examples in the Catalog, each listed under the table or function it uses.

Questions it can answer

Plain-English questions from the worker's agent test tasks. An AI agent with this catalog attached should answer each one with SQL.

  • Is the sentence 'The quick brown fox jumps over the lazy dog.' grammatically correct? Return a single boolean value.
  • Is the sentence 'She go to school every day.' grammatically correct? Return a single boolean value.
  • How many grammar, style, or spelling issues does the sentence 'The quick brown fox jumps over the lazy dog.' contain? Return the count as a single number.
  • When you check the sentence 'She go to school every day.' for writing problems, does it have at least one issue? Return a single boolean value.
  • Return the sentence 'I has a apple.' rewritten with its spelling and grammar automatically corrected.
  • Is the language code 'en-GB' one of the languages this worker supports for grammar checking? Return a single boolean value.

Grammar is an independent open-source connector from Query.Farm. It is not affiliated with, endorsed by or sponsored by the services, projects or organisations it works with. Product names, logos and trademarks belong to their respective owners.