rssfilter

package
v0.0.9 Latest Latest
Warning

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

Go to latest
Published: Feb 25, 2024 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Good bayesian.Class = "Good"
	Bad  bayesian.Class = "Bad"
)

分類するクラス一覧

Variables

This section is empty.

Functions

func SliceUnique

func SliceUnique(target []string) (unique []string)

SliceUnique はリストの重複を取り除きます

Types

type BayesClassifier

type BayesClassifier struct {
	Classifier *bayesian.Classifier
}

BayesClassifier はナイーブベイズのモデルです

func GenerateBayesModel

func GenerateBayesModel(r RSS) (*BayesClassifier, error)

GenerateBayesModel はRSSからナイーブベイズのモデルを生成します。

func LoadBayesModel

func LoadBayesModel(filename string) (*BayesClassifier, error)

LoadBayesModel はファイルからモデルをロードします

func (BayesClassifier) Classify

func (b BayesClassifier) Classify(words *[]string) (string, error)

func (BayesClassifier) Status added in v0.0.4

func (b BayesClassifier) Status() *BayesStatus

Status returns the result of learned status

func (BayesClassifier) Store

func (b BayesClassifier) Store(filename string) error

Store はナイーブベイズのモデルを保存します

type BayesStatus added in v0.0.4

type BayesStatus struct {
	LearnedCount   int            `json:"learned_count,omitempty"`
	WordsByClasses []WordsByClass `json:"words_by_classes,omitempty"`
}

BayesStatus stores the result of learned status

type RSS

type RSS struct {
	Title   string      `json:"title,omitempty"`
	Entries *[]RSSEntry `json:"entries,omitempty"`
}

RSS はRSS全体を示します

func CreateRSSFromURL added in v0.0.3

func CreateRSSFromURL(URL string) (*RSS, error)

CreateRSSFromURL は指定されたURLからRSSを生成します。

func (RSS) Classify

func (r RSS) Classify(classifier *BayesClassifier) error

Classify は未分類の記事を分類します

func (RSS) GenerateRss added in v0.0.3

func (r RSS) GenerateRss(url string) (*string, error)

GenerateRss generates RSS XML

type RSSEntry

type RSSEntry struct {
	Title       string    `json:"title,omitempty"`
	Description string    `json:"description,omitempty"`
	Link        string    `json:"link"`
	Published   time.Time `json:"published"`
	Categories  []string  `json:"categories,omitempty"`
	Retrieved   time.Time `json:"retrieved,omitempty"`
	Reputation  string    `json:"reputation,omitempty"`
}

RSSEntry はRSSの特定の記事を示します

func (RSSEntry) GenerateLearnData

func (e RSSEntry) GenerateLearnData() (string, *[]string, error)

GenerateLearnData はRSSEntryから分類データを生成します。

type Storage

type Storage interface {
	Store(rss *RSS)
}

type StorageJSON

type StorageJSON struct {
	FileName string
}

StorageJSON はStorageを実装し、JSONによりRSSを保存します。

func (StorageJSON) Load

func (j StorageJSON) Load() (*RSS, error)

Load は保存済みのファイルをロードします

func (StorageJSON) StoreUnique

func (j StorageJSON) StoreUnique(rss *RSS) error

StoreUnique はRSSと既に保存済みのファイルを比較し、新たに追加されたものを追記します

type WordScore added in v0.0.4

type WordScore struct {
	Word  string  `json:"word,omitempty"`
	Score float64 `json:"score,omitempty"`
}

WordScore stores set of word and score

type WordsByClass added in v0.0.4

type WordsByClass struct {
	ClassName  string      `json:"class_name,omitempty"`
	WordScores []WordScore `json:"word_scores,omitempty"`
}

WordsByClass stores class name and list of scores words.

Jump to

Keyboard shortcuts

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