tagify

package module
v0.41.1 Latest Latest
Warning

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

Go to latest
Published: Mar 5, 2020 License: Apache-2.0 Imports: 6 Imported by: 0

README

Tagify

Build Status Go Report Card Coverage GoDoc Mentioned in Awesome Go

Gets STDIN, file or HTTP address as an input and returns a list of most popular words ordered by popularity as an output. Currently only supports plain text and HTML.

More info about what is "Tagify" and the reasons behind it can be found here.

Visit playground here:

ZoomIO Tagify

Example, "tagify" this repository (with the limit of 3 tags):

$ tagify -s=https://github.com/zoomio/tagify -l=5
source html plain supports tags

In code (see cmd/cli/cli.go).

Use -no-stop flag to disable filtering out of the stop-words.

Installation

Binary

For MacOS:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/zoomio/tagify/master/_bin/install.sh)"

For Linux:

/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/zoomio/tagify/master/_bin/install.sh linux)"
Go dependency
go get -u github.com/zoomio/tagify/...

Changelog

See CHANGELOG.md

Contributing

See CONTRIBUTING.md

License

Released under the Apache License 2.0.

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	// Source sets target source.
	Source = func(v string) Option {
		return func(c *config) {
			c.source = v
		}
	}

	// Query sets CSS query for the target.
	Query = func(v string) Option {
		return func(c *config) {
			c.query = v
		}
	}

	// Content sets content of the target.
	Content = func(v string) Option {
		return func(c *config) {
			c.content = v
		}
	}

	// TargetType sets content type of the target.
	TargetType = func(v ContentType) Option {
		return func(c *config) {
			c.contentType = v
		}
	}

	// Limit sets the limit of tags for the target.
	Limit = func(v int) Option {
		return func(c *config) {
			c.limit = v
		}
	}

	// Verbose enables high verbosity.
	Verbose = func(v bool) Option {
		return func(c *config) {
			c.verbose = v
		}
	}

	// NoStopWords enables stop-words exclusion from the output.
	NoStopWords = func(v bool) Option {
		return func(c *config) {
			c.noStopWords = v
		}
	}

	// ContentOnly ignores all none content related parts of the HTML page.
	ContentOnly = func(v bool) Option {
		return func(c *config) {
			c.contentOnly = v
		}
	}

	// FullSite tells parser to process full site (HTML only).
	FullSite = func(v bool) Option {
		return func(c *config) {
			c.fullSite = v
		}
	}
)

Functions

func ToStrings added in v0.4.0

func ToStrings(items []*processor.Tag) []string

ToStrings transforms a list of tags into a list of strings.

Types

type ContentType added in v0.2.0

type ContentType byte

ContentType ...

const (
	Unknown ContentType = iota
	Text
	HTML
	Markdown
)

Content types

func ContentTypeOf added in v0.2.0

func ContentTypeOf(contentType string) ContentType

ContentTypeOf returns ContentType based on string value.

func (ContentType) String added in v0.2.0

func (ct ContentType) String() string

String ...

type Meta added in v0.29.0

type Meta struct {
	ContentType ContentType
	DocTitle    string
	DocHash     string
}

Meta extra information.

type Option added in v0.18.0

type Option func(*config)

Option allows to customise configuration.

type Result added in v0.29.0

type Result struct {
	Meta *Meta
	Tags []*processor.Tag
}

Result represents result of Tagify.

func Run added in v0.18.0

func Run(ctx context.Context, options ...Option) (*Result, error)

Run produces slice of tags ordered by frequency.

func (*Result) ForEach added in v0.40.0

func (r *Result) ForEach(fn func(i int, tag *processor.Tag))

ForEach iterates through the slice of Tags and calls provided "fn" on every iteration.

func (*Result) Len added in v0.29.0

func (r *Result) Len() int

Len returns count of tags in the result.

func (*Result) TagsStrings added in v0.29.0

func (r *Result) TagsStrings() []string

TagsStrings transforms slice of tags into a slice of strings.

Directories

Path Synopsis
cmd
cli

Jump to

Keyboard shortcuts

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