Description Usage Arguments Details Value See Also Examples
View source: R/natural-language.R
Analyse text entities, sentiment, syntax and categorisation using the Google Natural Language API
1 2 3 4 5 6 7 8 | gl_nlp(
string,
nlp_type = c("annotateText", "analyzeEntities", "analyzeSentiment", "analyzeSyntax",
"analyzeEntitySentiment", "classifyText"),
type = c("PLAIN_TEXT", "HTML"),
language = c("en", "zh", "zh-Hant", "fr", "de", "it", "ja", "ko", "pt", "es"),
encodingType = c("UTF8", "UTF16", "UTF32", "NONE")
)
|
string |
A vector of text to detect language for, or Google Cloud Storage URI(s) |
nlp_type |
The type of Natural Language Analysis to perform. The default |
type |
Whether input text is plain text or a HTML page |
language |
Language of source, must be supported by API. |
encodingType |
Text encoding that the caller uses to process the output |
string
can be a character vector, or a location of a file content on Google cloud Storage.
This URI must be of the form gs://bucket_name/object_name
Encoding type can usually be left at default UTF8
.
Read more here
The current language support is available here
A list of the following objects, if those fields are asked for via nlp_type
:
sentences - Sentences in the input document
tokens - Tokens, along with their syntactic information, in the input document
entities - Entities, along with their semantic information, in the input document
documentSentiment - The overall sentiment for the document
classifyText -Classification of the document
language - The language of the text, which will be the same as the language specified in the request or, if not specified, the automatically-detected language
text - The original text passed into the API. NA
if not passed due to being zero-length etc.
https://cloud.google.com/natural-language/docs/reference/rest/v1/documents
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | ## Not run:
text <- "to administer medicince to animals is frequently a very difficult matter,
and yet sometimes it's necessary to do so"
nlp <- gl_nlp(text)
nlp$sentences
nlp$tokens
nlp$entities
nlp$documentSentiment
## vectorised input
texts <- c("The cat sat one the mat", "oh no it didn't you fool")
nlp_results <- gl_nlp(texts)
## End(Not run)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.