paperswithcode_go

package module
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: May 30, 2021 License: MIT Imports: 9 Imported by: 0

README

paperswithcode-go

Go 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"
c := paperswithcode_go.NewClient()
papers, _ := c.PaperList(paperswithcode_go.PaperListParamsDefault())
gan, _ := c.PaperGet(paperswithcode_go.GetPaperIDFromPaperTitle("Generative Adversarial Networks"))

Documentation

Overview

Example
package main

import (
	"fmt"

	paperswithcode_go "github.com/codingpot/paperswithcode-go"
)

func main() {
	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)
	fmt.Println(gan.Authors)

}
Output:

50
Generative Adversarial Networks
[Ian J. Goodfellow Jean Pouget-Abadie Mehdi Mirza Bing Xu David Warde-Farley Sherjil Ozair Aaron Courville Yoshua Bengio]

Index

Examples

Constants

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

Variables

This section is empty.

Functions

func GetPaperIDFromPaperTitle added in v0.3.0

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

generative-adversarial-networks

Types

type Client

type Client struct {
	BaseURL    string
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

func NewClient

func NewClient(opts ...ClientOption) *Client

NewClient creates a Client object.

func (*Client) PaperGet

func (c *Client) PaperGet(paperID string) (*models.PaperListResultItem, 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.PaperListResult, error)

func (*Client) PaperMethodList added in v0.3.0

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

func (*Client) PaperRepositoryList added in v0.3.0

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

func (*Client) PaperResultList added in v0.3.0

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

func (*Client) PaperTaskList added in v0.3.0

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

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 PaperListParams

type PaperListParams struct {
	Query string
	Page  int
	Limit int
}

func PaperListParamsDefault

func PaperListParamsDefault() PaperListParams

func (PaperListParams) Build

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