textproc

package
v0.0.0-...-1eaaa5a Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2024 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrEmptyWords = errors.New("words is empty")
View Source
var ErrInvalidConfig = errors.New("invalid configuration: missing required fields")

Functions

func DatabaseConnection

func DatabaseConnection(ctx context.Context, pool *pgxpool.Pool) (*pgx.Conn, error)

func DatabasePool

func DatabasePool(ctx context.Context, cfg config.DatabaseConfig) (*pgxpool.Pool, error)

func NewAnalysisID

func NewAnalysisID() (string, error)

Returns a string of format: text_analysis_randomnumber_currentdate.

func NewAnalysisIDWithSuffix

func NewAnalysisIDWithSuffix(suffix string) (string, error)

func NewWordsTextFileWriter

func NewWordsTextFileWriter(f *os.File) *wordsTextFileWriter

func ValidateDatabaseConfig

func ValidateDatabaseConfig(cfg config.DatabaseConfig) error

func Write

func Write(data []byte, w WordsWriter) error

Types

type TextAnalysis

type TextAnalysis struct {
	ID            string         `json:"id"`
	WordFrequency map[string]int `json:"wordFrequency"`
	// contains filtered or unexported fields
}

TextAnalysis represents a struct which contains WordFrequency field and a Name field of this analysis.

func AnalyzeFrequency

func AnalyzeFrequency(words []string) (*TextAnalysis, error)

func NewTextAnalysis

func NewTextAnalysis() (*TextAnalysis, error)

Creates a new TextAnalysis.

func (*TextAnalysis) IncWordCount

func (ta *TextAnalysis) IncWordCount(word string)

Adds new occurrence of a word. Goroutine safe.

type WordsWriter

type WordsWriter interface {
	Write(words []byte) (int, error)
}

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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