pcfg

package
v0.5.1 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2026 License: GPL-2.0 Imports: 7 Imported by: 0

Documentation

Index

Constants

View Source
const (
	Alpha    = "A"
	Digit    = "D"
	Other    = "O"
	Keyboard = "K"
	Context  = "X"
	Year     = "Y"
	Markov   = "M"
	Cap      = "C"
	Email    = "E"
	Website  = "W"
)

TransitionID constants

Variables

This section is empty.

Functions

func CleanExistingFiles

func CleanExistingFiles(dir string) error

removes all files in a directory (not subdirectories)

func CreateRuleFolders

func CreateRuleFolders(baseDir string) error

creates the directory structure for a pcfg rule

func EnsureDir

func EnsureDir(path string) error

creates a directory (and parents) if it does not exist

func NewScanner

func NewScanner(path string) (*bufio.Scanner, *os.File, error)

returns a buffered scanner for the given file

func NewWriter

func NewWriter(path string) (*bufio.Writer, *os.File, error)

returns a buffered writer for the given file path (creates/truncates)

func ParseTSVLine

func ParseTSVLine(line string) (string, string, bool)

splits a tab-separated line into value and probability string

func WriteProbFile

func WriteProbFile(path string, entries []ProbEntry) error

writes probability entries to a file in "value\tprob\n" format

Types

type BaseStructure

type BaseStructure struct {
	Prob         float64
	Replacements []string
}

represents a base structure with its probability and replacement types

type Grammar

type Grammar map[string][]GrammarEntry

maps transition type names to ordered slices of GrammarEntry

type GrammarEntry

type GrammarEntry struct {
	Values []string
	Prob   float64
}

groups terminal values sharing the same probability

type PTItem

type PTItem struct {
	Prob     float64
	PT       []PTNode
	BaseProb float64
}

parse tree item used in the priority queue

type PTNode

type PTNode struct {
	Type  string
	Index int
}

single node in a parse tree: a type (e.g. "A4") and an index into the grammar

type ProbEntry

type ProbEntry struct {
	Value string
	Prob  float64
	Count int
}

stores a value, its probability, and count

func CounterToProbs

func CounterToProbs(counter map[string]int) []ProbEntry

converts a map[string]int counter to a probability-sorted list

type ProbPair

type ProbPair struct {
	Value string
	Count int
}

stores a value and its probability for sorted output

type Section

type Section struct {
	Value string
	Type  string // empty string means unclassified
}

section represents a parsed segment of a password value is the raw string content, Type is the classification (e.g. "A4", "D2", "K5", "Y1", nil)

Jump to

Keyboard shortcuts

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