-
Notifications
You must be signed in to change notification settings - Fork 0
/
README.Rmd
124 lines (85 loc) · 2.42 KB
/
README.Rmd
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
parseids
========
```{r echo=FALSE}
knitr::opts_chunk$set(
comment = "#>",
collapse = TRUE,
warning = FALSE
)
```
[![Build Status](https://travis-ci.org/ropenscilabs/parseids.svg?branch=master)](https://travis-ci.org/ropenscilabs/parseids)
Parsers for Digital Object Identifiers (DOIs) and Other Identifiers
Uses the R pkg [piton](https://github.com/Ironholds/piton) which gives access to the C++ PEG implementation [PEGTL](https://github.com/taocpp/PEGTL).
## Documentation for various identifiers
### DOI
* <https://en.wikipedia.org/wiki/Digital_object_identifier>
* <https://www.doi.org/overview/DOI_article_ELIS3.pdf>
## Example rules
Capture any letter
```
struct name
: plus< alpha >
{};
```
Capture any digit
```
struct numbers
: plus< digit >
{};
```
## Grammar
Rules are combined to form a grammar,
e.g., string must match `name`, then have one comma, then one space,
then match `numbers`.
```
struct grammar
: must< name, one< ',' >, space, numbers, eof >
{};
```
Which is then applied to parsing user input strings
## parseids API
```{r echo=FALSE, results='asis'}
cat(paste(" -", paste(getNamespaceExports("parseids"), collapse = "\n - ")))
```
## Install
```{r eval=FALSE}
devtools::install_github("ropenscilabs/parseids")
```
```{r}
library("parseids")
```
## pull out DOIs from text strings
```{r}
pid_dois("Foo 10.1094/PHYTO-04-17-0144-R")
```
```{r}
pid_dois(c("Foo 10.1094/PHYTO-04-17-0144-R", "adsfljadfa dflj fjas fljasf 10.1094/PHYTO-04-17-0144-R"))
```
## DOI prefixes
```{r}
pid_dois_prefixes(c("10.1094/PHYTO-04-17-0144-R", "10.5150/cmcm.2011.086"))
```
## DOI suffixes
```{r}
pid_dois_suffixes(c("10.1094/PHYTO-04-17-0144-R", "10.5150/cmcm.2011.086"))
```
## timing
```{r}
dois_long <- unlist(replicate(100, dois, simplify = FALSE), TRUE)
length(dois_long)
```
```{r}
library(microbenchmark)
microbenchmark::microbenchmark(
pid_dois = pid_dois(dois_long),
prefixes = pid_dois_prefixes(dois_long),
suffixes = pid_dois_suffixes(dois_long),
times = 10
)
```
## Meta
* Please [report any issues or bugs](https://github.com/ropenscilabs/parseids/issues).
* License: MIT
* Get citation information for `parseids`: `citation(package = 'parseids')`
* Please note that this project is released with a [Contributor Code of Conduct](CONDUCT.md). By participating in this project you agree to abide by its terms.
[![rofooter](https://ropensci.org/public_images/github_footer.png)](https://ropensci.org)