All Projects → Flight-School → sentences

Flight-School / sentences

Licence: MIT license
A command-line utility that splits natural language text into sentences.

Programming Languages

swift
15916 projects
Makefile
30231 projects

Projects that are alternatives of or similar to sentences

sentence-autosegmentation
Deep-learning based sentence auto-segmentation from unstructured text w/o punctuation
Stars: ✭ 37 (+0%)
Mutual labels:  sentence-tokenizer
bunkai
Sentence boundary disambiguation tool for Japanese texts (日本語文境界判定器)
Stars: ✭ 154 (+316.22%)
Mutual labels:  sentence-tokenizer

sentences

sentences is a command-line utility that splits natural language text into sentences.

$ cat propositions.txt
All men are mortal. Socrates is a man. Therefore, Socrates is mortal.

$ sentences propositions.txt
All men are mortal.
Socrates is a man.
Therefore, Socrates is mortal.


For more information about natural language processing, check out Chapter 7 of the Flight School Guide to Swift Strings.


Requirements

  • macOS 10.13+

Installation

Install sentences with Homebrew using the following command:

$ brew install flight-school/formulae/sentences

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 "Designed by Apple in California. Assembled in China." | sentences
Designed by Apple in California. 
Assembled in China.

$ echo "床前明月光,疑是地上霜。举头望明月,低头思故乡。" | sentences
床前明月光,疑是地上霜。
举头望明月,低头思故乡。

Reading from Standard Input Interactively

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

Reading from a File

$ head -n 1 think_different.txt
Here's to the crazy ones. The misfits. The rebels. The troublemakers.

$ sentences think_different.txt
Here's to the crazy ones.
The misfits.
The rebels.
The troublemakers.
The round pegs in the square holes.
The ones who see things differently.
They're not fond of rules.
And they have no respect for the status quo.
You can quote them, disagree with them, glorify or vilify them.
About the only thing you can't do is ignore them.
Because they change things.
They push the human race forward.
And while some may see them as the crazy ones, we see genius.
Because the people who are crazy enough to think they can change the world, are the ones who do.

Advanced Usage

sentences can be chained with Unix text processing commands, like cut, sort, uniq, comm, grep sed, and awk --- as well as its sibling tools, ner and pos.

Filtering Tags

$ sentences think_different.txt | head -n 1 | pos
ADVERB	Here
VERB	's
PREPOSITION	to
DETERMINER	the
ADJECTIVE	crazy
NOUN	ones

Additional Details

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

License

MIT

Contact

Mattt (@mattt)

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].