Documentation ¶
Index ¶
- type Alternative
- type Assumption
- type Assumptions
- type Client
- func (c *Client) GetConversationalQuery(query string, units Unit, lastResult *Conversation) (*Conversation, error)
- func (c *Client) GetFastQueryRecognizer(query string, mode Mode) (*FastQueryResult, error)
- func (c *Client) GetQueryResult(query string, params url.Values) (*QueryResult, error)
- func (c *Client) GetShortAnswerQuery(query string, units Unit, timeout int) (string, error)
- func (c *Client) GetSimpleQuery(query string, params url.Values) (io.ReadCloser, string, error)
- func (c *Client) GetSpokenAnswerQuery(query string, units Unit, timeout int) (string, error)
- type Conversation
- type Delimiters
- type FastQueryResult
- type Generalization
- type Img
- type Info
- type Infos
- type Link
- type Mode
- type Pod
- type QueryResult
- type ReInterpretation
- type Sound
- type Sounds
- type Source
- type Sources
- type Spellcheck
- type State
- type States
- type SubPod
- type Translation
- type Unit
- type Value
- type Warnings
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Alternative ¶
type Alternative struct {
InnerText string `json:",innerxml"`
}
type Assumption ¶
type Assumptions ¶
type Assumptions struct { Assumption []Assumption `json:"assumption"` Count int `json:"count"` }
type Client ¶
type Client struct {
AppID string
}
The client, requires an App ID, which you can sign up for at https://developer.wolframalpha.com/
func (*Client) GetConversationalQuery ¶
func (c *Client) GetConversationalQuery(query string, units Unit, lastResult *Conversation) (*Conversation, error)
func (*Client) GetFastQueryRecognizer ¶
func (c *Client) GetFastQueryRecognizer(query string, mode Mode) (*FastQueryResult, error)
func (*Client) GetQueryResult ¶
GetQueryResult gets the query result from the API and returns it. Example extra parameter: "format=image", for a url.Value it'd be: u := url.Values{} u.Add("format", "image") Additional information about parameters can be found at http://products.wolframalpha.com/docs/WolframAlpha-API-Reference.pdf, page 42
func (*Client) GetShortAnswerQuery ¶
func (*Client) GetSimpleQuery ¶
GetSimpleQuery gets an image from the `simple` endpoint.
Returns the image as a response body, the query url, and an error ¶
Can take some extra parameters, e.g `background=F5F5F5` sets the background color to #F5F5F5
The rest of the parameters can be found here https://products.wolframalpha.com/simple-api/documentation/
type Conversation ¶
type Delimiters ¶
type Delimiters struct {
Text string `json:"text"`
}
type FastQueryResult ¶
type FastQueryResult struct { Version string `json:"version"` SpellingCorrection string `json:"spellingCorretion"` BuildNumber string `json:"buildnumber"` Query []*struct { I string `json:"i"` Accepted string `json:"accepted"` Timing string `json:"timing"` Domain string `json:"domain"` ResultSignificanceScore string `json:"resultsignificancescore"` SummaryBox *struct { Path string `json:"path"` } `json:"summarybox"` } `json:"query"` }
type Generalization ¶
type Infos ¶
If there's extra information for the pod, the pod will have a <infos> element which contains <info> elements with text, and/or images/links to that information
type Pod ¶
type Pod struct { //The subpod elements of the pod SubPods []SubPod `json:"subpods"` //sub elements of the pod Infos []Infos `json:"infos"` States []States `json:"states"` //The pod title, used to identify the pod. Title string `json:"title"` //The name of the scanner that produced this pod. A guide to the type of //data it holds. Scanner string `json:"scanner"` //Not documented currently ID string `json:"id"` Position int `json:"position"` Error bool `json:"error"` NumSubPods int `json:"numsubpods"` Sounds Sounds `json:"sounds"` }
<pod> elements are subelements of <queryresult>. Each contains the results for a single pod
type QueryResult ¶
type QueryResult struct { Query string QueryResult struct { //The pods are what hold the majority of the information Pods []Pod `json:"pods"` //Warnings hold information about for example spelling errors Warnings Warnings `json:"warnings"` //Assumptions show info if some assumption was made while parsing the query Assumptions Assumptions `json:"assumptions"` //Generalizes the query to display more information Generalizations []Generalization `json:"generalization"` //true or false depending on whether the input could be successfully //understood. If false there will be no <pod> subelements Success bool `json:"success"` //true or false depending on whether a serious processing error occurred, //such as a missing required parameter. If true there will be no pod //content, just an <error> sub-element. Error bool `json:"error"` //The number of pod elements NumPods int `json:"numpods"` //Categories and types of data represented in the results DataTypes string `json:"datatypes"` //The number of pods that are missing because they timed out (see the //scantimeout query parameter). TimedOut string `json:"timedout"` //The wall-clock time in seconds required to generate the output. Timing float64 `json:"timing"` //The time in seconds required by the parsing phase. ParseTiming float64 `json:"parsetiming"` //Whether the parsing stage timed out (try a longer parsetimeout parameter //if true) ParseTimedOut bool `json:"parsetimedout"` //A URL to use to recalculate the query and get more pods. ReCalculate string `json:"recalculate"` //These elements are not documented currently ID string `json:"id"` Host string `json:"host"` Server string `json:"server"` Related string `json:"related"` //The version specification of the API on the server that produced this result. Version string `json:"version"` } }
The QueryResult is what you get back after a request
type ReInterpretation ¶
type ReInterpretation struct { Alternatives []Alternative `json:"alternative"` Text string `json:"text"` New string `json:"new"` }
type Sounds ¶
If there was a sound related to the query, if you for example query a musical note You will get a <sound> element which contains a link to the sound
type Sources ¶
type Sources struct { URL string `json:"url"` Text string `json:"text"` Source []Source `json:"source"` }
Each Source contains a link to a web page with the source information
type Spellcheck ¶
type States ¶
"Many pods on the Wolfram|Alpha website have text buttons in their upper-right corners that substitute the contents of that pod with a modified version. In Figure 1, the Result pod has buttons titled "More days", "Sun and Moon", CDT", "GMT", and "Show metric". Clicking any of these buttons will recompute just that one pod to display different information."
type Translation ¶
type Value ¶
type Value struct { Name string `json:"name"` Word string `json:"word"` Description string `json:"desc"` Input string `json:"input"` }
Usually contains info about an assumption
type Warnings ¶
type Warnings struct { //How many warnings were issued Count int `json:"count"` //Suggestions for spelling corrections Spellchecks []Spellcheck `json:"spellcheck"` //"If you enter a query with mismatched delimiters like "sin(x", Wolfram|Alpha attempts to fix the problem and reports //this as a warning." Delimiters []Delimiters `json:"delimiters"` //"[The API] will translate some queries from non-English languages into English. In some cases when it does //this, you will get a <translation> element in the API result." Translations []Translation `json:"translation"` //"[The API] can automatically try to reinterpret a query that it does not understand but that seems close to one //that it can." ReInterpretations []ReInterpretation `json:"reinterpret"` }