lingua

Natural language processing from the command line, using native macOS APIs. Language detection, sentiment analysis, part-of-speech tagging, named entity recognition, structured entity extraction (phone numbers, emails, addresses, dates, flight numbers), spelling, grammar, and style checking, dictionary definitions, an English LSP server, and tokenization. All on-device, no API keys, no network calls.

$ echo "Bonjour le monde" | lingua detect
fr [0.98]

$ echo "The food was absolutely incredible" | lingua sentiment
1.0000

$ echo "Call 800-555-1212 or email bob@test.com on March 3rd" | lingua entities
phone: 800-555-1212
email: bob@test.com
date: March 3rd

$ echo "He go to the store yesterday." | lingua grammar
grammar: The word ‘go’ may not agree with the rest of the sentence. [3,2]

$ echo "Mistakes were made by the team." | lingua style
style: passive voice: 'were made' [9,9]

$ lingua define serendipity | head -c 90
serendipity ser·en·dip·i·ty | ˌserənˈdipədē | noun the occurrence and development

Sentiment scores come from Apple's paragraph-level model and are most reliable on paragraph-length, opinionated text --- short factual sentences skew negative, so treat single-sentence scores with skepticism.

grammar and spell use the same engine behind TextEdit's squiggles; style adds passive voice, adverb pile-ups, and overlong sentences on top of the part-of-speech tagger. All three behave like linters: exit 0 when clean, exit 1 when they find something, so they drop straight into git hooks and CI.

And lingua lsp speaks the Language Server Protocol, turning any LSP-capable editor into an English checker: spelling, grammar, and style squiggles with quick-fix suggestions. VS Code (via the dev-mode extension in the repo) and Neovim (a five-line autocmd, no plugin) both work.

Reads from stdin, writes to stdout. Pipes with curl, tezcatl, or anything else:

# Extract phone numbers from a webpage
curl -s https://example.com | lingua entities --type=phone

# Detect language of a rendered JS page
tezcatl https://example.com | lingua detect

# Score sentiment per sentence
echo "I love this. I hate that." | lingua sentiment --per-sentence
1.0000	I love this.
-0.6000	I hate that.

All commands support --json for scripting.

Wraps Apple's NaturalLanguage framework, NSSpellChecker, NSDataDetector, and Dictionary Services via Objective-C runtime and C bindings --- no Swift, no Objective-C source files.

Install

brew install georgemandis/tap/lingua

Read More

Recipes