analyze

package
v0.12.1 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 16 Imported by: 0

Documentation

Overview

Package analyze provides analysis of the news Items.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Delta added in v0.6.0

type Delta struct {
	Word  string
	Count [2]float64
}

Delta is a word and its frequency in two different time periods.

func (Delta) Change added in v0.6.0

func (d Delta) Change() float64

Change returns how much the frequency of a word has changed from one Period to the other.

type DeltaList added in v0.6.0

type DeltaList []Delta

DeltaList is a list of Delta, analogous to the WordList

type Period

type Period struct {
	Begin time.Time
	End   time.Time
}

Period represents a timespan.

func NewPeriod

func NewPeriod(begin time.Time, dur time.Duration) *Period

NewPeriod creates a new Period, beginning at the specified Time, ending after the specified Duration.

func (*Period) Duration

func (p *Period) Duration() time.Duration

Duration returns the Period's duration.

func (*Period) Next

func (p *Period) Next() *Period

Next returns the Period following the receiver.

func (*Period) Previous

func (p *Period) Previous() *Period

Previous returns the Period prior to the receiver.

func (*Period) String

func (p *Period) String() string

type Series added in v0.7.0

type Series struct {
	Periods     []Period
	Frequencies map[string][]float64
}

Series is a list of word frequencies over a longer time span.

type TrendScout

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

TrendScout looks for the most frequent words in a given period, and how the distribution changed compared to earlier periods.

func NewTrendScout

func NewTrendScout(pool *database.Pool) (*TrendScout, error)

NewTrendScout creates a new TrendScout

func (*TrendScout) AnalyzeDelta added in v0.6.0

func (ts *TrendScout) AnalyzeDelta(p1, p2 *Period, cnt int) (DeltaList, error)

AnalyzeDelta calculates the changes in word frequencies between two Periods.

func (*TrendScout) AnalyzePeriod

func (ts *TrendScout) AnalyzePeriod(p *Period, cnt int) (WordList, error)

AnalyzePeriod calculates the frequencies of words in a given Period.

func (*TrendScout) ComputeSeries added in v0.7.0

func (ts *TrendScout) ComputeSeries(interval time.Duration, icnt, wcnt int) (*Series, error)

ComputeSeries computes a series of frequencies.

type Word

type Word struct {
	Word  string
	Count float64
}

Word is a word (duh!) and the number of times it occured in a given period. Sorry about the name.

type WordList

type WordList []Word

WordList is a list of words and their frequencies in a given Period.

type WordMap

type WordMap map[string]float64

WordMap maps a word to its frequency in a given Period.

Jump to

Keyboard shortcuts

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