textfiles

package
v0.0.0-...-24ca9bf Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Functions

func Bytes

func Bytes(s string) []byte

func CleanWords

func CleanWords(text string) []string

CleanWords matches whole words and removes any punctuation/whitespace.

func Frequency

func Frequency(fileName string, min int)

func Frequency2

func Frequency2(filename string)

func Frequency3

func Frequency3(filename string)

func Keys

func Keys(m map[string]int) []string

func LineMap

func LineMap(s string) map[int]string

LineSet returns a map of line numbers to lines.

func Lines

func Lines(s string) []string

func OpenTextFile

func OpenTextFile(filename string) ([]byte, error)

func ReWrap

func ReWrap(text string, size int) string

func RemoveNewlines

func RemoveNewlines(text string) string

func SortLines

func SortLines(lines []string) []string

func SortWords

func SortWords(words []string) []string

func String

func String(b []byte) string

func ToLower

func ToLower(s string) string

func ToValidUTF8

func ToValidUTF8(s string) string

func Values

func Values(m map[string]int) []int

func WordFrequency

func WordFrequency(words []string) map[string]int

func Words

func Words(s string) []string

Types

type MapSlice

type MapSlice[K Ordered, V Ordered] []tuple[K, V]

func KeySort

func KeySort(m map[string]int) MapSlice[string, int]

func (MapSlice[K, V]) Len

func (m MapSlice[K, V]) Len() int

TODO this sort interface doesn't seem to work ... Len(), Less(), Swap() ... hmm .. not sure

func (MapSlice[K, V]) Less

func (m MapSlice[K, V]) Less(i, j int) bool

func (MapSlice[K, V]) Sort

func (m MapSlice[K, V]) Sort()

func (MapSlice[K, V]) Swap

func (m MapSlice[K, V]) Swap(i, j int)

type Ordered

type Ordered constraints.Ordered

type TextFile

type TextFile struct {
	// contains filtered or unexported fields
}

func GetTextFile

func GetTextFile(filename string) (*TextFile, error)

func (*TextFile) Bytes

func (t *TextFile) Bytes() []byte

func (*TextFile) CleanAlphaNumeric

func (t *TextFile) CleanAlphaNumeric()

CleanAlphaNumeric cleans the word list and returns only items that are alpha-numeric.

func (*TextFile) Frequency

func (t *TextFile) Frequency() map[string]int

func (*TextFile) Less

func (t *TextFile) Less(i, j int) bool

func (*TextFile) LineMap

func (t *TextFile) LineMap() map[int]string

LineSet returns a map of line numbers to lines.

func (*TextFile) LineSet

func (t *TextFile) LineSet(prefix, suffix, contains string) []string

LineSet returns a set of lines from the given file that match the given patterns.

If any of the parameters are the empty string, they are ignored.

func (*TextFile) Lines

func (t *TextFile) Lines() []string

func (*TextFile) String

func (t *TextFile) String() string

func (*TextFile) Swap

func (t *TextFile) Swap(i, j int)

func (*TextFile) ToValidUTF8

func (t *TextFile) ToValidUTF8() error

func (*TextFile) Top

func (t *TextFile) Top(n int)

func (*TextFile) WordCount

func (t *TextFile) WordCount() (int, int)

func (*TextFile) Words

func (t *TextFile) Words() []string

type WordFreq

type WordFreq struct {
	// contains filtered or unexported fields
}

func (WordFreq) String

func (p WordFreq) String() string

Directories

Path Synopsis
cmd

Jump to

Keyboard shortcuts

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