Skip to content

Repository files navigation

Bibitem Parser

NuGet Badge

The Bibitem parser takes a LaTeX bibitem as input and parses it to a Publication object. The parser has the following characteristics:

  • It parses the given information without any required fields. For instance, it reads the title of book in the following bibitem while it is missing other information such as author name and publisher.

    @"@book{, title = {Awesome Book}}"
    
  • The parser reads common LaTeX typeset used in bibitem such as accented letters (e.g., \"e).

  • Accounts for some common inconsistencies in bibitem. For instance volume = {{10}} while it should be volume = {10}, or doi={NA} while instead this field should not be given.

  • It comes with generic and concrete constructors, hence can use built-in models or use user-provided types. For instance:

    // Concretevarparser=newParser();// Genericvarparser=newParser<Publication,Author,Keyword>(newPublicationConstructor(),newAuthorConstructor(),newKeywordConstructor());// For details, see examples below.
  • Accessible and modifiable regex pattern, custom attribute delimiter, custom keyword delimiter, and stop-words.

Examples

Example 1: Use concrete constructor

This is the simplest usage of the parser where it parses bibitem to built-in models.

usingGenometric.BibitemParser;// Sample input.varbibitem=@"@ARTICLE{8468044, author={Jalili, Vahid}, title={Next Generation Indexing for Genomic Intervals}, year={2019}, doi={10.1109/TKDE.2018.2871031}}";// Initialize the parser.varparser=newParser();// Parse the sample bibitem.boolstatus=parser.TryParse(bibitem,outPublicationpub);// Assert the parsed information.Xunit.Assert.True(status);Xunit.Assert.Contains(pub.Authors, a =>a.FirstName=="Vahid"&&a.LastName=="Jalili");Xunit.Assert.Equal(pub.DOI,"10.1109/TKDE.2018.2871031");

Example 2: Parse into custom types

This example shows how to provide custom types to the parser. The provided types implement their respective interfaces, which are defined in this directory. See built-in models as example on how to implement custom types (e.g., the built-in Publication type).

usingGenometric.BibitemParser;usingGenometric.BibitemParser.Model;usingGenometric.BibitemParser.Constructors;// Sample input.varbibitem=@"@ARTICLE{8468044, author={Jalili, Vahid}, title={Next Generation Indexing for Genomic Intervals}, year={2019}, doi={10.1109/TKDE.2018.2871031}}";// Initialize the parser.varparser=newParser<Publication,Author,Keyword>(newPublicationConstructor(),newAuthorConstructor(),newKeywordConstructor());// Parse the sample bibitem.boolstatus=parser.TryParse(bibitem,outPublicationpub);// Assert the parsed information.Xunit.Assert.True(status);Xunit.Assert.Contains(pub.Authors, a =>a.FirstName=="Vahid"&&a.LastName=="Jalili");Xunit.Assert.Equal(pub.DOI,"10.1109/TKDE.2018.2871031");

About

Parses a LaTeX BibTeX bibitem to a C# object

Topics

Resources

Stars

4 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages