bridge

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package bridge는 유사도가 높은데 링크가 없는 문서 쌍을 찾아 관계를 축으로 한 재발견을 돕는다. 후보와 근거만 내고 문장은 만들지 않는다. ADR 0028. 단어 축과 임베딩 축을 각각 자기 하한으로 걸러 합집합으로 낸다. ADR 0075.

Index

Constants

View Source
const (
	AxisTerm  = "term"
	AxisEmbed = "embed"
)

축 식별자다. Pair.Axes 의 값이고 --json 출력에 그대로 나간다.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Min 은 단어 축의 코사인 하한이다.
	Min float64
	// EmbedMin 은 임베딩 축의 코사인 하한이다. 단어 축과 눈금이 다르므로
	// 값을 공유하지 않는다(ADR 0075).
	EmbedMin float64
	// Limit 은 낼 쌍 수 상한이다. 음수면 제한 없다.
	Limit int
	// Vectors 는 색인 경로 기준 임베딩 벡터 맵이다. nil 이면 임베딩
	// 축을 끄고 단어 축만 돈다. 맵에 문서가 빠져 있으면 그 문서는
	// 임베딩 축 후보에서만 빠진다.
	Vectors map[string][]float32
}

Options는 Run 의 인자다.

type Pair

type Pair struct {
	A     string   `json:"a"`
	B     string   `json:"b"`
	Score float64  `json:"score"`
	Axes  []string `json:"axes"`
	// contains filtered or unexported fields
}

Pair는 후보 쌍 하나다. A와 B는 슬러그 오름차순으로 담는다.

type Result

type Result struct {
	Pairs []Pair `json:"pairs"`
	Stats Stats  `json:"stats"`
}

Result는 bridge 계산 결과 전부다.

func Run

func Run(ix *index.Index, g *graph.Graph, st state.State, opts Options) Result

Run은 context 문서 쌍 가운데 단어 축이나 임베딩 축 하나라도 통과하고 링크도 기각도 없는 쌍을 낸다. 두 축을 통과한 쌍의 합집합이지 교집합이 아니다. 두 축은 서로 다른 것을 잡으므로 교집합을 보면 둘 다 잡는 좁은 영역만 남아 재발견이 죽는다(ADR 0075). 같은 입력에 같은 출력이다. 기각 목록은 입력이지 출력이 아니다.

type Stats

type Stats struct {
	ContextDocs int `json:"contextDocs"`
	Linked      int `json:"linked"`
	Rejected    int `json:"rejected"`
	BelowMin    int `json:"belowMin"`
}

Stats는 탈락 사유별 쌍 수다. 후보가 없을 때 이유를 대는 재료로 쓴다. BelowMin 은 두 축 모두 하한에 못 미친 쌍 수다. 한 축이라도 통과하면 후보가 되므로 축별 미달은 세지 않는다.

Jump to

Keyboard shortcuts

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