slice

package module
v0.0.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Feb 23, 2022 License: BSD-2-Clause-Views Imports: 1 Imported by: 0

README

slice: text sampler

slice samples random lines from STDIN.

ABOUT

slice extracts random lines from text. This is useful for a variety of applications.

  • Statistics
  • Name generation
  • File previewing

For example, head/tail only show the very start and end of a document. Where slice shows a more representative interlace of the overall content. Like less/more, but in a compact, intentionally lossy form.

EXAMPLES

$ cd examples

$ slice romeo-and-juliet.txt
  Escalus, Prince of Verona.
  Friar John, Franciscan.
  Three Musicians.
  An Officer.
  Nurse to Juliet.
    In fair Verona, where we lay our scene,
                                                         [Exit.]

$ slice -rate 0.05 constellations.txt
Ara
Bootes
Canis

$ slice -skip 2 cities.txt
Amsterdam
Casablanca
Edison
Gallipoli
Italia
Kilogramme
Madagascar
Oslo
Quebec
Santiago
Upsala
Washington
Yokohama

By default, slice reads from STDIN. See slice -help for more information.

DOWNLOAD

https://github.com/mcandre/slice/releases

DOCUMENTATION

https://pkg.go.dev/github.com/mcandre/slice

CONTRIBUTING

See DEVELOPMENT.md.

LICENSE

FreeBSD

SEE ALSO

  • awk, a complex line processor
  • head/tail, basic text truncators
  • less, an interactive text file reader
  • more, a limited interactive text file reader
  • perl, a very complex text processor
  • sed, a simple line processor
  • uniq, a text filter for uniqueness

🔪

Documentation

Index

Constants

View Source
const DefaultRate = float64(0.1)

DefaultRate controls the normal probability preservation rate of each line.

View Source
const Version = "0.0.2"

Version is semver.

Variables

This section is empty.

Functions

func Slice

func Slice(rate *float64, skip *int64) (chan<- string, <-chan string, chan<- struct{})

Slice samples text.

rate specifies the probability of preserving each line.

Returns an input channel for submitting population lines; an output channel for receiving sample lines; and a done channel for concluding the sampling operation.

Types

This section is empty.

Directories

Path Synopsis
cmd
slice command

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL