fresheye

package module
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 15, 2021 License: AGPL-3.0 Imports: 7 Imported by: 1

README

fresheye License GoDoc Coverage report Pipeline status

Install

go get -u gitlab.com/opennota/fresheye
go install gitlab.com/opennota/fresheye/cmd/fesrv@latest

See also

You can find the original Fresh Eye program here: http://kirsanov.com/fresheye/

Documentation

Overview

Package fresheye provides a way to find paronyms in Russian text.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ContextSize

func ContextSize(n int) option

ContextSize option sets the size of a window within which the words will be compared to each other. With size = 1, each word will be compared to its left and right neighbor only.

func ExcludeProperNames

func ExcludeProperNames(ex bool) option

ExcludeProperNames option sets whether words starting with a capital letter and not at the beginning of a sentence should be reported.

func SensitivityThreshold

func SensitivityThreshold(n int) option

SensitivityThreshold option sets the threshold for badness so that word pairs with badness below the threshold won't be reported.

func ToColoredHTML

func ToColoredHTML(text string,
	contextSize int,
	sensitivityThreshold int,
	excludeProperNames bool,
) string

ToColoredHTML returns text with bad word pairs colored using HTML tags.

Types

type BadPair

type BadPair struct {
	Badness       float64
	First, Second WordDescriptor
}

BadPair is a word pair and a measure of similarity (badness) of these words.

func Check

func Check(it WordIterator, options ...option) []BadPair

Check returns a slice of bad word pairs.

type Colorizer

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

Colorizer is a way to assign colors to words given a slice of bad word pairs.

func NewColorizer

func NewColorizer(threshold int) *Colorizer

NewColorizer returns a Colorizer with a given sensitivity threshold.

func (*Colorizer) Color

func (c *Colorizer) Color(d WordDescriptor) color.RGBA

Color returns the color assigned to the word descriptor d. You must call Colorize before calling Color.

func (*Colorizer) Colorize

func (c *Colorizer) Colorize(pairs []BadPair)

Colorize assigns colors to words from pairs. To get the color assigned to a word descriptor d, call Color(d).

type SimpleWordDescriptor

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

SimpleWordDescriptor describes the position of a word in a string.

func (*SimpleWordDescriptor) End

func (w *SimpleWordDescriptor) End() int

End returns the end position of a word in text.

func (*SimpleWordDescriptor) Start

func (w *SimpleWordDescriptor) Start() int

Start returns the start position of a word in text.

type WordDescriptor

type WordDescriptor interface {
	Start() int
	End() int
}

WordDescriptor describes the position of a word in text.

func WordDescriptors

func WordDescriptors(bad []BadPair) []WordDescriptor

WordDescriptors extracts unique word descriptors from a slice of bad word pairs.

type WordIterator

type WordIterator interface {
	Next() bool
	Word() string
	Sep() string
	ParagraphStart() bool
	Descriptor() WordDescriptor
}

WordIterator returns words one by one.

func NewSimpleWordIterator

func NewSimpleWordIterator(text string) WordIterator

NewSimpleWordIterator returns a WordIterator that will return words from text one by one.

Directories

Path Synopsis
cmd
fesrv
Command fesrv provides a Fresh Eye server.
Command fesrv provides a Fresh Eye server.

Jump to

Keyboard shortcuts

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