Skip to content

Commit 1ae0303

Browse files
committed
Export speakers count table
1 parent 6c0b700 commit 1ae0303

File tree

6 files changed

+64
-11
lines changed

6 files changed

+64
-11
lines changed

NAMESPACE

+1
Original file line numberDiff line numberDiff line change
@@ -2,4 +2,5 @@
22

33
export(franc)
44
export(franc_all)
5+
export(speakers)
56
importFrom(jsonlite,fromJSON)

R/franc.R

+6-4
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ und <- function() lang("und")
5656
#' default), to make the detection reasonably fast.
5757
#' @param min_speakers Languages with at least this many speakers are
5858
#' checked. By default this is one million. Set it to zero to
59-
#' include all languages known by franc.
59+
#' include all languages known by franc. See also \code{\link{speakers}}.
6060
#' @param whitelist List of three letter language codes to check against.
6161
#' @param blacklist List of three letter language codes not to check
6262
#' againts.
@@ -68,7 +68,8 @@ und <- function() lang("und")
6868
#' language codes. The \code{score} column contains the scores.
6969
#'
7070
#' @encoding utf8
71-
#' @seealso \code{\link{franc}} if you only want the top result.
71+
#' @seealso \code{\link{franc}} if you only want the top result,
72+
#' \code{\link{speakers}}.
7273
#' @export
7374
#' @examples
7475
#' head(franc_all("O Brasil caiu 26 posições em"))
@@ -125,7 +126,7 @@ franc_all <- function(text, min_speakers = 1000000, whitelist = NULL,
125126
#' default), to make the detection reasonably fast.
126127
#' @param min_speakers Languages with at least this many speakers are
127128
#' checked. By default this is one million. Set it to zero to
128-
#' include all languages known by franc.
129+
#' include all languages known by franc. See also \code{\link{speakers}}.
129130
#' @param whitelist List of three letter language codes to check against.
130131
#' @param blacklist List of three letter language codes not to check
131132
#' againts.
@@ -136,7 +137,8 @@ franc_all <- function(text, min_speakers = 1000000, whitelist = NULL,
136137
#' language of the text. \code{"und"} is returned for too short input.
137138
#'
138139
#' @encoding utf8
139-
#' @seealso \code{\link{franc_all}} for scores against many languages.
140+
#' @seealso \code{\link{franc_all}} for scores against many languages,
141+
#' \code{\link{speakers}}.
140142
#' @export
141143
#' @examples
142144
#' ## afr

R/speakers.R

+24-3
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,29 @@
11

2-
#' @importFrom jsonlite fromJSON
3-
42
speakers_file <- system.file("speakers.json", package = packageName())
53

4+
#' Number of speakers for 370 languages
5+
#'
6+
#' This is a superset of all languages detected by franc. Numbers were
7+
#' collected by Titus Wormer. To quote him: \emph{Painstakingly crawled by
8+
#' hand from OHCHR, the numbers are (in some cases, very) rough estimates
9+
#' or out-of-date.}.
10+
#'
11+
#' @format
12+
#' A data frame with columns:
13+
#' \describe{
14+
#' \item{language}{Three letter language code.}
15+
#' \item{speakers}{Number of speakers.}
16+
#' \item{name}{Full name of language.}
17+
#' \item{iso6391}{ISO 639-1 codes. See more at
18+
#' \url{http://en.wikipedia.org/wiki/ISO_639}.}
19+
#' \item{iso6392}{ISO 639-2T codes. See more at
20+
#' \url{http://en.wikipedia.org/wiki/ISO_639}.}
21+
#' }
22+
#'
23+
#' @docType data
24+
#' @importFrom jsonlite fromJSON
25+
#' @export
26+
627
speakers <- jsonlite::fromJSON(speakers_file, simplifyVector = FALSE)
728

829
for (i in seq_along(speakers)) {
@@ -14,7 +35,7 @@ speakers <- data.frame(
1435
stringsAsFactors = FALSE,
1536
row.names = NULL,
1637
language = names(speakers),
17-
speakers = vapply(speakers, "[[", 1, "speakers"),
38+
speakers = as.integer(vapply(speakers, "[[", 1, "speakers")),
1839
name = vapply(speakers, "[[", "", "name"),
1940
iso6391 = vapply(speakers, "[[", "", "iso6391"),
2041
iso6392 = vapply(speakers, "[[", "", "iso6392")

man/franc.Rd

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/franc_all.Rd

+3-2
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

man/speakers.Rd

+27
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)