Skip to content

Commit 3af4d89

Browse files
committed
update rendering to html and docx
1 parent 5f0a30b commit 3af4d89

File tree

11 files changed

+107
-102
lines changed

11 files changed

+107
-102
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.7
4+
Version: 0.0.9
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: kableExtra, knitr, rmarkdown, utils, htmltools, methods
22-
RoxygenNote: 7.2.3
21+
Imports: kableExtra, knitr, gt, rmarkdown, utils, htmltools, methods
22+
RoxygenNote: 7.3.2.9000
2323
Suggests: testthat (>= 3.0.0)
2424
Config/testthat/edition: 3

NAMESPACE

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,13 @@ 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)
815
importFrom(htmltools,a)
916
importFrom(htmltools,tagList)
1017
importFrom(htmltools,tags)

NEWS.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,15 @@
1+
# lingglosses 0.0.9
2+
3+
- add `docx` compatibility
4+
5+
# lingglosses 0.0.8
6+
7+
- add 2PL gloss (thx to @IrinaPolitova)
8+
19
# lingglosses 0.0.7
210

311
- fix by @yihui
412

5-
613
# lingglosses 0.0.6
714

815
- small fix for CRAN

R/gloss_example.R

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,14 @@
3434
#' "I cannot fly.",
3535
#' intext = TRUE)
3636
#'
37+
#'
38+
#' @importFrom gt gt
39+
#' @importFrom gt tab_footnote
40+
#' @importFrom gt tab_options
41+
#' @importFrom gt fmt_markdown
42+
#' @importFrom gt md
43+
#' @importFrom gt as_word
44+
#' @importFrom gt opt_table_lines
3745
#' @importFrom knitr is_latex_output
3846
#' @importFrom knitr is_html_output
3947
#' @importFrom kableExtra kable_minimal

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 1341 rows and 4 variables:
7+
#' @format A data frame with 1342 rows and 4 variables:
88
#' \describe{
99
#' \item{gloss}{the gloss abbreviation}
1010
#' \item{definition_en}{the gloss definition}

data/glosses_df.RData

64 Bytes
Binary file not shown.

database_creation/glossa.R

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,5 +123,12 @@ glosses_df %>%
123123
pivot_wider(names_from = weight, values_from = n) %>%
124124
View()
125125

126+
glosses_df |>
127+
bind_rows(tibble(gloss = "2PL",
128+
definition_en = "second person plural",
129+
source = "Leipzig Glossing Rules",
130+
weight = 1)) ->
131+
glosses_df
132+
126133
save(glosses_df, file="data/glosses_df.RData", compress='xz')
127134

docs/index.Rmd

Lines changed: 43 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -37,13 +37,13 @@ NOM = nominative, GEN = nominative, DAT = nominative, ACC = accusative, VOC = ac
3737

3838
Besides the obvious errors, this list contains more problems that I would like to point out:
3939

40-
* the lack of alphabetic order;
41-
* some abbreviations used in the article (`r add_gloss("SBJV")`, `r add_gloss("IMP")`) are absent in the list.
40+
- the lack of alphabetic order;
41+
- some abbreviations used in the article (`r add_gloss("SBJV")`, `r add_gloss("IMP")`) are absent in the list.
4242

4343
The main goal of the `lingglosses` R package is to provide an option for creating:
4444

45-
* interlinear glossed linguistic glosses for an `.html` output of `rmarkdown` [@xie18][^latex];
46-
* a semi-automatically compiled list of glosses.
45+
- interlinear glossed linguistic glosses for an `.html` output of `rmarkdown` [@xie18][^latex];
46+
- a semi-automatically compiled list of glosses.
4747

4848
[^latex]: If you want to render a `.pdf` version you can either use latex and multiple linguistic packages developed for it (see e. g. [`gb4e`](https://www.ctan.org/pkg/gb4e), [`langsci`](https://www.ctan.org/pkg/langsci), [`expex`](https://www.ctan.org/pkg/expex), [`philex`](https://www.ctan.org/pkg/philex)), or you can render `.html` first and convert it to `.pdf` afterwards.
4949

@@ -74,13 +74,13 @@ You can go through the examples in this tutorial or you can create a lingglosses
7474

7575
The main function of the `lingglosses` package is `gloss_example()`. This package has the following arguments:
7676

77-
* `transliteration`;
78-
* `glosses`;
79-
* `free_translation`;
80-
* `comment`;
81-
* `grammaticality`;
82-
* `annotation`[^orth];
83-
* `line_length`.
77+
- `transliteration`;
78+
- `glosses`;
79+
- `free_translation`;
80+
- `comment`;
81+
- `grammaticality`;
82+
- `annotation`[^orth];
83+
- `line_length`.
8484

8585
[^orth]: I used `annotation` for representing orthography, but it also possible to use this tier for the annotation of words, like here:
8686
```{r, echo=FALSE}
@@ -103,9 +103,9 @@ gloss_example(transliteration = "bur-e-**ri** c'in-ne-sːu-w",
103103

104104
In this first example you can see that:
105105

106-
* the transliteration line is italic by default (if you do not want it, just add the argument `italic_transliteration = FALSE`)[^ital-all];
107-
* you can use standard markdown syntax (e.g. `**a**` for **bold**);
108-
* the free translation line is automatically framed with quotation marks.
106+
- the transliteration line is italic by default (if you do not want it, just add the argument `italic_transliteration = FALSE`)[^ital-all];
107+
- you can use standard markdown syntax (e.g. `**a**` for **bold**);
108+
- the free translation line is automatically framed with quotation marks.
109109

110110
[^ital-all]: Sometimes it is make sense to set this option ones for the whole document using the following code `options("lingglosses.italic_transliteration" = FALSE)`.
111111

@@ -145,8 +145,8 @@ With the names settled you can reference the example (@my_ex) in the text using
145145

146146
So this kind of example referencing can be used with `lingglosses` examples like in (@lingglosses1) and (@lingglosses2). The only important details are:
147147

148-
* change your code chunk argument to `echo = FALSE` (or specify it for all code chunks with the following comand in the begining of the document `knitr::opts_chunk$set(echo = FALSE")`);
149-
* do not put an empty line between the reference line (with `(@...)`) and the code chunk with `lingglosses` code.
148+
- change your code chunk argument to `echo = FALSE` (or specify it for all code chunks with the following comand in the begining of the document `knitr::opts_chunk$set(echo = FALSE")`);
149+
- do not put an empty line between the reference line (with `(@...)`) and the code chunk with `lingglosses` code.
150150

151151
(@lingglosses1)
152152
```{r, echo = FALSE}
@@ -358,17 +358,11 @@ It is really important that one should not treat the results of the `make_gloss_
358358

359359
# Other output formats
360360

361-
Right now there is no direct way of knitting `lingglosses` to `.docx` format. You can knit by adding an argument `always_allow_html: true` to your yaml file, however the result will be not ideal. You can work around this by copying and pasting from the `.html` version:
362-
363-
```{r, echo = FALSE}
364-
knitr::include_graphics("for_word_users.gif")
365-
```
366-
367361
Both kniting to `.pdf` and `.docx` outputs are possible, but there are some known restrictions:
368362

369-
* markdown bold and italic annotations do not work;
370-
* example numbers appear above the example;
371-
* there is no non-breaking space in the list of glosses.
363+
- markdown bold and italic annotations do not work;
364+
- example numbers appear above the example;
365+
- there is no non-breaking space in the list of glosses.
372366

373367
So if you want to avoid these problems, the best solution is to use one of the latex glossing packages listed in the first footnote and the package [`glossaries`](https://www.ctan.org/pkg/glossaries) for automatic compilation of glosses.
374368

@@ -386,22 +380,22 @@ Most definitions are too general on purpose: `r add_gloss("ASC")`, for example,
386380

387381
There have been several alternative to `lingglosses` infrastructure for interlinear glossed examples that might be interesting for the reader:
388382

389-
* multiple packages for glossing in LaTeX:
390-
* [`gb4e`](https://www.ctan.org/pkg/gb4e),
391-
* [`langsci`](https://www.ctan.org/pkg/langsci),
392-
* [`expex`](https://www.ctan.org/pkg/expex),
393-
* [`philex`](https://www.ctan.org/pkg/philex)
394-
* [ODIN project](https://odin.linguistlist.org/) [@lewis10] (looks like this project is not longer active);
395-
* [a Java-script library Leipzig.js](https://bdchauvette.net/leipzig.js/);
396-
* a Python library [`Xigt`](https://github.com/xigt/xigt) [@goodman15];
397-
* [scription format](https://github.com/digitallinguistics/scription) and [scription2dlx Java-script library](https://github.com/digitallinguistics/scription2dlx) [@hieber20];
398-
* a Python library [`pyigt`](https://github.com/cldf/pyigt) [@list21b].
383+
- multiple packages for glossing in LaTeX:
384+
- [`gb4e`](https://www.ctan.org/pkg/gb4e),
385+
- [`langsci`](https://www.ctan.org/pkg/langsci),
386+
- [`expex`](https://www.ctan.org/pkg/expex),
387+
- [`philex`](https://www.ctan.org/pkg/philex)
388+
- [ODIN project](https://odin.linguistlist.org/) [@lewis10] (looks like this project is not longer active);
389+
- [a Java-script library Leipzig.js](https://bdchauvette.net/leipzig.js/);
390+
- a Python library [`Xigt`](https://github.com/xigt/xigt) [@goodman15];
391+
- [scription format](https://github.com/digitallinguistics/scription) and [scription2dlx Java-script library](https://github.com/digitallinguistics/scription2dlx) [@hieber20];
392+
- a Python library [`pyigt`](https://github.com/cldf/pyigt) [@list21b].
399393

400394
Only several of them (`ODIN`, `Xigt`, `scription` and `pyigt`) are attempts towards creating a standard for the databases of interlinear glossed examples. I also wanted to mention paper by [@round20], where authors provided a [script](https://github.com/erichround/LREC_IGT/) for the automated identification and parsing of interlinear glossed text from scanned page images. The motivation for creating cross-linguistic database of interlinear glossed examples is the following:
401395

402-
* Prevent from disappearing of linguistic facts due to the projects fail (for example field notes of the researcher that did not manage to finish his work: article, dictionary, grammar etc.);
403-
* Fight with the publication bias, which cause some linguistic facts left unpublished since they not support a basic idea of author;
404-
* Make linguistic work more reproducible and linguistic facts reusable (cf. with human genome database, biodiversity databases or astronomical catalogues).
396+
- Prevent from disappearing of linguistic facts due to the projects fail (for example field notes of the researcher that did not manage to finish his work: article, dictionary, grammar etc.);
397+
- Fight with the publication bias, which cause some linguistic facts left unpublished since they not support a basic idea of author;
398+
- Make linguistic work more reproducible and linguistic facts reusable (cf. with human genome database, biodiversity databases or astronomical catalogues).
405399

406400
The `lingglosses` package make an attempt for going in this direction and provide an ability to extract examples in table format that can be further transformed into other formats. Each interlinear glossed example could be easily represented as a table using the `convert_to_df()` function.
407401

@@ -415,17 +409,17 @@ convert_to_df(transliteration = "bur-e-**ri** c'in-ne-sːu",
415409

416410
This table lists all the parameters that could be useful for a database, and has the following columns:
417411

418-
* `id` --- unique identifier through the whole table;
419-
* `example_id` --- unique identifier of particular examples;
420-
* `word_id` --- unique identifier of the word in the example (delimited with spaces and other punctuation);
421-
* `morpheme_id` --- unique identifier of the morpheme within the word (delimited with `-` or `=`);
422-
* `transliteration` --- language material;
423-
* `gloss` --- glosses;
424-
* `delimiter` --- delimiters: space, `-` or `=`
425-
* `transliteration_orig` --- original string with transliteration;
426-
* `glosses_orig` --- original string with glosses;
427-
* `free_translation` --- original string with the free translation;
428-
* `comment` --- original string with a comment;
412+
- `id` --- unique identifier through the whole table;
413+
- `example_id` --- unique identifier of particular examples;
414+
- `word_id` --- unique identifier of the word in the example (delimited with spaces and other punctuation);
415+
- `morpheme_id` --- unique identifier of the morpheme within the word (delimited with `-` or `=`);
416+
- `transliteration` --- language material;
417+
- `gloss` --- glosses;
418+
- `delimiter` --- delimiters: space, `-` or `=`
419+
- `transliteration_orig` --- original string with transliteration;
420+
- `glosses_orig` --- original string with glosses;
421+
- `free_translation` --- original string with the free translation;
422+
- `comment` --- original string with a comment;
429423

430424
When you use the `gloss_example()` function, a table of the structure described above is added to the database, so in the end you can extract it by saving the output of the `get_examples_db()` function to the file:
431425

docs/index.html

Lines changed: 28 additions & 47 deletions
Large diffs are not rendered by default.

man/gloss_example.Rd

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)