adding parent title (for more information in parquet file)
Browse files- README.md +1 -2
- articles.parquet +2 -2
- notebooks_preprocess/preprocess_xml.ipynb +0 -181
- notebooks_preprocess/preprocess_xml_withparent.ipynb +735 -0
README.md
CHANGED
|
@@ -6,8 +6,6 @@ tags:
|
|
| 6 |
- legal
|
| 7 |
pretty_name: LoiLibre
|
| 8 |
---
|
| 9 |
-
Ce dataset correspond à des pdfs parser avec nougat (https://github.com/facebookresearch/nougat).
|
| 10 |
-
Les principaux pdfs correspondent aux différents code de lois (civil / pénal etc).
|
| 11 |
|
| 12 |
Il s'agit des pdfs preparsés qui peuvent être ensuite utilisé dans des appli autour du NLP / LLMs dans un soucis de collaborations.
|
| 13 |
|
|
@@ -24,3 +22,4 @@ La structure des données :
|
|
| 24 |
- dans notebooks_preprocess/ on retrouve les différents notebooks qui ont permis de constitué le dataset final.
|
| 25 |
|
| 26 |
|
|
|
|
|
|
| 6 |
- legal
|
| 7 |
pretty_name: LoiLibre
|
| 8 |
---
|
|
|
|
|
|
|
| 9 |
|
| 10 |
Il s'agit des pdfs preparsés qui peuvent être ensuite utilisé dans des appli autour du NLP / LLMs dans un soucis de collaborations.
|
| 11 |
|
|
|
|
| 22 |
- dans notebooks_preprocess/ on retrouve les différents notebooks qui ont permis de constitué le dataset final.
|
| 23 |
|
| 24 |
|
| 25 |
+
|
articles.parquet
CHANGED
|
@@ -1,3 +1,3 @@
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
-
oid sha256:
|
| 3 |
-
size
|
|
|
|
| 1 |
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:071a08dd9f61635918589332a2d704d4baae97d2123cc32d86dc9bce87c9de57
|
| 3 |
+
size 16980961
|
notebooks_preprocess/preprocess_xml.ipynb
DELETED
|
@@ -1,181 +0,0 @@
|
|
| 1 |
-
{
|
| 2 |
-
"cells": [
|
| 3 |
-
{
|
| 4 |
-
"cell_type": "code",
|
| 5 |
-
"execution_count": 4,
|
| 6 |
-
"metadata": {},
|
| 7 |
-
"outputs": [],
|
| 8 |
-
"source": [
|
| 9 |
-
"import pandas as pd\n",
|
| 10 |
-
"import numpy as np\n",
|
| 11 |
-
"\n",
|
| 12 |
-
"# import xml parsing tools\n",
|
| 13 |
-
"import xml.etree.ElementTree as ET\n"
|
| 14 |
-
]
|
| 15 |
-
},
|
| 16 |
-
{
|
| 17 |
-
"cell_type": "code",
|
| 18 |
-
"execution_count": 59,
|
| 19 |
-
"metadata": {},
|
| 20 |
-
"outputs": [
|
| 21 |
-
{
|
| 22 |
-
"name": "stdout",
|
| 23 |
-
"output_type": "stream",
|
| 24 |
-
"text": [
|
| 25 |
-
"Found 9 files\n",
|
| 26 |
-
"Parsing Code de la consommation.xml\n",
|
| 27 |
-
"Found 2164 articles\n",
|
| 28 |
-
"Parsing Code civil.xml\n",
|
| 29 |
-
"Found 2881 articles\n",
|
| 30 |
-
"Parsing Code du travail.xml\n",
|
| 31 |
-
"Found 11258 articles\n",
|
| 32 |
-
"Parsing Code général des impôts.xml\n",
|
| 33 |
-
"Found 2315 articles\n",
|
| 34 |
-
"Parsing Code de la propriété intellectuelle.xml\n",
|
| 35 |
-
"Found 1896 articles\n",
|
| 36 |
-
"Parsing Code de la santé publique.xml\n",
|
| 37 |
-
"Found 13242 articles\n",
|
| 38 |
-
"Parsing Code de la sécurité sociale.xml\n",
|
| 39 |
-
"Found 7318 articles\n",
|
| 40 |
-
"Parsing Code pénal.xml\n",
|
| 41 |
-
"Found 1303 articles\n",
|
| 42 |
-
"Parsing Code de la route.xml\n",
|
| 43 |
-
"Found 1157 articles\n"
|
| 44 |
-
]
|
| 45 |
-
}
|
| 46 |
-
],
|
| 47 |
-
"source": [
|
| 48 |
-
"def retrieve_every_article_xml(xml_file):\n",
|
| 49 |
-
" \"\"\"\n",
|
| 50 |
-
" This function retrieves all the articles from a xml file\n",
|
| 51 |
-
" \"\"\"\n",
|
| 52 |
-
" tree = ET.parse(xml_file)\n",
|
| 53 |
-
" root = tree.getroot()\n",
|
| 54 |
-
" \n",
|
| 55 |
-
" # find all xml tags with the name \"article\"\n",
|
| 56 |
-
" articles = root.findall(\".//article\")\n",
|
| 57 |
-
" print(\"Found {} articles\".format(len(articles)))\n",
|
| 58 |
-
" \n",
|
| 59 |
-
" return articles\n",
|
| 60 |
-
"\n",
|
| 61 |
-
"def parse_article_xml(article):\n",
|
| 62 |
-
" \n",
|
| 63 |
-
" # we we check if there is any children\n",
|
| 64 |
-
" return \"\".join(article.itertext())\n",
|
| 65 |
-
"\n",
|
| 66 |
-
"def main(main_folder=\"/Users/adrienbufort/Documents/workspace/datasets/LoiLibre/raw\"):\n",
|
| 67 |
-
" \n",
|
| 68 |
-
" # npw we can list all the xml files in the folder\n",
|
| 69 |
-
" import os\n",
|
| 70 |
-
" files = os.listdir(main_folder)\n",
|
| 71 |
-
" files = [f for f in files if f.endswith(\".xml\")]\n",
|
| 72 |
-
" print(\"Found {} files\".format(len(files)))\n",
|
| 73 |
-
" \n",
|
| 74 |
-
" # we can now parse all the files \n",
|
| 75 |
-
" df_articles = []\n",
|
| 76 |
-
" \n",
|
| 77 |
-
" for f in files:\n",
|
| 78 |
-
" print(\"Parsing {}\".format(f))\n",
|
| 79 |
-
" articles = retrieve_every_article_xml(os.path.join(main_folder, f))\n",
|
| 80 |
-
" articles_text = [parse_article_xml(a) for a in articles]\n",
|
| 81 |
-
" articles_metadata = [a.attrib for a in articles]\n",
|
| 82 |
-
" \n",
|
| 83 |
-
" dataframe_articles = pd.DataFrame({\"text\": articles_text})\n",
|
| 84 |
-
" dataframe_metadata = pd.DataFrame(articles_metadata)\n",
|
| 85 |
-
" \n",
|
| 86 |
-
" # concatenate the columns\n",
|
| 87 |
-
" dataframe_tmp = pd.concat([dataframe_articles, dataframe_metadata], axis=1)\n",
|
| 88 |
-
" \n",
|
| 89 |
-
" # add the file name\n",
|
| 90 |
-
" dataframe_tmp[\"file_name\"] = f\n",
|
| 91 |
-
" \n",
|
| 92 |
-
" df_articles.append(dataframe_tmp)\n",
|
| 93 |
-
" \n",
|
| 94 |
-
" # concatenate all the dataframes\n",
|
| 95 |
-
" df_articles = pd.concat(df_articles)\n",
|
| 96 |
-
" \n",
|
| 97 |
-
" return df_articles\n",
|
| 98 |
-
"\n",
|
| 99 |
-
"# we can now parse all the files\n",
|
| 100 |
-
"articles = main()\n",
|
| 101 |
-
" \n",
|
| 102 |
-
" \n",
|
| 103 |
-
" \n",
|
| 104 |
-
"\n"
|
| 105 |
-
]
|
| 106 |
-
},
|
| 107 |
-
{
|
| 108 |
-
"cell_type": "code",
|
| 109 |
-
"execution_count": 61,
|
| 110 |
-
"metadata": {},
|
| 111 |
-
"outputs": [],
|
| 112 |
-
"source": [
|
| 113 |
-
"# strip the text\n",
|
| 114 |
-
"articles[\"text\"] = articles[\"text\"].str.strip()"
|
| 115 |
-
]
|
| 116 |
-
},
|
| 117 |
-
{
|
| 118 |
-
"cell_type": "code",
|
| 119 |
-
"execution_count": 69,
|
| 120 |
-
"metadata": {},
|
| 121 |
-
"outputs": [],
|
| 122 |
-
"source": [
|
| 123 |
-
"# save the dataframe\n",
|
| 124 |
-
"articles.to_parquet(\"../articles.parquet\")"
|
| 125 |
-
]
|
| 126 |
-
},
|
| 127 |
-
{
|
| 128 |
-
"cell_type": "code",
|
| 129 |
-
"execution_count": 68,
|
| 130 |
-
"metadata": {},
|
| 131 |
-
"outputs": [
|
| 132 |
-
{
|
| 133 |
-
"name": "stdout",
|
| 134 |
-
"output_type": "stream",
|
| 135 |
-
"text": [
|
| 136 |
-
"Defaulting to user installation because normal site-packages is not writeable\n",
|
| 137 |
-
"Collecting pyarrow\n",
|
| 138 |
-
" Downloading pyarrow-14.0.1-cp39-cp39-macosx_11_0_arm64.whl (24.0 MB)\n",
|
| 139 |
-
"\u001b[K |████████████████████████████████| 24.0 MB 14.7 MB/s eta 0:00:01\n",
|
| 140 |
-
"\u001b[?25hRequirement already satisfied: numpy>=1.16.6 in /Users/adrienbufort/Library/Python/3.9/lib/python/site-packages (from pyarrow) (1.25.1)\n",
|
| 141 |
-
"Installing collected packages: pyarrow\n",
|
| 142 |
-
"Successfully installed pyarrow-14.0.1\n",
|
| 143 |
-
"\u001b[33mWARNING: You are using pip version 21.2.4; however, version 23.3.1 is available.\n",
|
| 144 |
-
"You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n"
|
| 145 |
-
]
|
| 146 |
-
}
|
| 147 |
-
],
|
| 148 |
-
"source": [
|
| 149 |
-
"!pip3 install pyarrow"
|
| 150 |
-
]
|
| 151 |
-
},
|
| 152 |
-
{
|
| 153 |
-
"cell_type": "code",
|
| 154 |
-
"execution_count": null,
|
| 155 |
-
"metadata": {},
|
| 156 |
-
"outputs": [],
|
| 157 |
-
"source": []
|
| 158 |
-
}
|
| 159 |
-
],
|
| 160 |
-
"metadata": {
|
| 161 |
-
"kernelspec": {
|
| 162 |
-
"display_name": "Python 3",
|
| 163 |
-
"language": "python",
|
| 164 |
-
"name": "python3"
|
| 165 |
-
},
|
| 166 |
-
"language_info": {
|
| 167 |
-
"codemirror_mode": {
|
| 168 |
-
"name": "ipython",
|
| 169 |
-
"version": 3
|
| 170 |
-
},
|
| 171 |
-
"file_extension": ".py",
|
| 172 |
-
"mimetype": "text/x-python",
|
| 173 |
-
"name": "python",
|
| 174 |
-
"nbconvert_exporter": "python",
|
| 175 |
-
"pygments_lexer": "ipython3",
|
| 176 |
-
"version": "3.9.6"
|
| 177 |
-
}
|
| 178 |
-
},
|
| 179 |
-
"nbformat": 4,
|
| 180 |
-
"nbformat_minor": 2
|
| 181 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
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|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
{
|
| 2 |
+
"cells": [
|
| 3 |
+
{
|
| 4 |
+
"cell_type": "code",
|
| 5 |
+
"execution_count": 2,
|
| 6 |
+
"metadata": {},
|
| 7 |
+
"outputs": [
|
| 8 |
+
{
|
| 9 |
+
"name": "stdout",
|
| 10 |
+
"output_type": "stream",
|
| 11 |
+
"text": [
|
| 12 |
+
"Defaulting to user installation because normal site-packages is not writeable\n",
|
| 13 |
+
"Collecting lxml\n",
|
| 14 |
+
" Downloading lxml-4.9.3.tar.gz (3.6 MB)\n",
|
| 15 |
+
"\u001b[K |████████████████████████████████| 3.6 MB 3.0 MB/s eta 0:00:01\n",
|
| 16 |
+
"\u001b[?25hBuilding wheels for collected packages: lxml\n",
|
| 17 |
+
" Building wheel for lxml (setup.py) ... \u001b[?25ldone\n",
|
| 18 |
+
"\u001b[?25h Created wheel for lxml: filename=lxml-4.9.3-cp39-cp39-macosx_10_9_universal2.whl size=3109250 sha256=23007818bc62b33d4c6a6311fe35a09a7c0ad0b8150ed0a5b095f754a363c11e\n",
|
| 19 |
+
" Stored in directory: /Users/adrienbufort/Library/Caches/pip/wheels/5c/05/aa/530f84480d476c5bb9ea09877eea78fb144ec047fbb00ee2ca\n",
|
| 20 |
+
"Successfully built lxml\n",
|
| 21 |
+
"Installing collected packages: lxml\n",
|
| 22 |
+
"Successfully installed lxml-4.9.3\n",
|
| 23 |
+
"\u001b[33mWARNING: You are using pip version 21.2.4; however, version 23.3.1 is available.\n",
|
| 24 |
+
"You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n"
|
| 25 |
+
]
|
| 26 |
+
}
|
| 27 |
+
],
|
| 28 |
+
"source": [
|
| 29 |
+
"!pip3 install lxml"
|
| 30 |
+
]
|
| 31 |
+
},
|
| 32 |
+
{
|
| 33 |
+
"cell_type": "code",
|
| 34 |
+
"execution_count": 4,
|
| 35 |
+
"metadata": {},
|
| 36 |
+
"outputs": [],
|
| 37 |
+
"source": [
|
| 38 |
+
"import pandas as pd\n",
|
| 39 |
+
"import numpy as np\n",
|
| 40 |
+
"\n",
|
| 41 |
+
"# import xml parsing tools\n",
|
| 42 |
+
"import lxml.etree as ET\n"
|
| 43 |
+
]
|
| 44 |
+
},
|
| 45 |
+
{
|
| 46 |
+
"cell_type": "code",
|
| 47 |
+
"execution_count": 18,
|
| 48 |
+
"metadata": {},
|
| 49 |
+
"outputs": [
|
| 50 |
+
{
|
| 51 |
+
"name": "stdout",
|
| 52 |
+
"output_type": "stream",
|
| 53 |
+
"text": [
|
| 54 |
+
"Found 9 files\n",
|
| 55 |
+
"Parsing Code de la consommation.xml\n",
|
| 56 |
+
"Parsing Code civil.xml\n",
|
| 57 |
+
"Parsing Code du travail.xml\n",
|
| 58 |
+
"Parsing Code général des impôts.xml\n",
|
| 59 |
+
"Parsing Code de la propriété intellectuelle.xml\n",
|
| 60 |
+
"Parsing Code de la santé publique.xml\n",
|
| 61 |
+
"Parsing Code de la sécurité sociale.xml\n",
|
| 62 |
+
"Parsing Code pénal.xml\n",
|
| 63 |
+
"Parsing Code de la route.xml\n"
|
| 64 |
+
]
|
| 65 |
+
}
|
| 66 |
+
],
|
| 67 |
+
"source": [
|
| 68 |
+
"def retrieve_every_article_xml(xml_file):\n",
|
| 69 |
+
" \"\"\"\n",
|
| 70 |
+
" This function retrieves all the articles from a xml file\n",
|
| 71 |
+
" \"\"\"\n",
|
| 72 |
+
" tree = ET.parse(xml_file)\n",
|
| 73 |
+
" root = tree.getroot()\n",
|
| 74 |
+
" \n",
|
| 75 |
+
" # find all xml tags with the name \"article\"\n",
|
| 76 |
+
" articles = root.findall(\".//article\")\n",
|
| 77 |
+
" \n",
|
| 78 |
+
" # find all the parents of the articles\n",
|
| 79 |
+
" parents = [a.getparent() for a in articles]\n",
|
| 80 |
+
" \n",
|
| 81 |
+
" return articles, parents\n",
|
| 82 |
+
"\n",
|
| 83 |
+
"def parse_article_xml(article):\n",
|
| 84 |
+
" \n",
|
| 85 |
+
" # we we check if there is any children\n",
|
| 86 |
+
" return \"\".join(article.itertext())\n",
|
| 87 |
+
"\n",
|
| 88 |
+
"def main(main_folder=\"/Users/adrienbufort/Documents/workspace/datasets/LoiLibre/raw\"):\n",
|
| 89 |
+
" \n",
|
| 90 |
+
" # npw we can list all the xml files in the folder\n",
|
| 91 |
+
" import os\n",
|
| 92 |
+
" files = os.listdir(main_folder)\n",
|
| 93 |
+
" files = [f for f in files if f.endswith(\".xml\")]\n",
|
| 94 |
+
" print(\"Found {} files\".format(len(files)))\n",
|
| 95 |
+
" \n",
|
| 96 |
+
" # we can now parse all the files \n",
|
| 97 |
+
" df_articles = []\n",
|
| 98 |
+
" \n",
|
| 99 |
+
" for f in files:\n",
|
| 100 |
+
" print(\"Parsing {}\".format(f))\n",
|
| 101 |
+
" articles, parents = retrieve_every_article_xml(os.path.join(main_folder, f))\n",
|
| 102 |
+
" \n",
|
| 103 |
+
" \n",
|
| 104 |
+
" articles_text = [parse_article_xml(a) for a in articles]\n",
|
| 105 |
+
" articles_metadata = [a.attrib for a in articles]\n",
|
| 106 |
+
" \n",
|
| 107 |
+
" title_parent = [p.attrib[\"title\"] for p in parents]\n",
|
| 108 |
+
" \n",
|
| 109 |
+
" dataframe_articles = pd.DataFrame({\"text\": articles_text, \"title_parent\": title_parent})\n",
|
| 110 |
+
" dataframe_metadata = pd.DataFrame(articles_metadata)\n",
|
| 111 |
+
" \n",
|
| 112 |
+
" # concatenate the columns\n",
|
| 113 |
+
" dataframe_tmp = pd.concat([dataframe_articles, dataframe_metadata], axis=1)\n",
|
| 114 |
+
" \n",
|
| 115 |
+
" # add the file name\n",
|
| 116 |
+
" dataframe_tmp[\"file_name\"] = f\n",
|
| 117 |
+
" \n",
|
| 118 |
+
" df_articles.append(dataframe_tmp)\n",
|
| 119 |
+
" \n",
|
| 120 |
+
" # concatenate all the dataframes\n",
|
| 121 |
+
" df_articles = pd.concat(df_articles)\n",
|
| 122 |
+
" \n",
|
| 123 |
+
" return df_articles\n",
|
| 124 |
+
"\n",
|
| 125 |
+
"# we can now parse all the files\n",
|
| 126 |
+
"articles = main()\n",
|
| 127 |
+
" \n",
|
| 128 |
+
" \n",
|
| 129 |
+
" \n",
|
| 130 |
+
"\n"
|
| 131 |
+
]
|
| 132 |
+
},
|
| 133 |
+
{
|
| 134 |
+
"cell_type": "code",
|
| 135 |
+
"execution_count": 19,
|
| 136 |
+
"metadata": {},
|
| 137 |
+
"outputs": [
|
| 138 |
+
{
|
| 139 |
+
"data": {
|
| 140 |
+
"text/html": [
|
| 141 |
+
"<div>\n",
|
| 142 |
+
"<style scoped>\n",
|
| 143 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 144 |
+
" vertical-align: middle;\n",
|
| 145 |
+
" }\n",
|
| 146 |
+
"\n",
|
| 147 |
+
" .dataframe tbody tr th {\n",
|
| 148 |
+
" vertical-align: top;\n",
|
| 149 |
+
" }\n",
|
| 150 |
+
"\n",
|
| 151 |
+
" .dataframe thead th {\n",
|
| 152 |
+
" text-align: right;\n",
|
| 153 |
+
" }\n",
|
| 154 |
+
"</style>\n",
|
| 155 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 156 |
+
" <thead>\n",
|
| 157 |
+
" <tr style=\"text-align: right;\">\n",
|
| 158 |
+
" <th></th>\n",
|
| 159 |
+
" <th>text</th>\n",
|
| 160 |
+
" <th>title_parent</th>\n",
|
| 161 |
+
" <th>cid</th>\n",
|
| 162 |
+
" <th>date</th>\n",
|
| 163 |
+
" <th>etat</th>\n",
|
| 164 |
+
" <th>id</th>\n",
|
| 165 |
+
" <th>intOrdre</th>\n",
|
| 166 |
+
" <th>modId</th>\n",
|
| 167 |
+
" <th>modTitle</th>\n",
|
| 168 |
+
" <th>num</th>\n",
|
| 169 |
+
" <th>file_name</th>\n",
|
| 170 |
+
" </tr>\n",
|
| 171 |
+
" </thead>\n",
|
| 172 |
+
" <tbody>\n",
|
| 173 |
+
" <tr>\n",
|
| 174 |
+
" <th>0</th>\n",
|
| 175 |
+
" <td>\\n \\n Pour l'application du présent...</td>\n",
|
| 176 |
+
" <td>Partie législative nouvelle</td>\n",
|
| 177 |
+
" <td>LEGIARTI000032228215</td>\n",
|
| 178 |
+
" <td>2021-12-23</td>\n",
|
| 179 |
+
" <td>VIGUEUR</td>\n",
|
| 180 |
+
" <td>LEGIARTI000044563103</td>\n",
|
| 181 |
+
" <td>1014089499</td>\n",
|
| 182 |
+
" <td>JORFTEXT000044546235</td>\n",
|
| 183 |
+
" <td>Ordonnance n°2021-1734 du 22 décembre 2021 - a...</td>\n",
|
| 184 |
+
" <td>liminaire</td>\n",
|
| 185 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 186 |
+
" </tr>\n",
|
| 187 |
+
" <tr>\n",
|
| 188 |
+
" <th>1</th>\n",
|
| 189 |
+
" <td>\\n Avant que le consommateur ne soi...</td>\n",
|
| 190 |
+
" <td>Chapitre Ier : Obligation générale d'informati...</td>\n",
|
| 191 |
+
" <td>LEGIARTI000032220903</td>\n",
|
| 192 |
+
" <td>2021-09-30</td>\n",
|
| 193 |
+
" <td>VIGUEUR</td>\n",
|
| 194 |
+
" <td>LEGIARTI000044142438</td>\n",
|
| 195 |
+
" <td>195225786</td>\n",
|
| 196 |
+
" <td>JORFTEXT000044125847</td>\n",
|
| 197 |
+
" <td>Ordonnance n°2021-1247 du 29 septembre 2021 - ...</td>\n",
|
| 198 |
+
" <td>L111-1</td>\n",
|
| 199 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 200 |
+
" </tr>\n",
|
| 201 |
+
" <tr>\n",
|
| 202 |
+
" <th>2</th>\n",
|
| 203 |
+
" <td>\\n Outre les mentions prévues à l'a...</td>\n",
|
| 204 |
+
" <td>Chapitre Ier : Obligation générale d'informati...</td>\n",
|
| 205 |
+
" <td>LEGIARTI000032220905</td>\n",
|
| 206 |
+
" <td>2016-03-16</td>\n",
|
| 207 |
+
" <td>VIGUEUR</td>\n",
|
| 208 |
+
" <td>LEGIARTI000032227350</td>\n",
|
| 209 |
+
" <td>390451572</td>\n",
|
| 210 |
+
" <td>JORFTEXT000032209352</td>\n",
|
| 211 |
+
" <td>Ordonnance n°2016-301 du 14 mars 2016 - art.</td>\n",
|
| 212 |
+
" <td>L111-2</td>\n",
|
| 213 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 214 |
+
" </tr>\n",
|
| 215 |
+
" <tr>\n",
|
| 216 |
+
" <th>3</th>\n",
|
| 217 |
+
" <td>\\n Les dispositions des articles L....</td>\n",
|
| 218 |
+
" <td>Chapitre Ier : Obligation générale d'informati...</td>\n",
|
| 219 |
+
" <td>LEGIARTI000032220907</td>\n",
|
| 220 |
+
" <td>2017-04-07</td>\n",
|
| 221 |
+
" <td>VIGUEUR</td>\n",
|
| 222 |
+
" <td>LEGIARTI000034388081</td>\n",
|
| 223 |
+
" <td>585677358</td>\n",
|
| 224 |
+
" <td>JORFTEXT000034379166</td>\n",
|
| 225 |
+
" <td>Ordonnance n°2017-484 du 6 avril 2017 - art. 17</td>\n",
|
| 226 |
+
" <td>L111-3</td>\n",
|
| 227 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 228 |
+
" </tr>\n",
|
| 229 |
+
" <tr>\n",
|
| 230 |
+
" <th>4</th>\n",
|
| 231 |
+
" <td>\\n Le fabricant ou l'importateur de...</td>\n",
|
| 232 |
+
" <td>Chapitre Ier : Obligation générale d'informati...</td>\n",
|
| 233 |
+
" <td>LEGIARTI000032220909</td>\n",
|
| 234 |
+
" <td>2021-11-16</td>\n",
|
| 235 |
+
" <td>VIGUEUR</td>\n",
|
| 236 |
+
" <td>LEGIARTI000044330854</td>\n",
|
| 237 |
+
" <td>780903144</td>\n",
|
| 238 |
+
" <td>JORFTEXT000044327272</td>\n",
|
| 239 |
+
" <td>LOI n°2021-1485 du 15 novembre 2021 - art. 18</td>\n",
|
| 240 |
+
" <td>L111-4</td>\n",
|
| 241 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 242 |
+
" </tr>\n",
|
| 243 |
+
" <tr>\n",
|
| 244 |
+
" <th>...</th>\n",
|
| 245 |
+
" <td>...</td>\n",
|
| 246 |
+
" <td>...</td>\n",
|
| 247 |
+
" <td>...</td>\n",
|
| 248 |
+
" <td>...</td>\n",
|
| 249 |
+
" <td>...</td>\n",
|
| 250 |
+
" <td>...</td>\n",
|
| 251 |
+
" <td>...</td>\n",
|
| 252 |
+
" <td>...</td>\n",
|
| 253 |
+
" <td>...</td>\n",
|
| 254 |
+
" <td>...</td>\n",
|
| 255 |
+
" <td>...</td>\n",
|
| 256 |
+
" </tr>\n",
|
| 257 |
+
" <tr>\n",
|
| 258 |
+
" <th>1152</th>\n",
|
| 259 |
+
" <td>\\n I.- Lorsque ces informations son...</td>\n",
|
| 260 |
+
" <td>Chapitre 1er : Responsabilité pénale</td>\n",
|
| 261 |
+
" <td>LEGIARTI000033668477</td>\n",
|
| 262 |
+
" <td>2021-10-21</td>\n",
|
| 263 |
+
" <td>VIGUEUR</td>\n",
|
| 264 |
+
" <td>LEGIARTI000044233123</td>\n",
|
| 265 |
+
" <td>1879048191</td>\n",
|
| 266 |
+
" <td>JORFTEXT000044229080</td>\n",
|
| 267 |
+
" <td>Arrêté du 13 octobre 2021 - art. 5</td>\n",
|
| 268 |
+
" <td>A121-3</td>\n",
|
| 269 |
+
" <td>Code de la route.xml</td>\n",
|
| 270 |
+
" </tr>\n",
|
| 271 |
+
" <tr>\n",
|
| 272 |
+
" <th>1153</th>\n",
|
| 273 |
+
" <td>\\n Sont applicables en Nouvelle-Cal...</td>\n",
|
| 274 |
+
" <td>Chapitre 3 : Dispositions applicables en Nouve...</td>\n",
|
| 275 |
+
" <td>LEGIARTI000033668491</td>\n",
|
| 276 |
+
" <td>2021-10-21</td>\n",
|
| 277 |
+
" <td>VIGUEUR</td>\n",
|
| 278 |
+
" <td>LEGIARTI000044233128</td>\n",
|
| 279 |
+
" <td>1073741823</td>\n",
|
| 280 |
+
" <td>JORFTEXT000044229080</td>\n",
|
| 281 |
+
" <td>Arrêté du 13 octobre 2021 - art. 6</td>\n",
|
| 282 |
+
" <td>A143-1</td>\n",
|
| 283 |
+
" <td>Code de la route.xml</td>\n",
|
| 284 |
+
" </tr>\n",
|
| 285 |
+
" <tr>\n",
|
| 286 |
+
" <th>1154</th>\n",
|
| 287 |
+
" <td>\\n Le modèle de fiche descripti...</td>\n",
|
| 288 |
+
" <td>Sous-section 1 : Dispositions générales</td>\n",
|
| 289 |
+
" <td>LEGIARTI000042522938</td>\n",
|
| 290 |
+
" <td>2023-06-11</td>\n",
|
| 291 |
+
" <td>VIGUEUR</td>\n",
|
| 292 |
+
" <td>LEGIARTI000047666753</td>\n",
|
| 293 |
+
" <td>1073741823</td>\n",
|
| 294 |
+
" <td>JORFTEXT000047664460</td>\n",
|
| 295 |
+
" <td>Arrêté du 9 juin 2023 - art. 1</td>\n",
|
| 296 |
+
" <td>A325-12</td>\n",
|
| 297 |
+
" <td>Code de la route.xml</td>\n",
|
| 298 |
+
" </tr>\n",
|
| 299 |
+
" <tr>\n",
|
| 300 |
+
" <th>1155</th>\n",
|
| 301 |
+
" <td>\\n Les données relatives à l'en...</td>\n",
|
| 302 |
+
" <td>Sous-section 1 : Dispositions générales</td>\n",
|
| 303 |
+
" <td>LEGIARTI000042522940</td>\n",
|
| 304 |
+
" <td>2021-03-28</td>\n",
|
| 305 |
+
" <td>VIGUEUR</td>\n",
|
| 306 |
+
" <td>LEGIARTI000043308615</td>\n",
|
| 307 |
+
" <td>1610612735</td>\n",
|
| 308 |
+
" <td>JORFTEXT000043297189</td>\n",
|
| 309 |
+
" <td>Arrêté du 15 mars 2021 - art. 1</td>\n",
|
| 310 |
+
" <td>A325-13</td>\n",
|
| 311 |
+
" <td>Code de la route.xml</td>\n",
|
| 312 |
+
" </tr>\n",
|
| 313 |
+
" <tr>\n",
|
| 314 |
+
" <th>1156</th>\n",
|
| 315 |
+
" <td>\\n Le délai prévu au quatrième ...</td>\n",
|
| 316 |
+
" <td>Sous-section 1 : Dispositions générales</td>\n",
|
| 317 |
+
" <td>LEGIARTI000042522942</td>\n",
|
| 318 |
+
" <td>2022-06-18</td>\n",
|
| 319 |
+
" <td>VIGUEUR</td>\n",
|
| 320 |
+
" <td>LEGIARTI000045936067</td>\n",
|
| 321 |
+
" <td>1879048191</td>\n",
|
| 322 |
+
" <td>JORFTEXT000045930087</td>\n",
|
| 323 |
+
" <td>Arrêté du 10 juin 2022 - art. 1</td>\n",
|
| 324 |
+
" <td>A325-14</td>\n",
|
| 325 |
+
" <td>Code de la route.xml</td>\n",
|
| 326 |
+
" </tr>\n",
|
| 327 |
+
" </tbody>\n",
|
| 328 |
+
"</table>\n",
|
| 329 |
+
"<p>43534 rows × 11 columns</p>\n",
|
| 330 |
+
"</div>"
|
| 331 |
+
],
|
| 332 |
+
"text/plain": [
|
| 333 |
+
" text \\\n",
|
| 334 |
+
"0 \\n \\n Pour l'application du présent... \n",
|
| 335 |
+
"1 \\n Avant que le consommateur ne soi... \n",
|
| 336 |
+
"2 \\n Outre les mentions prévues à l'a... \n",
|
| 337 |
+
"3 \\n Les dispositions des articles L.... \n",
|
| 338 |
+
"4 \\n Le fabricant ou l'importateur de... \n",
|
| 339 |
+
"... ... \n",
|
| 340 |
+
"1152 \\n I.- Lorsque ces informations son... \n",
|
| 341 |
+
"1153 \\n Sont applicables en Nouvelle-Cal... \n",
|
| 342 |
+
"1154 \\n Le modèle de fiche descripti... \n",
|
| 343 |
+
"1155 \\n Les données relatives à l'en... \n",
|
| 344 |
+
"1156 \\n Le délai prévu au quatrième ... \n",
|
| 345 |
+
"\n",
|
| 346 |
+
" title_parent cid \\\n",
|
| 347 |
+
"0 Partie législative nouvelle LEGIARTI000032228215 \n",
|
| 348 |
+
"1 Chapitre Ier : Obligation générale d'informati... LEGIARTI000032220903 \n",
|
| 349 |
+
"2 Chapitre Ier : Obligation générale d'informati... LEGIARTI000032220905 \n",
|
| 350 |
+
"3 Chapitre Ier : Obligation générale d'informati... LEGIARTI000032220907 \n",
|
| 351 |
+
"4 Chapitre Ier : Obligation générale d'informati... LEGIARTI000032220909 \n",
|
| 352 |
+
"... ... ... \n",
|
| 353 |
+
"1152 Chapitre 1er : Responsabilité pénale LEGIARTI000033668477 \n",
|
| 354 |
+
"1153 Chapitre 3 : Dispositions applicables en Nouve... LEGIARTI000033668491 \n",
|
| 355 |
+
"1154 Sous-section 1 : Dispositions générales LEGIARTI000042522938 \n",
|
| 356 |
+
"1155 Sous-section 1 : Dispositions générales LEGIARTI000042522940 \n",
|
| 357 |
+
"1156 Sous-section 1 : Dispositions générales LEGIARTI000042522942 \n",
|
| 358 |
+
"\n",
|
| 359 |
+
" date etat id intOrdre \\\n",
|
| 360 |
+
"0 2021-12-23 VIGUEUR LEGIARTI000044563103 1014089499 \n",
|
| 361 |
+
"1 2021-09-30 VIGUEUR LEGIARTI000044142438 195225786 \n",
|
| 362 |
+
"2 2016-03-16 VIGUEUR LEGIARTI000032227350 390451572 \n",
|
| 363 |
+
"3 2017-04-07 VIGUEUR LEGIARTI000034388081 585677358 \n",
|
| 364 |
+
"4 2021-11-16 VIGUEUR LEGIARTI000044330854 780903144 \n",
|
| 365 |
+
"... ... ... ... ... \n",
|
| 366 |
+
"1152 2021-10-21 VIGUEUR LEGIARTI000044233123 1879048191 \n",
|
| 367 |
+
"1153 2021-10-21 VIGUEUR LEGIARTI000044233128 1073741823 \n",
|
| 368 |
+
"1154 2023-06-11 VIGUEUR LEGIARTI000047666753 1073741823 \n",
|
| 369 |
+
"1155 2021-03-28 VIGUEUR LEGIARTI000043308615 1610612735 \n",
|
| 370 |
+
"1156 2022-06-18 VIGUEUR LEGIARTI000045936067 1879048191 \n",
|
| 371 |
+
"\n",
|
| 372 |
+
" modId modTitle \\\n",
|
| 373 |
+
"0 JORFTEXT000044546235 Ordonnance n°2021-1734 du 22 décembre 2021 - a... \n",
|
| 374 |
+
"1 JORFTEXT000044125847 Ordonnance n°2021-1247 du 29 septembre 2021 - ... \n",
|
| 375 |
+
"2 JORFTEXT000032209352 Ordonnance n°2016-301 du 14 mars 2016 - art. \n",
|
| 376 |
+
"3 JORFTEXT000034379166 Ordonnance n°2017-484 du 6 avril 2017 - art. 17 \n",
|
| 377 |
+
"4 JORFTEXT000044327272 LOI n°2021-1485 du 15 novembre 2021 - art. 18 \n",
|
| 378 |
+
"... ... ... \n",
|
| 379 |
+
"1152 JORFTEXT000044229080 Arrêté du 13 octobre 2021 - art. 5 \n",
|
| 380 |
+
"1153 JORFTEXT000044229080 Arrêté du 13 octobre 2021 - art. 6 \n",
|
| 381 |
+
"1154 JORFTEXT000047664460 Arrêté du 9 juin 2023 - art. 1 \n",
|
| 382 |
+
"1155 JORFTEXT000043297189 Arrêté du 15 mars 2021 - art. 1 \n",
|
| 383 |
+
"1156 JORFTEXT000045930087 Arrêté du 10 juin 2022 - art. 1 \n",
|
| 384 |
+
"\n",
|
| 385 |
+
" num file_name \n",
|
| 386 |
+
"0 liminaire Code de la consommation.xml \n",
|
| 387 |
+
"1 L111-1 Code de la consommation.xml \n",
|
| 388 |
+
"2 L111-2 Code de la consommation.xml \n",
|
| 389 |
+
"3 L111-3 Code de la consommation.xml \n",
|
| 390 |
+
"4 L111-4 Code de la consommation.xml \n",
|
| 391 |
+
"... ... ... \n",
|
| 392 |
+
"1152 A121-3 Code de la route.xml \n",
|
| 393 |
+
"1153 A143-1 Code de la route.xml \n",
|
| 394 |
+
"1154 A325-12 Code de la route.xml \n",
|
| 395 |
+
"1155 A325-13 Code de la route.xml \n",
|
| 396 |
+
"1156 A325-14 Code de la route.xml \n",
|
| 397 |
+
"\n",
|
| 398 |
+
"[43534 rows x 11 columns]"
|
| 399 |
+
]
|
| 400 |
+
},
|
| 401 |
+
"execution_count": 19,
|
| 402 |
+
"metadata": {},
|
| 403 |
+
"output_type": "execute_result"
|
| 404 |
+
}
|
| 405 |
+
],
|
| 406 |
+
"source": [
|
| 407 |
+
"# get parent\n",
|
| 408 |
+
"articles"
|
| 409 |
+
]
|
| 410 |
+
},
|
| 411 |
+
{
|
| 412 |
+
"cell_type": "code",
|
| 413 |
+
"execution_count": 71,
|
| 414 |
+
"metadata": {},
|
| 415 |
+
"outputs": [],
|
| 416 |
+
"source": [
|
| 417 |
+
"# strip the text\n",
|
| 418 |
+
"articles[\"text\"] = articles[\"text\"].str.strip()"
|
| 419 |
+
]
|
| 420 |
+
},
|
| 421 |
+
{
|
| 422 |
+
"cell_type": "code",
|
| 423 |
+
"execution_count": 72,
|
| 424 |
+
"metadata": {},
|
| 425 |
+
"outputs": [],
|
| 426 |
+
"source": [
|
| 427 |
+
"# save the dataframe\n",
|
| 428 |
+
"articles.to_parquet(\"../articles.parquet\")"
|
| 429 |
+
]
|
| 430 |
+
},
|
| 431 |
+
{
|
| 432 |
+
"cell_type": "code",
|
| 433 |
+
"execution_count": 68,
|
| 434 |
+
"metadata": {},
|
| 435 |
+
"outputs": [
|
| 436 |
+
{
|
| 437 |
+
"name": "stdout",
|
| 438 |
+
"output_type": "stream",
|
| 439 |
+
"text": [
|
| 440 |
+
"Defaulting to user installation because normal site-packages is not writeable\n",
|
| 441 |
+
"Collecting pyarrow\n",
|
| 442 |
+
" Downloading pyarrow-14.0.1-cp39-cp39-macosx_11_0_arm64.whl (24.0 MB)\n",
|
| 443 |
+
"\u001b[K |████████████████████████████████| 24.0 MB 14.7 MB/s eta 0:00:01\n",
|
| 444 |
+
"\u001b[?25hRequirement already satisfied: numpy>=1.16.6 in /Users/adrienbufort/Library/Python/3.9/lib/python/site-packages (from pyarrow) (1.25.1)\n",
|
| 445 |
+
"Installing collected packages: pyarrow\n",
|
| 446 |
+
"Successfully installed pyarrow-14.0.1\n",
|
| 447 |
+
"\u001b[33mWARNING: You are using pip version 21.2.4; however, version 23.3.1 is available.\n",
|
| 448 |
+
"You should consider upgrading via the '/Library/Developer/CommandLineTools/usr/bin/python3 -m pip install --upgrade pip' command.\u001b[0m\n"
|
| 449 |
+
]
|
| 450 |
+
}
|
| 451 |
+
],
|
| 452 |
+
"source": []
|
| 453 |
+
},
|
| 454 |
+
{
|
| 455 |
+
"cell_type": "code",
|
| 456 |
+
"execution_count": 73,
|
| 457 |
+
"metadata": {},
|
| 458 |
+
"outputs": [
|
| 459 |
+
{
|
| 460 |
+
"data": {
|
| 461 |
+
"text/html": [
|
| 462 |
+
"<div>\n",
|
| 463 |
+
"<style scoped>\n",
|
| 464 |
+
" .dataframe tbody tr th:only-of-type {\n",
|
| 465 |
+
" vertical-align: middle;\n",
|
| 466 |
+
" }\n",
|
| 467 |
+
"\n",
|
| 468 |
+
" .dataframe tbody tr th {\n",
|
| 469 |
+
" vertical-align: top;\n",
|
| 470 |
+
" }\n",
|
| 471 |
+
"\n",
|
| 472 |
+
" .dataframe thead th {\n",
|
| 473 |
+
" text-align: right;\n",
|
| 474 |
+
" }\n",
|
| 475 |
+
"</style>\n",
|
| 476 |
+
"<table border=\"1\" class=\"dataframe\">\n",
|
| 477 |
+
" <thead>\n",
|
| 478 |
+
" <tr style=\"text-align: right;\">\n",
|
| 479 |
+
" <th></th>\n",
|
| 480 |
+
" <th>text</th>\n",
|
| 481 |
+
" <th>id</th>\n",
|
| 482 |
+
" <th>cid</th>\n",
|
| 483 |
+
" <th>num</th>\n",
|
| 484 |
+
" <th>etat</th>\n",
|
| 485 |
+
" <th>intOrdre</th>\n",
|
| 486 |
+
" <th>modTitle</th>\n",
|
| 487 |
+
" <th>modId</th>\n",
|
| 488 |
+
" <th>date</th>\n",
|
| 489 |
+
" <th>file_name</th>\n",
|
| 490 |
+
" </tr>\n",
|
| 491 |
+
" </thead>\n",
|
| 492 |
+
" <tbody>\n",
|
| 493 |
+
" <tr>\n",
|
| 494 |
+
" <th>0</th>\n",
|
| 495 |
+
" <td>Pour l'application du présent code, on entend ...</td>\n",
|
| 496 |
+
" <td>LEGIARTI000044563103</td>\n",
|
| 497 |
+
" <td>LEGIARTI000032228215</td>\n",
|
| 498 |
+
" <td>liminaire</td>\n",
|
| 499 |
+
" <td>VIGUEUR</td>\n",
|
| 500 |
+
" <td>1014089499</td>\n",
|
| 501 |
+
" <td>Ordonnance n°2021-1734 du 22 décembre 2021 - a...</td>\n",
|
| 502 |
+
" <td>JORFTEXT000044546235</td>\n",
|
| 503 |
+
" <td>2021-12-23</td>\n",
|
| 504 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 505 |
+
" </tr>\n",
|
| 506 |
+
" <tr>\n",
|
| 507 |
+
" <th>1</th>\n",
|
| 508 |
+
" <td>Avant que le consommateur ne soit lié par un c...</td>\n",
|
| 509 |
+
" <td>LEGIARTI000044142438</td>\n",
|
| 510 |
+
" <td>LEGIARTI000032220903</td>\n",
|
| 511 |
+
" <td>L111-1</td>\n",
|
| 512 |
+
" <td>VIGUEUR</td>\n",
|
| 513 |
+
" <td>195225786</td>\n",
|
| 514 |
+
" <td>Ordonnance n°2021-1247 du 29 septembre 2021 - ...</td>\n",
|
| 515 |
+
" <td>JORFTEXT000044125847</td>\n",
|
| 516 |
+
" <td>2021-09-30</td>\n",
|
| 517 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 518 |
+
" </tr>\n",
|
| 519 |
+
" <tr>\n",
|
| 520 |
+
" <th>2</th>\n",
|
| 521 |
+
" <td>Outre les mentions prévues à l'article L. 111-...</td>\n",
|
| 522 |
+
" <td>LEGIARTI000032227350</td>\n",
|
| 523 |
+
" <td>LEGIARTI000032220905</td>\n",
|
| 524 |
+
" <td>L111-2</td>\n",
|
| 525 |
+
" <td>VIGUEUR</td>\n",
|
| 526 |
+
" <td>390451572</td>\n",
|
| 527 |
+
" <td>Ordonnance n°2016-301 du 14 mars 2016 - art.</td>\n",
|
| 528 |
+
" <td>JORFTEXT000032209352</td>\n",
|
| 529 |
+
" <td>2016-03-16</td>\n",
|
| 530 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 531 |
+
" </tr>\n",
|
| 532 |
+
" <tr>\n",
|
| 533 |
+
" <th>3</th>\n",
|
| 534 |
+
" <td>Les dispositions des articles L. 111-1 et L. 1...</td>\n",
|
| 535 |
+
" <td>LEGIARTI000034388081</td>\n",
|
| 536 |
+
" <td>LEGIARTI000032220907</td>\n",
|
| 537 |
+
" <td>L111-3</td>\n",
|
| 538 |
+
" <td>VIGUEUR</td>\n",
|
| 539 |
+
" <td>585677358</td>\n",
|
| 540 |
+
" <td>Ordonnance n°2017-484 du 6 avril 2017 - art. 17</td>\n",
|
| 541 |
+
" <td>JORFTEXT000034379166</td>\n",
|
| 542 |
+
" <td>2017-04-07</td>\n",
|
| 543 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 544 |
+
" </tr>\n",
|
| 545 |
+
" <tr>\n",
|
| 546 |
+
" <th>4</th>\n",
|
| 547 |
+
" <td>Le fabricant ou l'importateur de biens meubles...</td>\n",
|
| 548 |
+
" <td>LEGIARTI000044330854</td>\n",
|
| 549 |
+
" <td>LEGIARTI000032220909</td>\n",
|
| 550 |
+
" <td>L111-4</td>\n",
|
| 551 |
+
" <td>VIGUEUR</td>\n",
|
| 552 |
+
" <td>780903144</td>\n",
|
| 553 |
+
" <td>LOI n°2021-1485 du 15 novembre 2021 - art. 18</td>\n",
|
| 554 |
+
" <td>JORFTEXT000044327272</td>\n",
|
| 555 |
+
" <td>2021-11-16</td>\n",
|
| 556 |
+
" <td>Code de la consommation.xml</td>\n",
|
| 557 |
+
" </tr>\n",
|
| 558 |
+
" <tr>\n",
|
| 559 |
+
" <th>...</th>\n",
|
| 560 |
+
" <td>...</td>\n",
|
| 561 |
+
" <td>...</td>\n",
|
| 562 |
+
" <td>...</td>\n",
|
| 563 |
+
" <td>...</td>\n",
|
| 564 |
+
" <td>...</td>\n",
|
| 565 |
+
" <td>...</td>\n",
|
| 566 |
+
" <td>...</td>\n",
|
| 567 |
+
" <td>...</td>\n",
|
| 568 |
+
" <td>...</td>\n",
|
| 569 |
+
" <td>...</td>\n",
|
| 570 |
+
" </tr>\n",
|
| 571 |
+
" <tr>\n",
|
| 572 |
+
" <th>1152</th>\n",
|
| 573 |
+
" <td>I.- Lorsque ces informations sont adressées de...</td>\n",
|
| 574 |
+
" <td>LEGIARTI000044233123</td>\n",
|
| 575 |
+
" <td>LEGIARTI000033668477</td>\n",
|
| 576 |
+
" <td>A121-3</td>\n",
|
| 577 |
+
" <td>VIGUEUR</td>\n",
|
| 578 |
+
" <td>1879048191</td>\n",
|
| 579 |
+
" <td>Arrêté du 13 octobre 2021 - art. 5</td>\n",
|
| 580 |
+
" <td>JORFTEXT000044229080</td>\n",
|
| 581 |
+
" <td>2021-10-21</td>\n",
|
| 582 |
+
" <td>Code de la route.xml</td>\n",
|
| 583 |
+
" </tr>\n",
|
| 584 |
+
" <tr>\n",
|
| 585 |
+
" <th>1153</th>\n",
|
| 586 |
+
" <td>Sont applicables en Nouvelle-Calédonie, en Pol...</td>\n",
|
| 587 |
+
" <td>LEGIARTI000044233128</td>\n",
|
| 588 |
+
" <td>LEGIARTI000033668491</td>\n",
|
| 589 |
+
" <td>A143-1</td>\n",
|
| 590 |
+
" <td>VIGUEUR</td>\n",
|
| 591 |
+
" <td>1073741823</td>\n",
|
| 592 |
+
" <td>Arrêté du 13 octobre 2021 - art. 6</td>\n",
|
| 593 |
+
" <td>JORFTEXT000044229080</td>\n",
|
| 594 |
+
" <td>2021-10-21</td>\n",
|
| 595 |
+
" <td>Code de la route.xml</td>\n",
|
| 596 |
+
" </tr>\n",
|
| 597 |
+
" <tr>\n",
|
| 598 |
+
" <th>1154</th>\n",
|
| 599 |
+
" <td>Le modèle de fiche descriptive de l'état du vé...</td>\n",
|
| 600 |
+
" <td>LEGIARTI000047666753</td>\n",
|
| 601 |
+
" <td>LEGIARTI000042522938</td>\n",
|
| 602 |
+
" <td>A325-12</td>\n",
|
| 603 |
+
" <td>VIGUEUR</td>\n",
|
| 604 |
+
" <td>1073741823</td>\n",
|
| 605 |
+
" <td>Arrêté du 9 juin 2023 - art. 1</td>\n",
|
| 606 |
+
" <td>JORFTEXT000047664460</td>\n",
|
| 607 |
+
" <td>2023-06-11</td>\n",
|
| 608 |
+
" <td>Code de la route.xml</td>\n",
|
| 609 |
+
" </tr>\n",
|
| 610 |
+
" <tr>\n",
|
| 611 |
+
" <th>1155</th>\n",
|
| 612 |
+
" <td>Les données relatives à l'enlèvement, à la gar...</td>\n",
|
| 613 |
+
" <td>LEGIARTI000043308615</td>\n",
|
| 614 |
+
" <td>LEGIARTI000042522940</td>\n",
|
| 615 |
+
" <td>A325-13</td>\n",
|
| 616 |
+
" <td>VIGUEUR</td>\n",
|
| 617 |
+
" <td>1610612735</td>\n",
|
| 618 |
+
" <td>Arrêté du 15 mars 2021 - art. 1</td>\n",
|
| 619 |
+
" <td>JORFTEXT000043297189</td>\n",
|
| 620 |
+
" <td>2021-03-28</td>\n",
|
| 621 |
+
" <td>Code de la route.xml</td>\n",
|
| 622 |
+
" </tr>\n",
|
| 623 |
+
" <tr>\n",
|
| 624 |
+
" <th>1156</th>\n",
|
| 625 |
+
" <td>Le délai prévu au quatrième alinéa de l'articl...</td>\n",
|
| 626 |
+
" <td>LEGIARTI000045936067</td>\n",
|
| 627 |
+
" <td>LEGIARTI000042522942</td>\n",
|
| 628 |
+
" <td>A325-14</td>\n",
|
| 629 |
+
" <td>VIGUEUR</td>\n",
|
| 630 |
+
" <td>1879048191</td>\n",
|
| 631 |
+
" <td>Arrêté du 10 juin 2022 - art. 1</td>\n",
|
| 632 |
+
" <td>JORFTEXT000045930087</td>\n",
|
| 633 |
+
" <td>2022-06-18</td>\n",
|
| 634 |
+
" <td>Code de la route.xml</td>\n",
|
| 635 |
+
" </tr>\n",
|
| 636 |
+
" </tbody>\n",
|
| 637 |
+
"</table>\n",
|
| 638 |
+
"<p>43534 rows × 10 columns</p>\n",
|
| 639 |
+
"</div>"
|
| 640 |
+
],
|
| 641 |
+
"text/plain": [
|
| 642 |
+
" text id \\\n",
|
| 643 |
+
"0 Pour l'application du présent code, on entend ... LEGIARTI000044563103 \n",
|
| 644 |
+
"1 Avant que le consommateur ne soit lié par un c... LEGIARTI000044142438 \n",
|
| 645 |
+
"2 Outre les mentions prévues à l'article L. 111-... LEGIARTI000032227350 \n",
|
| 646 |
+
"3 Les dispositions des articles L. 111-1 et L. 1... LEGIARTI000034388081 \n",
|
| 647 |
+
"4 Le fabricant ou l'importateur de biens meubles... LEGIARTI000044330854 \n",
|
| 648 |
+
"... ... ... \n",
|
| 649 |
+
"1152 I.- Lorsque ces informations sont adressées de... LEGIARTI000044233123 \n",
|
| 650 |
+
"1153 Sont applicables en Nouvelle-Calédonie, en Pol... LEGIARTI000044233128 \n",
|
| 651 |
+
"1154 Le modèle de fiche descriptive de l'état du vé... LEGIARTI000047666753 \n",
|
| 652 |
+
"1155 Les données relatives à l'enlèvement, à la gar... LEGIARTI000043308615 \n",
|
| 653 |
+
"1156 Le délai prévu au quatrième alinéa de l'articl... LEGIARTI000045936067 \n",
|
| 654 |
+
"\n",
|
| 655 |
+
" cid num etat intOrdre \\\n",
|
| 656 |
+
"0 LEGIARTI000032228215 liminaire VIGUEUR 1014089499 \n",
|
| 657 |
+
"1 LEGIARTI000032220903 L111-1 VIGUEUR 195225786 \n",
|
| 658 |
+
"2 LEGIARTI000032220905 L111-2 VIGUEUR 390451572 \n",
|
| 659 |
+
"3 LEGIARTI000032220907 L111-3 VIGUEUR 585677358 \n",
|
| 660 |
+
"4 LEGIARTI000032220909 L111-4 VIGUEUR 780903144 \n",
|
| 661 |
+
"... ... ... ... ... \n",
|
| 662 |
+
"1152 LEGIARTI000033668477 A121-3 VIGUEUR 1879048191 \n",
|
| 663 |
+
"1153 LEGIARTI000033668491 A143-1 VIGUEUR 1073741823 \n",
|
| 664 |
+
"1154 LEGIARTI000042522938 A325-12 VIGUEUR 1073741823 \n",
|
| 665 |
+
"1155 LEGIARTI000042522940 A325-13 VIGUEUR 1610612735 \n",
|
| 666 |
+
"1156 LEGIARTI000042522942 A325-14 VIGUEUR 1879048191 \n",
|
| 667 |
+
"\n",
|
| 668 |
+
" modTitle modId \\\n",
|
| 669 |
+
"0 Ordonnance n°2021-1734 du 22 décembre 2021 - a... JORFTEXT000044546235 \n",
|
| 670 |
+
"1 Ordonnance n°2021-1247 du 29 septembre 2021 - ... JORFTEXT000044125847 \n",
|
| 671 |
+
"2 Ordonnance n°2016-301 du 14 mars 2016 - art. JORFTEXT000032209352 \n",
|
| 672 |
+
"3 Ordonnance n°2017-484 du 6 avril 2017 - art. 17 JORFTEXT000034379166 \n",
|
| 673 |
+
"4 LOI n°2021-1485 du 15 novembre 2021 - art. 18 JORFTEXT000044327272 \n",
|
| 674 |
+
"... ... ... \n",
|
| 675 |
+
"1152 Arrêté du 13 octobre 2021 - art. 5 JORFTEXT000044229080 \n",
|
| 676 |
+
"1153 Arrêté du 13 octobre 2021 - art. 6 JORFTEXT000044229080 \n",
|
| 677 |
+
"1154 Arrêté du 9 juin 2023 - art. 1 JORFTEXT000047664460 \n",
|
| 678 |
+
"1155 Arrêté du 15 mars 2021 - art. 1 JORFTEXT000043297189 \n",
|
| 679 |
+
"1156 Arrêté du 10 juin 2022 - art. 1 JORFTEXT000045930087 \n",
|
| 680 |
+
"\n",
|
| 681 |
+
" date file_name \n",
|
| 682 |
+
"0 2021-12-23 Code de la consommation.xml \n",
|
| 683 |
+
"1 2021-09-30 Code de la consommation.xml \n",
|
| 684 |
+
"2 2016-03-16 Code de la consommation.xml \n",
|
| 685 |
+
"3 2017-04-07 Code de la consommation.xml \n",
|
| 686 |
+
"4 2021-11-16 Code de la consommation.xml \n",
|
| 687 |
+
"... ... ... \n",
|
| 688 |
+
"1152 2021-10-21 Code de la route.xml \n",
|
| 689 |
+
"1153 2021-10-21 Code de la route.xml \n",
|
| 690 |
+
"1154 2023-06-11 Code de la route.xml \n",
|
| 691 |
+
"1155 2021-03-28 Code de la route.xml \n",
|
| 692 |
+
"1156 2022-06-18 Code de la route.xml \n",
|
| 693 |
+
"\n",
|
| 694 |
+
"[43534 rows x 10 columns]"
|
| 695 |
+
]
|
| 696 |
+
},
|
| 697 |
+
"execution_count": 73,
|
| 698 |
+
"metadata": {},
|
| 699 |
+
"output_type": "execute_result"
|
| 700 |
+
}
|
| 701 |
+
],
|
| 702 |
+
"source": [
|
| 703 |
+
"articles"
|
| 704 |
+
]
|
| 705 |
+
},
|
| 706 |
+
{
|
| 707 |
+
"cell_type": "code",
|
| 708 |
+
"execution_count": null,
|
| 709 |
+
"metadata": {},
|
| 710 |
+
"outputs": [],
|
| 711 |
+
"source": []
|
| 712 |
+
}
|
| 713 |
+
],
|
| 714 |
+
"metadata": {
|
| 715 |
+
"kernelspec": {
|
| 716 |
+
"display_name": "Python 3",
|
| 717 |
+
"language": "python",
|
| 718 |
+
"name": "python3"
|
| 719 |
+
},
|
| 720 |
+
"language_info": {
|
| 721 |
+
"codemirror_mode": {
|
| 722 |
+
"name": "ipython",
|
| 723 |
+
"version": 3
|
| 724 |
+
},
|
| 725 |
+
"file_extension": ".py",
|
| 726 |
+
"mimetype": "text/x-python",
|
| 727 |
+
"name": "python",
|
| 728 |
+
"nbconvert_exporter": "python",
|
| 729 |
+
"pygments_lexer": "ipython3",
|
| 730 |
+
"version": "3.9.6"
|
| 731 |
+
}
|
| 732 |
+
},
|
| 733 |
+
"nbformat": 4,
|
| 734 |
+
"nbformat_minor": 2
|
| 735 |
+
}
|