Giter Club home page Giter Club logo

from-htdp-to-racket's Introduction

From HtDP to Racket

This repo contains code to extract the ISBN(s) from a given string, as an example of translation from ISL+ into Racket.

Additionally, this repo provides support for extracting ISBN(s) from pdf files, as well as for obtaining book information about those files from remote providers.

Software requirements

You need to install the following packages:

  • Racket distribution: version 7.3 or above [1].

  • Extra packages: pdf-read, json-pointer [2].

[1]. You can still make the code work on a Racket version below 7.3 if you remove #lang htdp/isl+ from isbn.v1.rkt and use instead ISL+ as Language selected from the DrRacket menu like in isbn.v0.rkt.

[2]. pdf-read is required by the pdf-isbn.rkt module. json-pointer is required by the book-info.rkt module.

Other requirements (Disclaimer)

The provider-gb.rkt implements functionality to retrieve and parse records using the Google Books API. Google requires an API key or authorization token to use this API. As this code is only for didactic purposes they are not provided. If you are going to use this code in production, you must fork it and modify it as needed to include your own credentials. For further information see https://developers.google.com/books/docs/v1/using

Core modules source code

Transformation stages and corresponding files are as follows:

  1. isbn.v0.rkt: ISBN extraction program written in ISL+.

  2. isbn.v1.rkt: #lang htdp/isl+ with 2htdp/abstraction for and match.

  3. isbn.v2.rkt: Switch to lang# racket/base + Racket batteries.

  4. isbn.v3.rkt: Native Racket for and match constructs.

  5. isbn.v4.rkt: Regular Expressions.

  6. isbn.v5.rkt: Contracts and Submodules.

  7. isbn.v6.rkt: The main functions in its own module; rackunit and test submodules.

    isbn-utils.rkt: Contracts and auxiliary functions in its own module; rackunit and test submodules.

  8. isbn.v7.rkt (aka. isbn.rkt): Optional and keyword arguments; syntatic abstraction; performance.

Auxiliary files for ISL+ implementation

  • isbn-lib.rkt: Helpers for the ISL+ implementation in isbn.v0.rkt and isbn.v1.rkt.

  • isbn-teachpack.rkt: Exports provide, which is used by isbn-lib.rkt.

Supplementary modules

In order to show a more realistic application of the code above a few more modules have been included.

ISBN Extraction from pdf files

  • pdf-isbn.rkt

Bibligraphic information retrieval and parsing

  • book-info.rkt: The main module for this functionality.

  • ejsp.rkt: A few extensions to the json-pointer module to be used here.

  • provider.rkt: Data definitions for providers.

  • provider-gb.rkt: Google Books provider.

  • provider-lc.rkt: Library of Congress provider.

  • provider-ol.rkt: Open Library provider.

Main

  • main-example.rkt: A very simple client that uses the Racket code in this repo.

Examples for test cases

ISBN extraction

  • test-isbn-examples

ISBN extraction from pdf

  • test-damaged.pdf: An invalid pdf file.

  • test-isbn-examples.pdf: ISBN examples in pdf.

  • test-with-image-only.pdf: A pdf with only an image.

  • test-with-isbn-10-only.pdf: A pdf with only and ISBN-10.

  • test-without-isbn.pdf: A pdf without ISBN.

Bibliographic information

  • test-gb-json-example.json: A book JSON record from Google Books.

  • test-lc-xml-example.xml: A book XML record from the Library of Congress.

  • test-ol-json-example.json: A book JSON record from the Open Library.

  • test-gb-json-no-item-example.json: A JSON response from Google Books that doesn't contain any book record.

  • test-lc-xml-no-item-example.xml: An XML response from the Library of Congress that doesn't contain any book record.

  • test-ol-json-no-item-example.json: A JSON response from the Open Library that doesn't contain any book record.

Documentation

isbn.v*.rkt transformations are documented in doc/. The main document is htdp2racket.html. Scribble sources for all parts are also included.

Acknowledgments

Matthias Felleisen derserves special thanks for his support, comments, suggestions, and thoughtful code improvements.

from-htdp-to-racket's People

Watchers

 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.