Documentation ¶
Index ¶
- Variables
- func DatabaseConnection(ctx context.Context, pool *pgxpool.Pool) (*pgx.Conn, error)
- func DatabasePool(ctx context.Context, cfg config.DatabaseConfig) (*pgxpool.Pool, error)
- func NewAnalysisID() (string, error)
- func NewAnalysisIDWithSuffix(suffix string) (string, error)
- func NewWordsTextFileWriter(f *os.File) *wordsTextFileWriter
- func ValidateDatabaseConfig(cfg config.DatabaseConfig) error
- func Write(data []byte, w WordsWriter) error
- type TextAnalysis
- type WordsWriter
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 DatabasePool ¶
func NewAnalysisID ¶
Returns a string of format: text_analysis_randomnumber_currentdate.
func NewAnalysisIDWithSuffix ¶
func NewWordsTextFileWriter ¶
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 (*TextAnalysis) IncWordCount ¶
func (ta *TextAnalysis) IncWordCount(word string)
Adds new occurrence of a word. Goroutine safe.
type WordsWriter ¶
Click to show internal directories.
Click to hide internal directories.