wordcount

package
v0.0.0-...-c4986e2 Latest Latest
Warning

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

Go to latest
Published: Aug 18, 2018 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Update

func Update(r io.Reader, d Dict) error

Update updates given Dict with new or exitring word and increment word count.

Types

type Dict

type Dict map[string]int

Dict represents word frequency count

func Tell

func Tell(r io.Reader) (Dict, error)

Tell counts number of words.

type KeyVal

type KeyVal struct {
	Key string
	Val int
}

KeyVal represents Key-Value pair.

type Pairs

type Pairs []KeyVal

Pairs represents slice of Key-Val pairs.

func Sort

func Sort(ws Dict) Pairs

Sort sorts given Dict by word popularity and return slice of Key-Val pairs.

func (Pairs) Len

func (k Pairs) Len() int

func (Pairs) Less

func (k Pairs) Less(i, j int) bool

func (Pairs) Swap

func (k Pairs) Swap(i, j int)

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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