Git Product home page Git Product logo

citationparser's Introduction

CitationParser

https://travis-ci.org/mromanello/CitationParser.svg?branch=master

Canonical references (e.g. "Hom. Il. 1,124-125") use punctuation symbols in a consistent way, meaning that we can define a formal grammar to process them.

When encountering the reference "Hom. Il. 1,124-125", the human reader will parse it as follows:

  • the text preceding the numbers contains information about work and author being cited
  • the hyphen is used to specify a range of text passages, e.g. lines 124 to 125;
  • the semicolon separates a reference from another within the sanme citation (is common to chain together references to mutiple of the same work or of different works);
  • the comma separates the hierarchical levels of the work being cited. In the example above 1,124-5 stands for from Book 1, Line 124 to Book 1, Line 125
  • when the citation scope is a range, the identical hierarchical level are collapsed: 1.124 - 1.125 can be written as both 1.124-125 or 1.124 s. without any loss of information for the human reader.

The CitationParser is composed by a lexer, a parser and a tree parser written in ANTLR and compiled into Python code. The parsed reference is then serialized into JSON.

An example:

>>> cp = CitationParser()
>>> cp.parse("Hom. Il. 1,124-125")
[{'work': u'Hom. Il.', 'scp': {'start': ['1', '124'], 'end': ['1', '125']}

citationparser's People

Contributors

mromanello avatar

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.