fakebox

package
v0.3.1 Latest Latest
Warning

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

Go to latest
Published: Oct 9, 2019 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package fakebox provides a client for accessing Fakebox services.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Analysis

type Analysis struct {
	// Title is the response object for the title analysis.
	Title Title `json:"title"`
	// Content is the response object for the content analysis.
	Content Content `json:"content"`
	// Domain is the response object for the domain analysis.
	Domain Domain `json:"domain"`
}

Analysis represents an analysis of title, content and domain.

type Client

type Client struct {

	// HTTPClient is the http.Client that will be used to
	// make requests.
	HTTPClient *http.Client
	// contains filtered or unexported fields
}

Client is an HTTP client that can make requests to the box.

func New

func New(addr string) *Client

New makes a new Client.

func (*Client) Check

func (c *Client) Check(title string, content string, u *url.URL) (*Analysis, error)

Check passes the text from the Reader to fakebox for analysis.

func (*Client) Info

func (c *Client) Info() (*boxutil.Info, error)

Info gets the details about the box.

type Content

type Content struct {
	// Decision is the string representing the decision could be bias/unsure/impartial.
	Decision string `json:"decision,omitempty"`
	// Score is the numeric score of the decision is between 0.00 (bias) and 1.00 (impartial).
	Score float64 `json:"score,omitempty"`
	// Entities represents entities discovered in the text.
	Entities []Entity `json:"entities,omitempty"`
	// Keywords are the most relevant keywords extracted from the text.
	Keywords []Keyword `json:"keywords"`
}

Content is the response object for the content analysis.

type Domain

type Domain struct {
	// Domain is the domain extracted from the URL.
	Domain string `json:"domain,omitempty"`
	// Category is one of the listed on the API docs.
	Category string `json:"category,omitempty"`
}

Domain is the response object for the domain analysis.

type Entity

type Entity struct {
	// Type is a string describing the kind of entity.
	Type string `json:"type"`
	// Text is the text of the entity.
	Text string `json:"text"`
	// Start is the absolute start position of the entity (in the original text).
	Start int `json:"start"`
	// Start is the absolute end position of the entity (in the original text).
	End int `json:"end"`
}

Entity represents an entity discovered in the text.

type Keyword

type Keyword struct {
	Keyword string `json:"keyword"`
}

Keyword represents a key word.

type Title

type Title struct {
	// Decision is the string representing the decision could be bias/unsure/impartial.
	Decision string `json:"decision,omitempty"`
	// Score is the numeric score of the decision is between 0.00 (bias) and 1.00 (impartial).
	Score float64 `json:"score,omitempty"`
	// Entities represents entities discovered in the text.
	Entities []Entity `json:"entities,omitempty"`
}

Title is the response object for the title analysis.

Jump to

Keyboard shortcuts

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