Skip to content

Commit 5f0a30b

Browse files
committed
update
1 parent aae4b66 commit 5f0a30b

File tree

11 files changed

+1082
-6524
lines changed

11 files changed

+1082
-6524
lines changed

DESCRIPTION

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
Package: lingglosses
22
Type: Package
33
Title: Interlinear Glossed Linguistic Examples and Abbreviation Lists Generation
4-
Version: 0.0.9
4+
Version: 0.0.7
55
Depends: R (>= 3.5.0)
66
Authors@R: person("George", "Moroz",
77
role = c("aut", "cre"),
@@ -18,7 +18,7 @@ Encoding: UTF-8
1818
LazyData: true
1919
URL: https://CRAN.R-project.org/package=phonfieldwork, https://agricolamz.github.io/lingglosses/
2020
BugReports: https://github.com/agricolamz/lingglosses/issues
21-
Imports: gt, knitr, rmarkdown, utils, htmltools, methods
22-
RoxygenNote: 7.3.2.9000
21+
Imports: kableExtra, knitr, rmarkdown, utils, htmltools, methods
22+
RoxygenNote: 7.2.3
2323
Suggests: testthat (>= 3.0.0)
2424
Config/testthat/edition: 3

NAMESPACE

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,22 +5,17 @@ export(convert_to_df)
55
export(get_examples_db)
66
export(gloss_example)
77
export(make_gloss_list)
8-
importFrom(gt,as_word)
9-
importFrom(gt,fmt_markdown)
10-
importFrom(gt,gt)
11-
importFrom(gt,md)
12-
importFrom(gt,opt_table_lines)
13-
importFrom(gt,tab_footnote)
14-
importFrom(gt,tab_options)
158
importFrom(htmltools,a)
169
importFrom(htmltools,tagList)
1710
importFrom(htmltools,tags)
11+
importFrom(kableExtra,footnote)
12+
importFrom(kableExtra,kable_minimal)
13+
importFrom(kableExtra,kbl)
1814
importFrom(knitr,asis_output)
1915
importFrom(knitr,is_html_output)
2016
importFrom(knitr,is_latex_output)
2117
importFrom(knitr,knit_hooks)
2218
importFrom(knitr,opts_current)
23-
importFrom(knitr,opts_knit)
2419
importFrom(methods,hasArg)
2520
importFrom(methods,missingArg)
2621
importFrom(rmarkdown,metadata)

NEWS.md

Lines changed: 2 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,13 @@
1-
# lingglosses 0.0.9
2-
3-
- move from `kableExtra` to `gt` package
4-
5-
# lingglosses 0.0.8
6-
7-
- add 2PL gloss
8-
91
# lingglosses 0.0.7
102

113
- fix by @yihui
124

5+
136
# lingglosses 0.0.6
147

158
- small fix for CRAN
169

10+
1711
# lingglosses 0.0.5
1812

1913
- add possibility to have a sole transliteration line; thx to @sverhees #19

R/gloss_example.R

Lines changed: 52 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -36,14 +36,9 @@
3636
#'
3737
#' @importFrom knitr is_latex_output
3838
#' @importFrom knitr is_html_output
39-
#' @importFrom knitr opts_knit
40-
#' @importFrom gt gt
41-
#' @importFrom gt tab_footnote
42-
#' @importFrom gt tab_options
43-
#' @importFrom gt fmt_markdown
44-
#' @importFrom gt md
45-
#' @importFrom gt as_word
46-
#' @importFrom gt opt_table_lines
39+
#' @importFrom kableExtra kable_minimal
40+
#' @importFrom kableExtra kbl
41+
#' @importFrom kableExtra footnote
4742
#' @importFrom methods missingArg
4843
#' @importFrom methods hasArg
4944
#' @export
@@ -256,40 +251,35 @@ gloss_example <- function(transliteration,
256251
}
257252
}
258253

259-
result |>
260-
as.data.frame() |>
261-
gt::gt() |>
262-
gt::tab_options(column_labels.hidden = TRUE,
263-
table.align = "left") |>
264-
gt::opt_table_lines(extent = "none") |>
265-
gt::fmt_markdown() ->
266-
result
254+
if (isTRUE(knitr::opts_knit$get('rmarkdown.pandoc.to') != "docx")) {
255+
256+
result <- kableExtra::kbl(result, align = "l", centering = FALSE,
257+
escape = FALSE, vline = "")
258+
result <- kableExtra::kable_minimal(result,
259+
position = "left",
260+
full_width = FALSE)
261+
267262

268263
# add video ---------------------------------------------------------------
269264
if(!is.null(video_path) & knitr::is_html_output()){
270265
if(length(video_path) > 1){
271266
stop("video_path argument should be of the length 1")
272267
}
273-
result <- gt::tab_footnote(data = result,
274-
footnote = as.character(
268+
result <- kableExtra::footnote(kable_input = result,
269+
general = as.character(
275270
add_video(video_path,
276271
video_width,
277-
video_height)))
278-
}
279-
280-
# add free translation -----------------------------------------------------
281-
if(nchar(free_translation) > 0){
282-
result <- gt::tab_footnote(data = result,
283-
footnote = paste0("'",
284-
gt::md(free_translation),
285-
"'"))
272+
video_height)),
273+
general_title = "",
274+
escape = FALSE)
286275
}
287276

288277

289278
# add comment --------------------------------------------------------------
290279
if(nchar(comment) > 0){
291-
result <- gt::tab_footnote(data = result,
292-
footnote = gt::md(comment))
280+
result <- kableExtra::footnote(kable_input = result,
281+
general = comment,
282+
general_title = "")
293283
}
294284

295285
# add audio ---------------------------------------------------------------
@@ -307,6 +297,15 @@ gloss_example <- function(transliteration,
307297
} else {
308298
add_to_translation <- "'"
309299
}
300+
# add free translation -----------------------------------------------------
301+
if(nchar(free_translation) > 0){
302+
result <- kableExtra::footnote(kable_input = result,
303+
general = paste0("'",
304+
free_translation,
305+
add_to_translation),
306+
general_title = "",
307+
escape = FALSE)
308+
}
310309

311310
# remove lines from LaTeX --------------------------------------------------
312311
if(knitr::is_latex_output()){
@@ -315,6 +314,28 @@ gloss_example <- function(transliteration,
315314
result <- gsub("\\\\bottomrule", "", result)
316315
result <- gsub("\\\\hline", "", result)
317316
}
317+
318+
} else {
319+
result |>
320+
as.data.frame() |>
321+
gt::gt() |>
322+
gt::tab_options(column_labels.hidden = TRUE,
323+
table.align = "left") |>
324+
gt::opt_table_lines(extent = "none") |>
325+
gt::fmt_markdown() ->
326+
result
327+
328+
if(nchar(free_translation) > 0){
329+
result <- gt::tab_footnote(data = result,
330+
footnote = paste0("'",
331+
gt::md(free_translation),
332+
"'"))
333+
}
334+
if(nchar(comment) > 0){
335+
result <- gt::tab_footnote(data = result,
336+
footnote = gt::md(comment))
337+
}
338+
}
318339
}
319340
}
320341

@@ -328,9 +349,9 @@ gloss_example <- function(transliteration,
328349
sep = "\n")
329350
}
330351
} else {
331-
for(i in multiline_result) {print(i)}
352+
cat(unlist(multiline_result))
332353
}
333-
} else{
354+
} else {
334355
return(result)
335356
}
336357
}

R/glosses_df.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
#' Comrie, Haspelmath, and Bickel and other glosses automatically gathered from
55
#' Glossa Journal articles.
66
#'
7-
#' @format A data frame with 1342 rows and 4 variables:
7+
#' @format A data frame with 1341 rows and 4 variables:
88
#' \describe{
99
#' \item{gloss}{the gloss abbreviation}
1010
#' \item{definition_en}{the gloss definition}

codemeta.json

Lines changed: 6 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -8,13 +8,13 @@
88
"codeRepository": "https://CRAN.R-project.org/package=phonfieldwork",
99
"issueTracker": "https://github.com/agricolamz/lingglosses/issues",
1010
"license": "https://spdx.org/licenses/GPL-3.0",
11-
"version": "0.0.9",
11+
"version": "0.0.4",
1212
"programmingLanguage": {
1313
"@type": "ComputerLanguage",
1414
"name": "R",
1515
"url": "https://r-project.org"
1616
},
17-
"runtimePlatform": "R version 4.3.3 (2024-02-29)",
17+
"runtimePlatform": "R version 4.2.0 (2022-04-22)",
1818
"provider": {
1919
"@id": "https://cran.r-project.org",
2020
"@type": "Organization",
@@ -63,15 +63,15 @@
6363
},
6464
"2": {
6565
"@type": "SoftwareApplication",
66-
"identifier": "gt",
67-
"name": "gt",
66+
"identifier": "kableExtra",
67+
"name": "kableExtra",
6868
"provider": {
6969
"@id": "https://cran.r-project.org",
7070
"@type": "Organization",
7171
"name": "Comprehensive R Archive Network (CRAN)",
7272
"url": "https://cran.r-project.org"
7373
},
74-
"sameAs": "https://CRAN.R-project.org/package=gt"
74+
"sameAs": "https://CRAN.R-project.org/package=kableExtra"
7575
},
7676
"3": {
7777
"@type": "SoftwareApplication",
@@ -102,26 +102,9 @@
102102
"identifier": "utils",
103103
"name": "utils"
104104
},
105-
"6": {
106-
"@type": "SoftwareApplication",
107-
"identifier": "htmltools",
108-
"name": "htmltools",
109-
"provider": {
110-
"@id": "https://cran.r-project.org",
111-
"@type": "Organization",
112-
"name": "Comprehensive R Archive Network (CRAN)",
113-
"url": "https://cran.r-project.org"
114-
},
115-
"sameAs": "https://CRAN.R-project.org/package=htmltools"
116-
},
117-
"7": {
118-
"@type": "SoftwareApplication",
119-
"identifier": "methods",
120-
"name": "methods"
121-
},
122105
"SystemRequirements": null
123106
},
124-
"fileSize": "59.745KB",
107+
"fileSize": "53.058KB",
125108
"citation": [
126109
{
127110
"@type": "SoftwareSourceCode",

data/glosses_df.RData

-52 Bytes
Binary file not shown.

database_creation/glossa.R

Lines changed: 4 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -118,15 +118,10 @@ for_analysis %>%
118118
# save file as rds ---------------------------------------------------------
119119
glosses_df <- read.csv("database_creation/glosses_extracted.csv")
120120

121-
library(tidyverse)
122-
glosses_df |>
123-
bind_rows(tibble(gloss = "2PL",
124-
definition_en = "second person plural",
125-
source = "lingglosses",
126-
weight = 1)) |>
127-
arrange(gloss) ->
128-
glosses_df
121+
glosses_df %>%
122+
count(gloss, weight, sort = TRUE) %>%
123+
pivot_wider(names_from = weight, values_from = n) %>%
124+
View()
129125

130126
save(glosses_df, file="data/glosses_df.RData", compress='xz')
131127

132-

docs/index.Rmd

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,8 @@ The first line corresponds to pictures in markdown format that should be located
318318

319319
After you finished your text, it is possible to call the `make_gloss_list()` function in order to automatically create a list of abbreviations.
320320

321+
322+
321323
```{r}
322324
make_gloss_list()
323325
```

0 commit comments

Comments
 (0)