querygkg {gkgraphR}R Documentation

Performs a query on the Google Knowledge Graph API

Description

Performs a query on the Google Knowledge Graph API

Usage

querygkg(
  query = NULL,
  ids = NULL,
  lang = NULL,
  types = NULL,
  indent = NULL,
  prefix = NULL,
  limit = NULL,
  json = FALSE,
  itemList = TRUE,
  cleanIDs = TRUE,
  api.key
)

Arguments

query

A character string to search for in Google Knowledge Graph.

ids

A list of one or more entity IDs to search for in Google Knowledge Graph. Should be a Google Knowledge Graph or Freebase ID code in character string format.

lang

A character argument defining the language filter. The list of language codes (defined in ISO 639) to run the query with, for instance 'en'. Defaults to NULL.

types

A character argument restricting returned entities to those of the specified types. See schema.org for valid types (e.g. 'Person' as defined in http://schema.org/Person restricts the results to entities representing people). If multiple types are specified, returned entities will contain one or more of these types. Defaults to NULL.

indent

A logical argument enabling indenting of JSON results. Defaults to NULL.

prefix

A logical argument enabling prefix (initial substring) matching against names and aliases of entities. For example, a prefix 'Jung' will match entities and aliases such as 'Jung', 'Jungle', and 'Jung-ho Kang'. Defaults to NULL.

limit

A numeric value limiting the number of entities to be returned. Maximum is 500. Defaults to 20. Please note that requests with high limits have a higher chance of timing out.

json

A logical argument defining whether the API query should be returned in the original JSON format or as an R object. Defaults to FALSE.

itemList

Should the query contain only the Google Knowledge Graph item list returned by the query? Defaults to TRUE. Only valid when returning R objects (i.e. parameter json = FALSE).

cleanIDs

If the output is an item list, should it return clean IDs? Defaults to TRUE. Only valid when returning an item list (i.e. parameter json = FALSE and parameter itemList = TRUE).

api.key

A Google API key.

Value

Returns the Google Knowledge Graph output.

Examples

## Not run: 
# Note: Function querygkg requires a valid Google API key to work

# Run a text-based query for the term "apple"
querygkg(query = "apple", api.key = "YOUR_API_KEY")

# Run an ID-based query for the entity "apple" representing the fruit
querygkg(ids = "/m/014j1m", api.key = "YOUR_API_KEY")

# Run an ID-based query and get the original JSON object returned by the API
querygkg(ids = "/m/014j1m", json = TRUE, api.key = "YOUR_API_KEY")

## End(Not run)

[Package gkgraphR version 1.0.2 Index]