<commit_before>**************
Gutenberg-HTTP
**************

.. image:: https://travis-ci.org/c-w/gutenberg-http.svg?branch=master
    :target: https://travis-ci.org/c-w/gutenberg-http


Overview
========

This project is a HTTP wrapper for the `Python Gutenberg API <https://github.com/c-w/gutenberg/>`_.
As such, it lets you search for books

Endpoints
=========

Fetch all metadata for a book
-----------------------------

.. sourcecode :: sh

    # fetch all metadata for a book-id
    curl 'http://gutenbergapi.org/texts/2701'

.. sourcecode :: json

    {
      "metadata": {
        "title": ["Moby Dick; Or, The Whale"],
        "rights": ["Public domain in the USA."],
        "author": ["<NAME>"],
        "subject": [
          "Mentally ill -- Fiction",
          "Whaling -- Fiction",
          "Ship captains -- Fiction",
          "Sea stories",
          "Whaling ships -- Fiction",
          "Psychological fiction",
          "Ahab, Captain (Fictitious character) -- Fiction",
          "PS",
          "Whales -- Fiction",
          "Adventure stories"
        ],
        "language": ["en"]
      },
      "text_id": 2701
    }

Fetch specific metadata for a book
----------------------------------

.. sourcecode :: sh

    # fetch specific metadata for a book-id
    curl 'http://gutenbergapi.org/texts/2701?fields=title,author'

.. sourcecode :: json

    {
      "metadata": {
        "author": ["<NAME>"],
        "title": ["Moby Dick; Or, The Whale"]
      },
      "text_id": 2701
    }

Fetch the text of a book
------------------------

.. sourcecode :: sh

    # fetch the text for a book-id
    curl 'http://gutenbergapi.org/texts/2701/body'

.. sourcecode

    MOBY DICK; OR THE WHALE

    By <NAME>

    ... (about 22,000 more lines) ...


Simple search for books
-----------------------

.. sourcecode :: sh

    # simple single-predicate query
    curl 'http://gutenbergapi.org/search/title eq The Jungle Book'

.. sourcecode :: json

    {"texts":[{"text_id":236},{"text_id":35997}]}

Complex search for books
------------------------

.. sourcecode :: sh

    # conjunctive query with field expansion
    curl 'http://gutenbergapi.org/search/author eq "<NAME>" and title eq "<NAME>"?fields=rights,language'

.. sourcecode :: json

    {
      "texts": [
        {
          "rights": ["Copyrighted. Read the copyright notice inside this book for details."],
          "language": ["en"],
          "text_id": 9147
        },
        {
          "rights": ["Public domain in the USA."],
          "language": ["en"],
          "text_id": 15
        }
      ]
    }
<commit_msg>Add missing sentence<commit_after>**************
Gutenberg-HTTP
**************

.. image:: https://travis-ci.org/c-w/gutenberg-http.svg?branch=master
    :target: https://travis-ci.org/c-w/gutenberg-http


Overview
========

This project is a HTTP wrapper for the `Python Gutenberg API <https://github.com/c-w/gutenberg/>`_.
As such, it lets you search for books, retrieve information about books and get
the text of books via a set of easy-to-use HTTP endpoints.

Endpoints
=========

Fetch all metadata for a book
-----------------------------

.. sourcecode :: sh

    # fetch all metadata for a book-id
    curl 'http://gutenbergapi.org/texts/2701'

.. sourcecode :: json

    {
      "metadata": {
        "title": ["Moby Dick; Or, The Whale"],
        "rights": ["Public domain in the USA."],
        "author": ["<NAME>"],
        "subject": [
          "Mentally ill -- Fiction",
          "Whaling -- Fiction",
          "Ship captains -- Fiction",
          "Sea stories",
          "Whaling ships -- Fiction",
          "Psychological fiction",
          "Ahab, Captain (Fictitious character) -- Fiction",
          "PS",
          "Whales -- Fiction",
          "Adventure stories"
        ],
        "language": ["en"]
      },
      "text_id": 2701
    }

Fetch specific metadata for a book
----------------------------------

.. sourcecode :: sh

    # fetch specific metadata for a book-id
    curl 'http://gutenbergapi.org/texts/2701?fields=title,author'

.. sourcecode :: json

    {
      "metadata": {
        "author": ["<NAME>"],
        "title": ["Moby Dick; Or, The Whale"]
      },
      "text_id": 2701
    }

Fetch the text of a book
------------------------

.. sourcecode :: sh

    # fetch the text for a book-id
    curl 'http://gutenbergapi.org/texts/2701/body'

.. sourcecode

    MOBY DICK; OR THE WHALE

    By <NAME>

    ... (about 22,000 more lines) ...


Simple search for books
-----------------------

.. sourcecode :: sh

    # simple single-predicate query
    curl 'http://gutenbergapi.org/search/title eq The Jungle Book'

.. sourcecode :: json

    {"texts":[{"text_id":236},{"text_id":35997}]}

Complex search for books
------------------------

.. sourcecode :: sh

    # conjunctive query with field expansion
    curl 'http://gutenbergapi.org/search/author eq "<NAME>" and title eq "Moby Dick"?fields=rights,language'

.. sourcecode :: json

    {
      "texts": [
        {
          "rights": ["Copyrighted. Read the copyright notice inside this book for details."],
          "language": ["en"],
          "text_id": 9147
        },
        {
          "rights": ["Public domain in the USA."],
          "language": ["en"],
          "text_id": 15
        }
      ]
    }

{'fraction_non_alphanumeric': 0.20123664980326025, 'fraction_numerical': 0.01461495222034851, 'mean_word_length': 1.8423855165069223, 'pattern_counts': {'":': 42, '<': 14, '<?xml version=': 0, '>': 14, 'https://': 6, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5575274', 'n_tokens_mistral': 1689, 'n_tokens_neox': 1577, 'n_words': 446}