Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/Flight-School/ner
A command-line utility for extracting names of people, places, and organizations from text on macOS.
https://github.com/Flight-School/ner
cli macos named-entity-recognition nlp swift
Last synced: 3 months ago
JSON representation
A command-line utility for extracting names of people, places, and organizations from text on macOS.
- Host: GitHub
- URL: https://github.com/Flight-School/ner
- Owner: Flight-School
- License: mit
- Created: 2019-11-22T17:31:29.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2019-11-23T16:12:24.000Z (almost 5 years ago)
- Last Synced: 2024-07-05T13:46:19.645Z (4 months ago)
- Topics: cli, macos, named-entity-recognition, nlp, swift
- Language: Swift
- Homepage: https://flight.school/books/strings
- Size: 11.7 KB
- Stars: 74
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
# ner
`ner` is a command-line utility for performing
named entity recognition (NER) on text.
You can use it to extract names of people, places, and organizations
from standard input or file arguments.```terminal
$ echo "Designed by Apple in California." | ner
ORGANIZATION Apple
PLACE California
```---
For more information about natural language processing,
check out Chapter 7 of the
[Flight School Guide to Swift Strings](https://flight.school/books/strings).---
## Requirements
- macOS 10.12+
## Installation
Install `ner` with [Homebrew](https://brew.sh) using the following command:
```terminal
$ brew install flight-school/formulae/ner
```## Usage
Text can be read from either standard input or file arguments,
and named entities are written to standard output on separate lines.### Reading from Piped Standard Input
```terminal
$ echo "Tim Cook is the CEO of Apple." | ner
PERSON Tim Cook
ORGANIZATION Apple
```### Reading from Standard Input Interactively
```terminal
$ ner
Greetings from Cupertino, California! (This text is being typed into standard input.)
PLACE Cupertino
PLACE California
```### Reading from a File
```terminal
$ cat barton.txt
The American Red Cross was established in Washington DC by Clara Barton.$ ner barton.txt
ORGANIZATION American Red Cross
PLACE Washington DC
PERSON Clara Barton
```### Reading from Multiple Files
```terminal
$ cat lincoln.txt
Abraham Lincoln was the 16th President of the United States of America.$ ner barton.txt lincoln.txt
ORGANIZATION American Red Cross
PLACE Washington DC
PERSON Clara Barton
PERSON Abraham Lincoln
PLACE United States of America
```## Advanced Usage
`ner` can be chained with
[Unix text processing commands](https://en.wikibooks.org/wiki/Guide_to_Unix/Commands/Text_Processing),
like `cut`, `sort`, `uniq`, `comm`, `grep` `sed`, and `awk`.### Filtering Tags
```terminal
$ ner barton.txt | cut -f2
American Red Cross
Washington DC
Clara Barton
```## Additional Details
Named entities are written to standard output on separate lines.
Each line consists of
the tag (`PERSON`, `PLACE`, or `ORGANIZATION`),
followed by a tab (`\t`),
followed by the token:```regexp
^(?(?>PERSON|PLACE|ORGANIZATION))\t(?.+)$
````ner` uses
[`NLTagger`](https://developer.apple.com/documentation/naturallanguage/nltagger)
when available,
falling back on
[`NSLinguisticTagger`](https://developer.apple.com/documentation/foundation/nslinguistictagger)
for older versions of macOS.## License
MIT
## Contact
Mattt ([@mattt](https://twitter.com/mattt))