Git Product home page Git Product logo

parseids's Introduction

parseids

Build Status

Parsers for Digital Object Identifiers (DOIs) and Other Identifiers

Uses the R pkg piton which gives access to the C++ PEG implementation PEGTL.

Documentation for various identifiers

DOI

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

  • pid_dois
  • pid_dois_prefixes
  • pid_dois_split
  • pid_dois_suffixes

Install

devtools::install_github("ropenscilabs/parseids")
library("parseids")

pull out DOIs from text strings

pid_dois("Foo 10.1094/PHYTO-04-17-0144-R")
#> [1] "10.1094/PHYTO-04-17-0144-R"
pid_dois(c("Foo 10.1094/PHYTO-04-17-0144-R", "adsfljadfa dflj fjas fljasf 10.1094/PHYTO-04-17-0144-R"))
#> [1] "10.1094/PHYTO-04-17-0144-R" "10.1094/PHYTO-04-17-0144-R"

DOI prefixes

pid_dois_prefixes(c("10.1094/PHYTO-04-17-0144-R", "10.5150/cmcm.2011.086"))
#> [1] "10.1094" "10.5150"

DOI suffixes

pid_dois_suffixes(c("10.1094/PHYTO-04-17-0144-R", "10.5150/cmcm.2011.086"))
#> [1] "PHYTO-04-17-0144-R" "cmcm.2011.086"

timing

dois_long <- unlist(replicate(100, dois, simplify = FALSE), TRUE)
length(dois_long)
#> [1] 100000
library(microbenchmark)
microbenchmark::microbenchmark(
  pid_dois = pid_dois(dois_long),
  prefixes = pid_dois_prefixes(dois_long),
  suffixes = pid_dois_suffixes(dois_long),
  times = 100
)
#> Unit: milliseconds
#>      expr      min        lq      mean    median        uq      max neval
#>  pid_dois 356.9053 367.39554 378.38806 373.42769 383.85699 463.5051   100
#>  prefixes  85.5466  86.98456  91.13909  88.44211  92.90492 137.7983   100
#>  suffixes 157.2990 162.26911 170.07435 167.44599 172.70201 217.5943   100

Meta

  • Please report any issues or bugs.
  • License: MIT
  • Get citation information for parseids: citation(package = 'parseids')
  • Please note that this project is released with a Contributor Code of Conduct. By participating in this project you agree to abide by its terms.

rofooter

parseids's People

Contributors

sckott avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar

parseids's Issues

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.