Skip to content
This repository has been archived by the owner on Oct 19, 2024. It is now read-only.
/ ner Public archive

A command-line utility for extracting names of people, places, and organizations from text on macOS.

License

Notifications You must be signed in to change notification settings

Flight-School/ner

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

$ 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.


Requirements

  • macOS 10.12+

Installation

Install ner with Homebrew using the following command:

$ 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

$ echo "Tim Cook is the CEO of Apple." | ner
PERSON	Tim Cook
ORGANIZATION	Apple

Reading from Standard Input Interactively

$ ner
Greetings from Cupertino, California! (This text is being typed into standard input.)
PLACE	Cupertino
PLACE	California

Reading from a File

$ 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

$ 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, like cut, sort, uniq, comm, grep sed, and awk.

Filtering Tags

$ 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:

^(?<tag>(?>PERSON|PLACE|ORGANIZATION))\t(?<token>.+)$

ner uses NLTagger when available, falling back on NSLinguisticTagger for older versions of macOS.

License

MIT

Contact

Mattt (@mattt)

About

A command-line utility for extracting names of people, places, and organizations from text on macOS.

Topics

Resources

License

Security policy

Stars

Watchers

Forks

Sponsor this project

Packages

No packages published