Help us shape the future of Go! Take the 2026 Go Developer Survey

models

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 24 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GenerateCitationKey added in v0.4.0

func GenerateCitationKey(w *Work) string

GenerateCitationKey generates a clean, URL-safe citation key for a work.

func SanitizeLaTeX added in v0.4.0

func SanitizeLaTeX(s string) string

SanitizeLaTeX escapes common LaTeX reserved characters (%, &, _, #) in plain text, avoiding double-escaping if a character is already preceded by a backslash.

Types

type Analysis

type Analysis struct {
	Nodes []*Node `json:"nodes"`
	Links []*Link `json:"links"`
}

Analysis represents the complete bibliographic analysis dataset, containing all analyzed nodes and citation links.

func (*Analysis) CitationGraph

func (a *Analysis) CitationGraph() (gograph.Graph[string], error)

CitationGraph constructs and returns a directed, acyclic, weighted citation graph from the analysis links and nodes.

func (*Analysis) Keep

func (a *Analysis) Keep(ids []string) *Analysis

Keep filters the analysis, returning a new Analysis containing only nodes with the specified IDs and links between them.

func (*Analysis) Query

func (a *Analysis) Query(category string, top int) ([]*Result, error)

Query returns the top scored results for the given Tree of Science category ("root", "trunk", or "leaf"), up to top items.

type BibtexOption added in v0.4.0

type BibtexOption func(*bibtexOptions)

BibtexOption specifies configuration options for BibTeX generation.

func WithCiteKey added in v0.4.0

func WithCiteKey(key string) BibtexOption

WithCiteKey specifies a custom citation key for a single Work BibTeX entry.

func WithOmitAbstracts added in v0.4.0

func WithOmitAbstracts(omit bool) BibtexOption

WithOmitAbstracts configures whether the abstract field should be omitted from BibTeX entries.

type Category

type Category string

Category represents the Tree of Science classification category of an analysis node.

const (
	// CategoryRoot represents foundational, seminal works.
	CategoryRoot Category = "root"
	// CategoryTrunk represents core structural works connecting the field.
	CategoryTrunk Category = "trunk"
	// CategoryLeaf represents recent and specialized works at the frontier.
	CategoryLeaf Category = "leaf"
)

type CitationKeyInfo added in v0.4.0

type CitationKeyInfo struct {
	ID          string `json:"id" jsonschema:"Work identifier in the collection"`
	CiteKey     string `json:"citekey" jsonschema:"Generated BibTeX citation key (disambiguated within the export)"`
	Title       string `json:"title,omitempty" jsonschema:"Work title"`
	Year        *int   `json:"year,omitempty" jsonschema:"Publication year"`
	FirstAuthor string `json:"first_author,omitempty" jsonschema:"Primary author name"`
}

CitationKeyInfo provides metadata for an exported citation.

type Collection

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

Collection represents a collection of works with methods to manage them.

func NewCollection

func NewCollection(a Works) (*Collection, error)

NewCollection creates a new Collection instance with deduplicated works.

func (*Collection) All

func (c *Collection) All() iter.Seq[*Work]

All returns an iterator over all works in the collection, including their references.

func (*Collection) CitationGraph

func (c *Collection) CitationGraph() (gograph.Graph[string], error)

CitationGraph returns a directed graph representing the citation relationships between works in the collection.

func (*Collection) Clean

func (c *Collection) Clean() (*Collection, error)

Clean returns a clean version of the largest connected component of the collection.

func (*Collection) Keep

func (c *Collection) Keep(labels ...string) (*Collection, error)

Keep filters the collection, returning a new Collection containing only works whose keys match the provided labels.

func (*Collection) Len

func (c *Collection) Len() int

Len returns the number of works in the collection.

func (*Collection) Main

func (c *Collection) Main() iter.Seq[*Work]

Main returns an iterator over the main works in the collection, excluding duplicates.

type Link struct {
	Source string  `json:"source"`
	Target string  `json:"target"`
	Weight float64 `json:"weight"`
}

Link represents a directed, weighted citation edge between two nodes in an Analysis.

type Node

type Node struct {
	ID        string   `json:"id"`
	Category  Category `json:"category"`
	Rootness  float64  `json:"rootness"`
	Trunkness float64  `json:"trunkness"`
	Leafness  float64  `json:"leafness"`
	Work      *Work    `json:"work"`
}

Node represents a work entity within an analysis, containing its metadata and Tree of Science category and scores.

func (*Node) Filename

func (n *Node) Filename() string

Filename generates a sanitized, slugified filename with a content hash suffix for exporting the node as markdown.

func (*Node) Metadata

func (n *Node) Metadata() *NodeMetadata

Metadata extracts and constructs the NodeMetadata for this node.

type NodeMetadata

type NodeMetadata struct {
	ID         string              `yaml:"id"`
	Label      string              `yaml:"label"`
	Category   string              `yaml:"category"`
	Rootness   float64             `yaml:"rootness"`
	Trunkness  float64             `yaml:"trunkness"`
	Leafness   float64             `yaml:"leafness"`
	Rich       bool                `yaml:"rich"`
	Title      *utils.FoldedString `yaml:"title,omitempty"`
	Year       *int                `yaml:"year,omitempty"`
	Venue      *utils.FoldedString `yaml:"venue,omitempty"`
	Volume     *string             `yaml:"volume,omitempty"`
	Issue      *string             `yaml:"issue,omitempty"`
	Page       *string             `yaml:"page,omitempty"`
	DOI        *string             `yaml:"doi,omitempty"`
	Permalink  *string             `yaml:"permalink,omitempty"`
	TimesCited *int                `yaml:"times_cited,omitempty"`
	Authors    []string            `yaml:"authors,omitempty"`
	IDs        []string            `yaml:"ids,omitempty"`
}

NodeMetadata represents the YAML-serializable metadata of a Node, commonly used for generating frontmatter in markdown exports.

type References

type References []*Work

References prevents circular references by using a slice of Work pointers.

func (References) MarshalJSON

func (r References) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface.

type Result

type Result struct {
	Score float64 `json:"score"`
	Work  *Work   `json:"work"`
}

Result represents a scored search or query result pointing to an Work.

type Work added in v0.6.0

type Work struct {
	Label       string                   `json:"label"`
	IDs         *collections.Set[string] `json:"ids,omitempty"`
	Authors     []string                 `json:"authors,omitempty"`
	Year        *int                     `json:"year,omitempty"`
	Title       *string                  `json:"title,omitempty"`
	Venue       *string                  `json:"venue,omitempty"`
	Type        *string                  `json:"type,omitempty"`
	VenueType   *string                  `json:"venue_type,omitempty"`
	Publisher   *string                  `json:"publisher,omitempty"`
	Institution *string                  `json:"institution,omitempty"`
	Volume      *string                  `json:"volume,omitempty"`
	Issue       *string                  `json:"issue,omitempty"`
	Page        *string                  `json:"page,omitempty"`
	DOI         *string                  `json:"doi,omitempty"`
	Permalink   *string                  `json:"permalink,omitempty"`
	TimesCited  *int                     `json:"times_cited,omitempty"`
	Keywords    *collections.Set[string] `json:"keywords,omitempty"`
	Abstract    *string                  `json:"abstract,omitempty"`
	References  References               `json:"references,omitempty"`
	Rich        bool                     `json:"rich"`
}

Work represents a bibliographic work, containing citation metadata, identifiers, author information, and references to cited works.

func (*Work) AddSimpleId added in v0.6.0

func (w *Work) AddSimpleId() *Work

AddSimpleId adds a simple ID to the Work's IDs set.

func (*Work) Clone added in v0.6.0

func (w *Work) Clone(options ...WorkOption) *Work

Clone returns a deep copy of the Work, applying any provided WorkOption modifiers.

func (w *Work) GetPermalink() *string

Permalink returns the permalink of the Work if it exists.

func (*Work) ID added in v0.6.0

func (w *Work) ID(source string) (string, bool)

ID extracts the identifier value for the specified prefix source (e.g. "doi", "openalex"). Returns the identifier and true if found, or an empty string and false otherwise.

func (*Work) KeepReferences added in v0.6.0

func (w *Work) KeepReferences(ids ...string) *Work

KeepReferences returns a cloned Work retaining only references that match at least one of the given IDs.

func (*Work) Key added in v0.6.0

func (w *Work) Key() *string

Key returns the first ID of the Work if it exists.

func (*Work) Merge added in v0.6.0

func (w *Work) Merge(other *Work) *Work

Merge creates a new Work by merging the fields of the current Work with another Work.

func (*Work) PurgeReferences added in v0.6.0

func (w *Work) PurgeReferences(ids ...string) *Work

PurgeReferences returns a cloned Work with any references matching the given IDs removed.

func (*Work) SetSimpleLabel added in v0.6.0

func (w *Work) SetSimpleLabel() *Work

SetSimpleLabel sets a simplified label for the Work.

func (*Work) SimpleId added in v0.6.0

func (w *Work) SimpleId() *string

SimpleId returns the first author's name and the year.

func (*Work) SimpleLabel added in v0.6.0

func (w *Work) SimpleLabel() *string

SimpleLabel returns a simplified label for the Work.

func (*Work) ToBibEntry added in v0.6.0

func (w *Work) ToBibEntry(opts ...BibtexOption) *bibtex.BibEntry

ToBibEntry converts the Work into a *bibtex.BibEntry. Accepts optional BibtexOption modifiers (e.g. WithCiteKey, WithOmitAbstracts).

func (*Work) ToBibTeX added in v0.6.0

func (w *Work) ToBibTeX(opts ...BibtexOption) string

ToBibTeX formats a single Work into a BibTeX entry string.

type WorkOption added in v0.6.0

type WorkOption func(*Work)

WorkOption specifies a functional option for configuring an Work.

func WithReferences

func WithReferences(references []*Work) WorkOption

WithReferences sets the references for an Work.

type Works added in v0.6.0

type Works []*Work

Works represents a collection of Work pointers with helper methods for graph construction and deduplication.

func (*Works) All added in v0.6.0

func (w *Works) All() iter.Seq[*Work]

All returns a slice of all works including their references

func (*Works) Deduplicate added in v0.6.0

func (w *Works) Deduplicate() (Works, error)

Deduplicate returns a slice of unique works, preserving the order of the first occurrence of each work.

func (Works) ToBibTeX added in v0.6.0

func (w Works) ToBibTeX(opts ...BibtexOption) string

ToBibTeX formats a collection of Works into a concatenated BibTeX string, automatically disambiguating duplicate citation keys.

func (Works) ToBibTeXWithKeys added in v0.6.0

func (w Works) ToBibTeXWithKeys(opts ...BibtexOption) (string, []CitationKeyInfo)

ToBibTeXWithKeys formats a collection of Works into a concatenated BibTeX string, automatically disambiguating duplicate citation keys, and returns the slice of CitationKeyInfo.

func (*Works) UniqueById added in v0.6.0

func (w *Works) UniqueById() (map[string]*Work, error)

UniqueById returns a map of unique works by their IDs.

Jump to

Keyboard shortcuts

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