detect

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: MIT Imports: 2 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package detect decides which tool to jump to for a piece of text: it takes a sample, runs the registry's Detectors and applies the threshold and the tie rule. The heuristics live in each tool's Detect.

Index

Constants

View Source
const (
	SampleBytes = 64 << 10 // sample size
	Threshold   = 0.5      // minimum score to jump
	TieGap      = 0.1      // gap below which the user is asked
)

Variables

This section is empty.

Functions

func Sample

func Sample(s string) string

Sample cuts s to SampleBytes without splitting a UTF-8 character.

Types

type Outcome

type Outcome struct {
	// Best is the chosen tool; nil when nothing beats Threshold or when
	// there is a tie.
	Best *registry.Scored
	// Candidates are the tools above Threshold, highest first. On a tie,
	// only those within TieGap of the first one.
	Candidates []registry.Scored
	Ambiguous  bool
}

Outcome is the detection result.

func Run

func Run(reg *registry.Registry, text string) Outcome

Run detects on a sample of text.

Jump to

Keyboard shortcuts

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