2023-02-08 20:00:47 +00:00
{
"cells": [
{
"cell_type": "markdown",
"id": "bda1f3f5",
"metadata": {},
"source": [
"# Gutenberg\n",
"\n",
2023-05-02 22:24:53 +00:00
">[Project Gutenberg](https://www.gutenberg.org/about/) is an online library of free eBooks.\n",
"\n",
"This notebook covers how to load links to `Gutenberg` e-books into a document format that we can use downstream."
2023-02-08 20:00:47 +00:00
]
},
{
"cell_type": "code",
"execution_count": 1,
"id": "9bfd5e46",
2023-05-02 22:24:53 +00:00
"metadata": {
"tags": []
},
2023-02-08 20:00:47 +00:00
"outputs": [],
"source": [
"from langchain.document_loaders import GutenbergLoader"
]
},
{
"cell_type": "code",
2023-05-02 22:24:53 +00:00
"execution_count": 2,
2023-02-08 20:00:47 +00:00
"id": "700e4ef2",
2023-05-02 22:24:53 +00:00
"metadata": {
"tags": []
},
2023-02-08 20:00:47 +00:00
"outputs": [],
"source": [
"loader = GutenbergLoader('https://www.gutenberg.org/cache/epub/69972/pg69972.txt')"
]
},
{
"cell_type": "code",
2023-05-02 22:24:53 +00:00
"execution_count": 3,
2023-02-08 20:00:47 +00:00
"id": "b6f28930",
2023-05-02 22:24:53 +00:00
"metadata": {
"tags": []
},
2023-02-08 20:00:47 +00:00
"outputs": [],
"source": [
"data = loader.load()"
]
},
{
"cell_type": "code",
2023-05-02 22:24:53 +00:00
"execution_count": 7,
2023-02-08 20:00:47 +00:00
"id": "7d436441",
2023-05-02 22:24:53 +00:00
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"'The Project Gutenberg eBook of The changed brides, by Emma Dorothy\\r\\n\\n\\nEliza Nevitte Southworth\\r\\n\\n\\n\\r\\n\\n\\nThis eBook is for the use of anyone anywhere in the United States and\\r\\n\\n\\nmost other parts of the world at no cost and with almost no restrictions\\r\\n\\n\\nwhatsoever. You may copy it, give it away or re-u'"
]
},
"execution_count": 7,
"metadata": {},
"output_type": "execute_result"
}
],
2023-02-08 20:00:47 +00:00
"source": [
2023-05-02 22:24:53 +00:00
"data[0].page_content[:300]"
2023-02-08 20:00:47 +00:00
]
},
{
"cell_type": "code",
2023-05-02 22:24:53 +00:00
"execution_count": 9,
"id": "1481beb1-12a7-4654-9d91-bfd101109891",
"metadata": {
"tags": []
},
"outputs": [
{
"data": {
"text/plain": [
"{'source': 'https://www.gutenberg.org/cache/epub/69972/pg69972.txt'}"
]
},
"execution_count": 9,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"data[0].metadata"
]
2023-02-08 20:00:47 +00:00
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3 (ipykernel)",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
2023-05-02 22:24:53 +00:00
"version": "3.10.6"
2023-02-08 20:00:47 +00:00
}
},
"nbformat": 4,
"nbformat_minor": 5
}