diff --git a/R/natural-language.R b/R/natural-language.R
index a390921..6965fcb 100644
--- a/R/natural-language.R
+++ b/R/natural-language.R
@@ -25,7 +25,7 @@
#' \item{tokens - }{\href{https://cloud.google.com/natural-language/docs/reference/rest/v1/Token}{Tokens, along with their syntactic information, in the input document}}
#' \item{entities - }{\href{https://cloud.google.com/natural-language/docs/reference/rest/v1/Entity}{Entities, along with their semantic information, in the input document}}
#' \item{documentSentiment - }{\href{https://cloud.google.com/natural-language/docs/reference/rest/v1/Sentiment}{The overall sentiment for the document}}
-#' \item{classifyText -}{\href{https://cloud.google.com/natural-language/docs/classifying-text}}
+#' \item{classifyText -}{\href{https://cloud.google.com/natural-language/docs/classifying-text}{Classification of the document}}
#' \item{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}
#' \item{text - }{The original text passed into the API. \code{NA} if not passed due to being zero-length etc. }
#' }
diff --git a/README.Rmd b/README.Rmd
index 824718f..59dd27f 100644
--- a/README.Rmd
+++ b/README.Rmd
@@ -110,7 +110,7 @@ The Natural Language API returns natural language understanding technolgies. Yo
You can pass a vector of text which will call the API for each element. The return is a list of responses, each response being a list of tibbles holding the different types of analysis.
-```{r}
+```r
texts <- c("to administer medicince to animals is frequently a very difficult matter, and yet sometimes it's necessary to do so",
"I don't know how to make a text demo that is sensible")
nlp_result <- gl_nlp(texts)
@@ -127,7 +127,7 @@ You can detect the language via `gl_translate_detect`, or translate and detect l
Note this is a lot more refined than the free version on Google's translation website.
-```{r}
+```r
text <- "to administer medicine to animals is frequently a very difficult matter, and yet sometimes it's necessary to do so"
## translate British into Danish
gl_translate(text, target = "da")$translatedText
@@ -145,7 +145,7 @@ A test audio file is installed with the package which reads:
The file is sourced from the [University of Southampton's speech detection](http://www-mobile.ecs.soton.ac.uk/newcomms/) group and is fairly difficult for computers to parse, as we see below:
-```{r}
+```r
## get the sample source file
test_audio <- system.file("woman1_wb.wav", package = "googleLanguageR")
@@ -165,7 +165,7 @@ A test audio file is installed with the package which reads:
The file is sourced from the [University of Southampton's speech detection](http://www-mobile.ecs.soton.ac.uk/newcomms/) group and is fairly difficult for computers to parse, as we see below:
-``` r
+```r
## get the sample source file
test_audio <- system.file("woman1_wb.wav", package = "googleLanguageR")
diff --git a/docs/CONTRIBUTING.html b/docs/CONTRIBUTING.html
index 77b767b..3f3989d 100644
--- a/docs/CONTRIBUTING.html
+++ b/docs/CONTRIBUTING.html
@@ -21,13 +21,19 @@
+
+
+
-
+
+
+
+
@@ -37,20 +43,16 @@
-
+
+
-
-
The Natural Language API returns natural language understanding technologies. You can call them individually, or the default is to return them all. The available returns are:
-Entity analysis - Finds named entities (currently proper names and common nouns) in the text along with entity types, salience, mentions for each entity, and other properties. If possible, will also return metadata about that entity such as a Wikipedia URL. If using the v1beta2 endpoint this also includes sentiment for each entity.
+Entity analysis - Finds named entities (currently proper names and common nouns) in the text along with entity types, salience, mentions for each entity, and other properties. If possible, will also return metadata about that entity such as a Wikipedia URL.
Syntax - Analyzes the syntax of the text and provides sentence boundaries and tokenization along with part of speech tags, dependency trees, and other properties.
Sentiment - The overall sentiment of the text, represented by a magnitude [0, +inf] and score between -1.0 (negative sentiment) and 1.0 (positive sentiment).
+
+Content Classification - Analyzes a document and returns a list of content categories that apply to the text found in the document. A complete list of content categories can be found here.
@@ -151,82 +157,109 @@
You can pass a vector of text which will call the API for each element. The return is a list of responses, each response being a list of tibbles holding the different types of analysis.
library(googleLanguageR)
-texts <-c("to administer medicince to animals is frequently a very difficult matter,
- and yet sometimes it's necessary to do so",
- "I don't know how to make a text demo that is sensible")
+# random text form wikipedia
+texts <-c("Norma is a small constellation in the Southern Celestial Hemisphere between Ara and Lupus, one of twelve drawn up in the 18th century by French astronomer Nicolas Louis de Lacaille and one of several depicting scientific instruments. Its name refers to a right angle in Latin, and is variously considered to represent a rule, a carpenter's square, a set square or a level. It remains one of the 88 modern constellations. Four of Norma's brighter stars make up a square in the field of faint stars. Gamma2 Normae is the brightest star with an apparent magnitude of 4.0. Mu Normae is one of the most luminous stars known, but is partially obscured by distance and cosmic dust. Four star systems are known to harbour planets. ",
+ "Solomon Wariso (born 11 November 1966 in Portsmouth) is a retired English sprinter who competed primarily in the 200 and 400 metres.[1] He represented his country at two outdoor and three indoor World Championships and is the British record holder in the indoor 4 × 400 metres relay.")
nlp_result <-gl_nlp(texts)
Each text has its own entry in returned tibbles
str(nlp_result, max.level =2)
-#List of 6
-# $ sentences :List of 2
-# ..$ :'data.frame': 1 obs. of 4 variables:
-# ..$ :'data.frame': 1 obs. of 4 variables:
-# $ tokens :List of 2
-# ..$ :'data.frame': 21 obs. of 17 variables:
-# ..$ :'data.frame': 13 obs. of 17 variables:
-# $ entities :List of 2
-# ..$ :Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 3 obs. of 9 variables:
-# ..$ :Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 1 obs. of 9 variables:
-# $ language : chr [1:2] "en" "en"
-# $ text : chr [1:2] "to administer medicince to animals is frequently a very difficult matter,\n # and yet sometimes it's necessary to do so" "I don't know how to make a text demo that is sensible"
-# $ documentSentiment:Classes ‘tbl_df’, ‘tbl’ and 'data.frame': 2 obs. of 2 variables:
-# ..$ magnitude: num [1:2] 0.5 0.3
-# ..$ score : num [1:2] 0.5 -0.3
+List of 7
+ $sentences :List of 2
+ ..$:'data.frame':7 obs. of 4 variables:
+..$:'data.frame':1 obs. of 4 variables:
+$tokens :List of 2
+ ..$:'data.frame':139 obs. of 17 variables:
+..$:'data.frame':54 obs. of 17 variables:
+$entities :List of 2
+ ..$:Classes ‘tbl_df’, ‘tbl’ and 'data.frame':52 obs. of 9 variables:
+..$:Classes ‘tbl_df’, ‘tbl’ and 'data.frame':8 obs. of 9 variables:
+$language :chr [1:2] "en""en"
+ $text :chr [1:2] "Norma is a small constellation in the Southern Celestial Hemisphere between Ara and Lupus, one of twelve drawn "|__truncated__ "Solomon Wariso (born 11 November 1966 in Portsmouth) is a retired English sprinter who competed primarily in th"|__truncated__
+ $documentSentiment:Classes ‘tbl_df’, ‘tbl’ and 'data.frame':2 obs. of 2 variables:
+..$magnitude:num [1:2] 2.40.1
+ ..$score :num [1:2] 0.30.1
+ $classifyText :Classes ‘tbl_df’, ‘tbl’ and 'data.frame':1 obs. of 2 variables:
+..$name :chr "/Science/Astronomy"
+ ..$confidence:num 0.93
Sentence structure and sentiment:
## sentences structure
nlp_result$sentences[[2]]
-# content beginOffset magnitude score
-#1 I don't know how to make a text demo that is sensible 0 0.3 -0.3
+
+content
+1 Solomon Wariso (born 11 November 1966in Portsmouth) is a retired English sprinter who competed primarily in the 200 and 400 metres.[1] He represented his country at two outdoor and three indoor World Championships and is the British record holder in the indoor 4 × 400 metres relay.
+ beginOffset magnitude score
+100.10.1
Information on what words (tokens) are within each text:
What entities within text have been identified, with optional wikipedia URL if its available.
nlp_result$entities
-#[[1]]
-# A tibble: 3 x 9
-# name type salience mid wikipedia_url magnitude score beginOffset mention_type
-# <chr> <chr> <dbl> <fctr> <fctr> <dbl> <dbl> <int> <chr>
-#1 animals OTHER 0.2449778 <NA> <NA> NA NA 27 COMMON
-#2 matter OTHER 0.2318689 <NA> <NA> NA NA 66 COMMON
-#3 medicince OTHER 0.5231533 <NA> <NA> NA NA 14 COMMON
-
-#[[2]]
-# A tibble: 1 x 9
-# name type salience mid wikipedia_url magnitude score beginOffset mention_type
-# <chr> <chr> <int> <fctr> <fctr> <dbl> <dbl> <int> <chr>
-#1 text demo WORK_OF_ART 1 <NA> <NA> NA NA 27 COMMON
+[[1]]
+# A tibble: 52 x 9
+ name type salience mid wikipedia_url magnitude score beginOffset mention_type
+ <chr><chr><dbl><chr><chr><dbl><dbl><int><chr>
+1 angle OTHER 0.0133NANA00261 COMMON
+ 2 Ara ORGANIZATION 0.0631NANA0076 PROPER
+ 3 astronomer NANANANANANA144 COMMON
+ 4 carpenter PERSON 0.0135NANA00328 COMMON
+ 5 constellation OTHER 0.150NANA0017 COMMON
+ 6 constellations OTHER 0.0140NANA0.90.9405 COMMON
+ 7 distance OTHER 0.00645NANA00649 COMMON
+ 8 dust OTHER 0.00645NANA0.3-0.3669 COMMON
+ 9 field LOCATION 0.00407NANA0.6-0.6476 COMMON
+10 French LOCATION 0.0242NANA00137 PROPER
+# ... with 42 more rows
+
+[[2]]
+# A tibble: 8 x 9
+ name type salience mid wikipedia_url magnitude score beginOffset mention_type
+ <chr><chr><dbl><chr><chr><dbl><dbl><int><chr>
+1 British LOCATION 0.0255NANA00226 PROPER
+2 country LOCATION 0.0475NANA00155 COMMON
+3 English OTHER 0.0530NANA0066 PROPER
+4 Portsmouth LOCATION 0.0530/m/0619_ https://en.wiki… 0041 PROPER
+5 record holder PERSON 0.0541NANA00234 COMMON
+6 Solomon Wariso ORGANIZATION 0.156/g/120x5nf6 https://en.wiki… 000 PROPER
+7 sprinter PERSON 0.600NANA0074 COMMON
+8 World Championships EVENT 0.0113NANA0.10.1195 PROPER
Sentiment of the entire text:
nlp_result$documentSentiment
# A tibble: 2 x 2
magnitude score
<dbl><dbl>
-10.50.5
-20.3-0.3
+12.40.3
+20.10.1
+
The category for the text as defined by the list here.
+
nlp_result$classifyText
+# A tibble: 1 x 2
+ name confidence
+ <chr><dbl>
+1/Science/Astronomy 0.93
The language for the text:
nlp_result$language
# [1] "en" "en"
The original passed in text, to aid with working with the output:
nlp_result$text
-# [1] "to administer medicince to animals is frequently a very difficult matter,\n and yet sometimes it's necessary to do so"
-# [2] "I don't know how to make a text demo that is sensible"
+[1] "Norma is a small constellation in the Southern Celestial Hemisphere between Ara and Lupus, one of twelve drawn up in the 18th century by French astronomer Nicolas Louis de Lacaille and one of several depicting scientific instruments. Its name refers to a right angle in Latin, and is variously considered to represent a rule, a carpenter's square, a set square or a level. It remains one of the 88 modern constellations. Four of Norma's brighter stars make up a square in the field of faint stars. Gamma2 Normae is the brightest star with an apparent magnitude of 4.0. Mu Normae is one of the most luminous stars known, but is partially obscured by distance and cosmic dust. Four star systems are known to harbour planets."
+[2] "Solomon Wariso (born 11 November 1966 in Portsmouth) is a retired English sprinter who competed primarily in the 200 and 400 metres.[1] He represented his country at two outdoor and three indoor World Championships and is the British record holder in the indoor 4 × 400 metres relay."
diff --git a/docs/articles/setup.html b/docs/articles/setup.html
index 0ae7bd7..ff70262 100644
--- a/docs/articles/setup.html
+++ b/docs/articles/setup.html
@@ -8,22 +8,19 @@
Introduction to googleLanguageR • googleLanguageR
-
-
+
+
@@ -110,7 +107,14 @@
-
# two results of lists of tibblesstr(nlp_result, max.level =2)
-
## List of 6
-## $ sentences :List of 2
-## ..$ :'data.frame': 1 obs. of 4 variables:
-## ..$ :'data.frame': 1 obs. of 4 variables:
-## $ tokens :List of 2
-## ..$ :'data.frame': 21 obs. of 17 variables:
-## ..$ :'data.frame': 13 obs. of 17 variables:
-## $ entities :List of 2
-## ..$ :Classes 'tbl_df', 'tbl' and 'data.frame': 3 obs. of 9 variables:
-## ..$ :Classes 'tbl_df', 'tbl' and 'data.frame': 1 obs. of 9 variables:
-## $ language : chr [1:2] "en" "en"
-## $ text : chr [1:2] "to administer medicince to animals is frequently a very difficult matter, and yet sometimes it's necessary to do so" "I don't know how to make a text demo that is sensible"
-## $ documentSentiment:Classes 'tbl_df', 'tbl' and 'data.frame': 2 obs. of 2 variables:
-## ..$ magnitude: num [1:2] 0.5 0.3
-## ..$ score : num [1:2] 0.5 -0.3
text <- "to administer medicine to animals is frequently a very difficult matter, and yet sometimes it's necessary to do so"
## translate British into Danish
gl_translate(text, target ="da")$translatedText
-
## [1] "at administrere medicin til dyr er ofte en meget vanskelig sag, og dog er det undertiden nødvendigt at gøre det"
See more examples and details on the website or via vignette("translate", package = "googleLanguageR")
@@ -293,10 +281,6 @@
## its not perfect but...:)
gl_speech(test_audio)$transcript
-
## # A tibble: 1 x 2
-## transcript confidence
-## <chr> <chr>
-## 1 to administer medicine to animals is frequency of very diffi… 0.918081
test_audio <-system.file("woman1_wb.wav", package ="googleLanguageR")
## its not perfect but...:)
-gl_speech(test_audio)$transcript
-
## # A tibble: 1 x 2
-## transcript confidence
-## <chr> <chr>
-## 1 to administer medicine to animals is frequency of very diffi… 0.9180294
+gl_speech(test_audio)$transcript
+
+
+ ## # A tibble: 1 x 2
+ ## transcript confidence
+ ## <chr> <chr>
+ ## 1 to administer medicine to animals is frequency of very diffi… 0.9180294
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.
The language of the voice as a BCP-47 language code
+
name
Name of the voice, see list via gl_talk_languages for supported voices. Set to NULL to make the service choose a voice based on languageCode and gender.
+
gender
The gender of the voice, if available
+
audioEncoding
Format of the requested audio stream
+
speakingRate
Speaking rate/speed between 0.25 and 4.0
+
pitch
Speaking pitch between -20.0 and 20.0 in semitones.
+
volumeGainDb
Volumne gain in dB
+
sampleRateHertz
Sample rate for returned audio
+
+
+
+
autoplay
+
passed to the HTML audio player - default TRUE plays on load
+
+
+
controls
+
passed to the HTML audio player - default TRUE shows controls
+
+
+
loop
+
passed to the HTML audio player - default FALSE does not loop
Recursively step down into list, removing all such objects
+
rmNullObs(x)
diff --git a/docs/sitemap.xml b/docs/sitemap.xml
index 69f1a4f..8ffe305 100644
--- a/docs/sitemap.xml
+++ b/docs/sitemap.xml
@@ -1,5 +1,8 @@
+
+ https://code.markedmondson.me/googleLanguageR//index.html
+ https://code.markedmondson.me/googleLanguageR//reference/gl_auth.html
@@ -21,6 +24,12 @@
https://code.markedmondson.me/googleLanguageR//reference/gl_talk_player.html
+
+ https://code.markedmondson.me/googleLanguageR//reference/gl_talk_shiny.html
+
+
+ https://code.markedmondson.me/googleLanguageR//reference/gl_talk_shinyUI.html
+ https://code.markedmondson.me/googleLanguageR//reference/gl_translate.html
diff --git a/man/gl_nlp.Rd b/man/gl_nlp.Rd
index f42d4fe..00833a8 100644
--- a/man/gl_nlp.Rd
+++ b/man/gl_nlp.Rd
@@ -29,7 +29,7 @@ A list of the following objects, if those fields are asked for via \code{nlp_typ
\item{tokens - }{\href{https://cloud.google.com/natural-language/docs/reference/rest/v1/Token}{Tokens, along with their syntactic information, in the input document}}
\item{entities - }{\href{https://cloud.google.com/natural-language/docs/reference/rest/v1/Entity}{Entities, along with their semantic information, in the input document}}
\item{documentSentiment - }{\href{https://cloud.google.com/natural-language/docs/reference/rest/v1/Sentiment}{The overall sentiment for the document}}
- \item{classifyText -}{\href{https://cloud.google.com/natural-language/docs/classifying-text}}
+ \item{classifyText -}{\href{https://cloud.google.com/natural-language/docs/classifying-text}{Classification of the document}}
\item{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}
\item{text - }{The original text passed into the API. \code{NA} if not passed due to being zero-length etc. }
}