paperswithcode_go

package module
v2.3.0 Latest Latest
Warning

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

Go to latest
Published: Mar 17, 2022 License: MIT Imports: 10 Imported by: 1

README

paperswithcode-go

Go Go Report Card Go Reference codecov

This is a client for PapersWithCode read/write API.

For Python version, see https://github.com/paperswithcode/paperswithcode-client

Quick usage example

import "github.com/codingpot/paperswithcode-go/v2"
c := paperswithcode_go.NewClient()
papers, _ := c.PaperList(paperswithcode_go.PaperListParamsDefault())
gan, _ := c.PaperGet(paperswithcode_go.GetPaperIDFromPaperTitle("Generative Adversarial Networks"))

Documentation

Overview

Example
c := paperswithcode_go.NewClient()
papers, _ := c.PaperList(paperswithcode_go.PaperListParamsDefault())
fmt.Println(len(papers.Results))

gan, _ := c.PaperGet(paperswithcode_go.GetPaperIDFromPaperTitle("Generative Adversarial Networks"))
fmt.Println(gan.Title)
Output:

50
Generative Adversarial Networks

Index

Examples

Constants

View Source
const (
	BaseURL = "https://paperswithcode.com/api/v1"
)

Variables

This section is empty.

Functions

func GetPaperIDFromPaperTitle

func GetPaperIDFromPaperTitle(paperTitle string) string

GetPaperIDFromPaperTitle generates a paper ID from paper title. WARNING: This function does not cover all cases.

Example
paperTitle := "Generative Adversarial Networks"
fmt.Println(GetPaperIDFromPaperTitle(paperTitle))
Output:

generative-adversarial-networks

Types

type Client

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

func NewClient

func NewClient(opts ...ClientOption) Client

NewClient creates a Client object.

func (*Client) MethodGet added in v2.2.0

func (c *Client) MethodGet(methodID string) (models.Method, error)

MethodGet returns a method in a paper. See https://paperswithcode-client.readthedocs.io/en/latest/api/client.html#paperswithcode.client.PapersWithCodeClient.method_list

func (*Client) MethodList added in v2.2.0

func (c *Client) MethodList(params MethodListParams) (models.MethodList, error)

MethodList fetches a list of "methods" that can be used in research papers.

func (*Client) PaperGet

func (c *Client) PaperGet(paperID string) (models.Paper, error)

PaperGet returns a single paper. Note that paperID is hyphen cased (e.g., generative-adversarial-networks).

func (*Client) PaperList

func (c *Client) PaperList(params PaperListParams) (models.PaperList, error)

PaperList returns multiple papers.

func (*Client) PaperMethodList

func (c *Client) PaperMethodList(paperID string) (models.MethodList, error)

PaperMethodList returns the methods used in the given paper.

func (*Client) PaperRepositoryList

func (c *Client) PaperRepositoryList(paperID string) (models.RepositoryList, error)

PaperRepositoryList returns repositories related to the given paper.

func (*Client) PaperResultList

func (c *Client) PaperResultList(paperID string) (models.ResultList, error)

PaperResultList returns the evaluation results of the paper.

func (*Client) PaperTaskList

func (c *Client) PaperTaskList(paperID string) (models.TaskList, error)

PaperTaskList returns tasks (an area of research) for the given paper.

type ClientOption

type ClientOption func(*Client)

ClientOption can be used to swap the default http client or swap the API key

func WithAPIToken

func WithAPIToken(apiToken string) ClientOption

WithAPIToken sets the client API token.

type MethodListParams added in v2.2.0

type MethodListParams struct {
	// Page (default: 1)
	Page int
	// ItemsPerPage (default: 50)
	ItemsPerPage int
}

MethodListParams is an argument object to MethodList.

func (MethodListParams) Build added in v2.3.0

func (m MethodListParams) Build() string

Build used to expand `MethodListParams` to URL path params.

type PaperListParams

type PaperListParams struct {
	// Q to search papers (default: "")
	// If empty, it returns all papers.
	Q        string
	ArxivID  string
	Title    string
	Abstract string
	// Page is the number of page to search (default: 1)
	Page int
	// ItemsPerPage returns how many papers are returned in a single response.
	ItemsPerPage int
}

PaperListParams is the parameter for PaperList method.

func PaperListParamsDefault

func PaperListParamsDefault() PaperListParams

PaperListParamsDefault returns the default PaperListParams.

func (PaperListParams) Build added in v2.1.3

func (p PaperListParams) Build() string

Directories

Path Synopsis
cmd
internal

Jump to

Keyboard shortcuts

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