Documentation
¶
Index ¶
- func GenerateCitationKey(w *Work) string
- func SanitizeLaTeX(s string) string
- type Analysis
- type BibtexOption
- type Category
- type CitationKeyInfo
- type Collection
- func (c *Collection) All() iter.Seq[*Work]
- func (c *Collection) CitationGraph() (gograph.Graph[string], error)
- func (c *Collection) Clean() (*Collection, error)
- func (c *Collection) Keep(labels ...string) (*Collection, error)
- func (c *Collection) Len() int
- func (c *Collection) Main() iter.Seq[*Work]
- type Link
- type Node
- type NodeMetadata
- type References
- type Result
- type Work
- func (w *Work) AddSimpleId() *Work
- func (w *Work) Clone(options ...WorkOption) *Work
- func (w *Work) GetPermalink() *string
- func (w *Work) ID(source string) (string, bool)
- func (w *Work) KeepReferences(ids ...string) *Work
- func (w *Work) Key() *string
- func (w *Work) Merge(other *Work) *Work
- func (w *Work) PurgeReferences(ids ...string) *Work
- func (w *Work) SetSimpleLabel() *Work
- func (w *Work) SimpleId() *string
- func (w *Work) SimpleLabel() *string
- func (w *Work) ToBibEntry(opts ...BibtexOption) *bibtex.BibEntry
- func (w *Work) ToBibTeX(opts ...BibtexOption) string
- type WorkOption
- type Works
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GenerateCitationKey ¶ added in v0.4.0
GenerateCitationKey generates a clean, URL-safe citation key for a work.
func SanitizeLaTeX ¶ added in v0.4.0
SanitizeLaTeX escapes common LaTeX reserved characters (%, &, _, #) in plain text, avoiding double-escaping if a character is already preceded by a backslash.
Types ¶
type Analysis ¶
Analysis represents the complete bibliographic analysis dataset, containing all analyzed nodes and citation links.
func (*Analysis) CitationGraph ¶
CitationGraph constructs and returns a directed, acyclic, weighted citation graph from the analysis links and nodes.
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.
type Link ¶
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 ¶
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 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
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 (*Work) GetPermalink ¶ added in v0.6.0
Permalink returns the permalink of the Work if it exists.
func (*Work) ID ¶ added in v0.6.0
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
KeepReferences returns a cloned Work retaining only references that match at least one of the given IDs.
func (*Work) Merge ¶ added in v0.6.0
Merge creates a new Work by merging the fields of the current Work with another Work.
func (*Work) PurgeReferences ¶ added in v0.6.0
PurgeReferences returns a cloned Work with any references matching the given IDs removed.
func (*Work) SetSimpleLabel ¶ added in v0.6.0
SetSimpleLabel sets a simplified label for the Work.
func (*Work) SimpleLabel ¶ added in v0.6.0
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) Deduplicate ¶ added in v0.6.0
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.