Title: | Client for 'AWS Comprehend' |
---|---|
Description: | Client for 'AWS Comprehend' <https://aws.amazon.com/comprehend>, a cloud natural language processing service that can perform a number of quantitative text analyses, including language detection, sentiment analysis, and feature extraction. |
Authors: | Thomas J. Leeper [aut] , Antoine Sachet [aut, cre], Dave Kincaid [ctb] |
Maintainer: | Antoine Sachet <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.2.1.9000 |
Built: | 2024-11-22 02:50:13 UTC |
Source: | https://github.com/cloudyr/aws.comprehend |
AWS Comprehend Client Package
Client for AWS Comprehend (https://aws.amazon.com/comprehend0, a cloud natural language processing service that can perform a number of quantitative text analyses, including language detection, sentiment analysis, and feature extraction.
Thomas J. Leeper <[email protected]>
detect_language
, detect_sentiment
, detect_entities
, detect_phrases
Turn a list of data.frames (of different lengths and potentially empty) into a single indexed data.frame. Useful to process a ResultList from 'comprehendHTTP'.
bind_and_index(index, df_list)
bind_and_index(index, df_list)
index |
Vector of indices |
df_list |
List of data.frames to bind and index. Should NOT be a data.frame. |
'index' and 'df_list' should be the same length. An error is raised otherwise.
bind_and_index(1:2, list(data.frame(col = "a"), data.frame(col = "b")))
bind_and_index(1:3, list( data.frame(col = "a"), data.frame(), data.frame(c("b", "c"))))
This is the workhorse function to execute calls to the Comprehend API.
comprehendHTTP( action, query = list(), headers = list(), body = NULL, verbose = getOption("verbose", FALSE), region = Sys.getenv("AWS_DEFAULT_REGION", "us-east-1"), key = NULL, secret = NULL, session_token = NULL, service = c("comprehend", "comprehendmedical"), ... )
comprehendHTTP( action, query = list(), headers = list(), body = NULL, verbose = getOption("verbose", FALSE), region = Sys.getenv("AWS_DEFAULT_REGION", "us-east-1"), key = NULL, secret = NULL, session_token = NULL, service = c("comprehend", "comprehendmedical"), ... )
action |
A character string specifying the API action to take |
query |
An optional named list containing query string parameters and their character values. |
headers |
A list of headers to pass to the HTTP request. |
body |
A request body |
verbose |
A logical indicating whether to be verbose. Default is given by |
region |
A character string containing the AWS region. If missing, defaults to “us-east-1”. |
key |
A character string containing an AWS Access Key ID. See |
secret |
A character string containing an AWS Secret Access Key. See |
session_token |
A character string containing an AWS Session Token. See |
service |
the Comprehend service to use. Currently either 'comprehend' for the base service or 'comprehendmedical' for the Comprehend Medical service. |
... |
Additional arguments passed to |
This function constructs and signs an Polly API request and returns the results thereof, or relevant debugging information in the case of error.
If successful, a named list. Otherwise, a data structure of class “aws-error” containing any error message(s) from AWS and information about the request attempt.
Thomas J. Leeper
Detect entities in a source text
detect_entities(text, language = "en", ...)
detect_entities(text, language = "en", ...)
text |
A character string containing a text to entities analyze, or a character vector to perform analysis separately for each element. |
language |
A character string containing a two-letter language code. Currently “en” and “es” are supported. |
... |
Additional arguments passed to |
A data frame
## Not run: # simple example detect_entities("Amazon provides web services. Jeff is their leader.") txt <-c("Amazon provides web services, like Google.", "Jeff is their leader.") detect_entities(txt) ## End(Not run)
## Not run: # simple example detect_entities("Amazon provides web services. Jeff is their leader.") txt <-c("Amazon provides web services, like Google.", "Jeff is their leader.") detect_entities(txt) ## End(Not run)
Detect language(s) in a source text
detect_language(text, ...)
detect_language(text, ...)
text |
A character string containing a textual source, or a character vector to detect languages separately for each element. |
... |
Additional arguments passed to |
A data frame of language probabilities.
## Not run: # simple example detect_language("This is a test sentence in English") # two languages in a single text txt <- "A: ¡Hola! ¿Como está, usted?\nB: Ça va bien. Merci. Et toi?" detect_language(txt) # "batch" mode detect_language(c("A: ¡Hola! ¿Como está, usted?", "B: Ça va bien. Merci. Et toi?")) ## End(Not run)
## Not run: # simple example detect_language("This is a test sentence in English") # two languages in a single text txt <- "A: ¡Hola! ¿Como está, usted?\nB: Ça va bien. Merci. Et toi?" detect_language(txt) # "batch" mode detect_language(c("A: ¡Hola! ¿Como está, usted?", "B: Ça va bien. Merci. Et toi?")) ## End(Not run)
Detect entities in a source medical text
detect_medical_entities(text, language = "en", version = c("2", "1"), ...)
detect_medical_entities(text, language = "en", version = c("2", "1"), ...)
text |
A character string containing a text to entities analyze, or a character vector to perform analysis separately for each element. |
language |
A character string containing a two-letter language code. Currently only “en” is supported. |
version |
A character string containing the version of the API that should be used. Currently only "1" or "2" are supported. |
... |
Additional arguments passed to |
A data frame
## Not run: # simple example medical_detect_entities("Mrs. Smith comes in today complaining of shortness of breath.") txt <-c("Mrs. Smith comes in today.", "She is complaining of shortnesss of breath.") medical_detect_entities(txt) ## End(Not run)
## Not run: # simple example medical_detect_entities("Mrs. Smith comes in today complaining of shortness of breath.") txt <-c("Mrs. Smith comes in today.", "She is complaining of shortnesss of breath.") medical_detect_entities(txt) ## End(Not run)
Detect Protected Health Information (PHI) in a source medical text
detect_medical_phi(text, language = "en", ...)
detect_medical_phi(text, language = "en", ...)
text |
A character string containing a text to entities analyze, or a character vector to perform analysis separately for each element. |
language |
A character string containing a two-letter language code. Currently only “en” is supported. |
... |
Additional arguments passed to |
A data frame
## Not run: # simple example medical_detect_phi("Mrs. Smith comes in today complaining of shortness of breath.") txt <-c("Mrs. Smith comes in today.", "She is complaining of shortnesss of breath.") medical_detect_phi(txt) ## End(Not run)
## Not run: # simple example medical_detect_phi("Mrs. Smith comes in today complaining of shortness of breath.") txt <-c("Mrs. Smith comes in today.", "She is complaining of shortnesss of breath.") medical_detect_phi(txt) ## End(Not run)
Detect key phrases in a source text
detect_phrases(text, language = "en", ...)
detect_phrases(text, language = "en", ...)
text |
A character string containing a text to analyze, or a character vector to perform analysis separately for each element. |
language |
A character string containing a two-letter language code. Currently “en” and “es” are supported. |
... |
Additional arguments passed to |
A data frame
## Not run: # simple example detect_phrases("Amazon provides web services. Jeff is their leader.") txt <-c("Amazon provides web services.", "Jeff is their leader.") detect_phrases(txt) ## End(Not run)
## Not run: # simple example detect_phrases("Amazon provides web services. Jeff is their leader.") txt <-c("Amazon provides web services.", "Jeff is their leader.") detect_phrases(txt) ## End(Not run)
Detect sentiment in a source text
detect_sentiment(text, language = "en", ...)
detect_sentiment(text, language = "en", ...)
text |
A character string containing a text to sentiment analyze, or a character vector to perform analysis separately for each element. |
language |
A character string containing a two-letter language code. Currently “en” and “es” are supported. |
... |
Additional arguments passed to |
A data frame
## Not run: # simple example detect_sentiment("I have never been happier. This is the best day ever.") txt <-c("I have never been happier. This is the best day ever.", "I have always been happier. This is the worst day ever.") detect_sentiment(txt) ## End(Not run)
## Not run: # simple example detect_sentiment("I have never been happier. This is the best day ever.") txt <-c("I have never been happier. This is the best day ever.", "I have always been happier. This is the worst day ever.") detect_sentiment(txt) ## End(Not run)
Detect syntax in a source text
detect_syntax(text, language = "en", ...)
detect_syntax(text, language = "en", ...)
text |
A character string containing a text to syntax analyze, or a character vector to perform analysis separately for each element. |
language |
A character string containing a two-letter language code. |
... |
Additional arguments passed to |
A data frame
## Not run: # simple example detect_syntax("The quick brown fox jumps over the lazy dog.") txt <-c("The quick brown fox jumps over the lazy dog.", "I have never been happier!") detect_syntax(txt) ## End(Not run)
## Not run: # simple example detect_syntax("The quick brown fox jumps over the lazy dog.") txt <-c("The quick brown fox jumps over the lazy dog.", "I have never been happier!") detect_syntax(txt) ## End(Not run)
Flatten embedded data.frames (1 level max)
flatten(df)
flatten(df)
df |
data.frame to flatten |