algorithm

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jan 9, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AlgorithmType

type AlgorithmType int

AlgorithmType represents the type of matching algorithm

const (
	// AlgorithmAuto automatically selects the best algorithm based on word count
	AlgorithmAuto AlgorithmType = iota
	// AlgorithmDFA uses Deterministic Finite Automaton
	AlgorithmDFA
	// AlgorithmAC uses Aho-Corasick algorithm
	AlgorithmAC
)

func (AlgorithmType) String

func (a AlgorithmType) String() string

String returns the string representation of the algorithm type

type MatchResult

type MatchResult struct {
	Word     string        // The matched word
	Start    int           // Start position (rune index)
	End      int           // End position (rune index)
	Category dict.Category // Category of the word
	Level    dict.Level    // Severity level
}

MatchResult represents a single match result from the algorithm

type Matcher

type Matcher interface {
	// Build constructs the detection structure from the given words
	Build(words []dict.Word) error

	// Match finds all sensitive words in the text and returns their positions
	Match(text string) []MatchResult

	// Replace replaces all sensitive words in the text with the given replacement rune
	Replace(text string, repl rune) string

	// Validate checks if the text contains any sensitive words
	Validate(text string) bool
}

Matcher is the interface that all matching algorithms must implement

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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