models

package
v0.0.1 Latest Latest
Warning

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

Go to latest
Published: May 30, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analysis

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

func (*Analysis) CitationGraph

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

func (*Analysis) Keep

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

func (*Analysis) Query

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

type Article

type Article 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"`
	Journal    *string                  `json:"journal,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"`
}

func (*Article) AddSimpleId

func (a *Article) AddSimpleId() *Article

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

func (*Article) Clone

func (a *Article) Clone(options ...ArticleOption) *Article
func (a *Article) GetPermalink() *string

Permalink returns the permalink of the Article if it exists.

func (*Article) ID

func (a *Article) ID(source string) (string, bool)

func (*Article) KeepReferences

func (a *Article) KeepReferences(ids ...string) *Article

func (*Article) Key

func (a *Article) Key() *string

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

func (*Article) Merge

func (a *Article) Merge(other *Article) *Article

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

func (*Article) PurgeReferences

func (a *Article) PurgeReferences(ids ...string) *Article

func (*Article) SetSimpleLabel

func (a *Article) SetSimpleLabel() *Article

SetSimpleLabel sets a simplified label for the Article.

func (*Article) SimpleId

func (a *Article) SimpleId() *string

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

func (*Article) SimpleLabel

func (a *Article) SimpleLabel() *string

SimpleLabel returns a simplified label for the Article.

type ArticleOption

type ArticleOption func(*Article)

func WithReferences

func WithReferences(references []*Article) ArticleOption

type Articles

type Articles []*Article

func (*Articles) All

func (a *Articles) All() iter.Seq[*Article]

All returns a slice of all articles including their references

func (*Articles) Deduplicate

func (a *Articles) Deduplicate() (Articles, error)

Deduplicate returns a slice of unique articles, preserving the order of the first occurrence of each article.

func (*Articles) UniqueById

func (a *Articles) UniqueById() (map[string]*Article, error)

UniqueById returns a map of unique articles by their IDs.

type Category

type Category string
const (
	CategoryRoot  Category = "root"
	CategoryTrunk Category = "trunk"
	CategoryLeaf  Category = "leaf"
)

type Collection

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

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

func NewCollection

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

NewCollection creates a new Collection instance with deduplicated articles.

func (*Collection) All

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

All returns an iterator over all articles 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 articles 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)

func (*Collection) Len

func (c *Collection) Len() int

Len returns the number of articles in the collection.

func (*Collection) Main

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

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

func (*Collection) MarshalJSON

func (c *Collection) MarshalJSON() ([]byte, error)

MarshalJSON implements the json.Marshaler interface for Collection.

func (*Collection) Merge

func (c *Collection) Merge(other *Collection) (*Collection, error)

Merge merges another collection into the current collection.

func (*Collection) Purge

func (c *Collection) Purge(ids ...string) (*Collection, error)

Purge removes articles from the collection by their IDs.

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

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"`
	Article   *Article `json:"article"`
}

func (*Node) Filename

func (n *Node) Filename() string

func (*Node) Metadata

func (n *Node) Metadata() *NodeMetadata

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"`
	Journal    *utils.FoldedString `yaml:"journal,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"`
}

type References

type References []*Article

References prevents circular references by using a slice of Article 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"`
	Article *Article `json:"article"`
}

Jump to

Keyboard shortcuts

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